Skip to content

Commit

Permalink
opt: headword dialog ,limited filter number
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyifang committed Jun 24, 2024
1 parent 19d3160 commit 03adffe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/headwordsmodel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ void HeadwordListModel::requestFinished()
return;
}
beginResetModel();
words.clear();
words << filterWords;
words = QStringList( filterWords );
endResetModel();
emit numberPopulated( words.size() );
}
}

Expand Down
12 changes: 8 additions & 4 deletions src/ui/dictheadwords.cc
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,6 @@ DictHeadwords::DictHeadwords( QWidget * parent, Config::Class & cfg_, Dictionary

connect( ui.headersListView, &QAbstractItemView::clicked, this, &DictHeadwords::itemClicked );

connect( proxy, &QAbstractItemModel::dataChanged, this, &DictHeadwords::showHeadwordsNumber );
connect( ui.filterMaxResult, &QSpinBox::valueChanged, this, [ this ]( int _value ) {
model->setMaxFilterResults( _value );
} );

ui.headersListView->installEventFilter( this );

Expand All @@ -136,6 +132,7 @@ void DictHeadwords::setup( Dictionary::Class * dict_ )
const auto size = dict->getWordCount();
std::shared_ptr< HeadwordListModel > other = std::make_shared< HeadwordListModel >();
model.swap( other );
model->setMaxFilterResults( ui.filterMaxResult->value() );
model->setDict( dict );
proxy->setSourceModel( model.get() );
proxy->sort( 0 );
Expand All @@ -155,6 +152,13 @@ void DictHeadwords::setup( Dictionary::Class * dict_ )
dictId = QString( dict->getId().c_str() );

QApplication::restoreOverrideCursor();
connect( model.get(), &HeadwordListModel::numberPopulated, this, [ this ]( int _ ) {
showHeadwordsNumber();
} );
connect( proxy, &QAbstractItemModel::dataChanged, this, &DictHeadwords::showHeadwordsNumber );
connect( ui.filterMaxResult, &QSpinBox::valueChanged, this, [ this ]( int _value ) {
model->setMaxFilterResults( _value );
} );
}

void DictHeadwords::savePos()
Expand Down

0 comments on commit 03adffe

Please sign in to comment.