fix : code smell

This commit is contained in:
xiaoyifang 2023-04-22 13:32:10 +08:00
parent 72fca59a92
commit 21bab62263
3 changed files with 5 additions and 6 deletions

View file

@ -2,7 +2,7 @@
#include "wstring_qt.hh"
HeadwordListModel::HeadwordListModel( QObject * parent ) :
QAbstractListModel( parent ), filtering( false ), totalSize(0), index( 0 ),ptr( 0 )
QAbstractListModel( parent ), filtering( false ), totalSize(0), index( 0 ),ptr( nullptr )
{
}
@ -49,7 +49,7 @@ void HeadwordListModel::setFilter( QRegularExpression reg )
void HeadwordListModel::addMatches( QStringList matches)
{
QStringList filtered;
for ( auto & w : matches ) {
for ( auto const & w : matches ) {
if ( !words.contains( w ) ) {
filtered << w;
}

View file

@ -201,7 +201,7 @@ void DictHeadwords::filterChangedInternal()
QTimer::singleShot( 100, this, &DictHeadwords::filterChanged );
}
QRegularExpression DictHeadwords::getFilterRegex( )
QRegularExpression DictHeadwords::getFilterRegex( ) const
{
const QRegExp::PatternSyntax syntax =
static_cast< QRegExp::PatternSyntax >(ui.searchModeCombo->itemData(
@ -368,8 +368,7 @@ void DictHeadwords::saveHeadersToFile()
QStringList filtered;
const QRegularExpression regExp = getFilterRegex();
if(regExp.isValid() && !regExp.pattern().isEmpty()){
if ( const QRegularExpression regExp = getFilterRegex(); regExp.isValid() && !regExp.pattern().isEmpty() ) {
filtered = sortedWords.filter( regExp );
}
else{

View file

@ -48,7 +48,7 @@ private:
private slots:
void savePos();
void filterChangedInternal();
QRegularExpression getFilterRegex();
QRegularExpression getFilterRegex() const;
void filterChanged();
void exportButtonClicked();
void okButtonClicked();