From 084175f56fef6479d690478e82e7bb8793a03925 Mon Sep 17 00:00:00 2001 From: xiaoyifang <105986+xiaoyifang@users.noreply.github.com> Date: Sat, 22 Apr 2023 12:33:11 +0800 Subject: [PATCH] fix: code smell --- src/headwordsmodel.cc | 8 ++++---- src/headwordsmodel.hh | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/headwordsmodel.cc b/src/headwordsmodel.cc index 25cb0322..8cb1139a 100644 --- a/src/headwordsmodel.cc +++ b/src/headwordsmodel.cc @@ -124,16 +124,16 @@ int HeadwordListModel::wordCount() const QVariant HeadwordListModel::data( const QModelIndex & index, int role ) const { if( !index.isValid() ) - return QVariant(); + return {}; if( index.row() >= totalSize || index.row() < 0 || index.row() >= words.size() ) - return QVariant(); + return {}; if( role == Qt::DisplayRole ) { return words.at( index.row() ); } - return QVariant(); + return {}; } bool HeadwordListModel::canFetchMore( const QModelIndex & parent ) const @@ -174,7 +174,7 @@ void HeadwordListModel::fetchMore( const QModelIndex & parent ) emit numberPopulated( words.size() ); } -int HeadwordListModel::getCurrentIndex() +int HeadwordListModel::getCurrentIndex() const { return index; } diff --git a/src/headwordsmodel.hh b/src/headwordsmodel.hh index 4c30909c..7515cff1 100644 --- a/src/headwordsmodel.hh +++ b/src/headwordsmodel.hh @@ -22,7 +22,7 @@ public: void setFilter( QRegularExpression ); void appendWord( const QString & word ); void addMatches( QStringList matches ); - int getCurrentIndex(); + int getCurrentIndex() const; bool containWord( const QString & word ); QSet< QString > getRemainRows( int & nodeIndex ); signals: