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" #include "wstring_qt.hh"
HeadwordListModel::HeadwordListModel( QObject * parent ) : 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) void HeadwordListModel::addMatches( QStringList matches)
{ {
QStringList filtered; QStringList filtered;
for ( auto & w : matches ) { for ( auto const & w : matches ) {
if ( !words.contains( w ) ) { if ( !words.contains( w ) ) {
filtered << w; filtered << w;
} }

View file

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

View file

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