Skip to content

Commit

Permalink
update search history whenever search get triggered
Browse files Browse the repository at this point in the history
  • Loading branch information
joern274 committed Nov 10, 2023
1 parent 8a982c8 commit 62f9736
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions plugins/gui/src/searchbar/searchbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ namespace hal
else if(mIncrementalSearch && mLineEdit->text().length() >= mMinCharsToStartIncSearch)
{
Q_EMIT triggerNewSearch(mLineEdit->text(), mCurrentOptions->toInt());
updateSearchHistory(mLineEdit->text());
}
}

Expand Down Expand Up @@ -282,8 +283,7 @@ namespace hal

qInfo() << "Searchbar starts search with: " << txt << " " << mCurrentOptions->toInt() << " inc search: " << mIncrementalSearch << " " << mMinCharsToStartIncSearch;
Q_EMIT triggerNewSearch(txt, mCurrentOptions->toInt());


updateSearchHistory(txt);
}
if(mCurrentOptions->toInt() != SearchOptions().toInt())
mSearchOptionsButton->setChecked(true);
Expand All @@ -294,11 +294,11 @@ namespace hal
void Searchbar::updateSearchHistory(QString entry){
if(entry.length() >= 3 && !mSearchHistory.contains(entry))
{

if(!mSearchHistory.empty() && entry.startsWith(mSearchHistory[0])) mSearchHistory[0] = entry;
if(!mSearchHistory.empty() && entry.startsWith(mSearchHistory[0]))
mSearchHistory[0] = entry;
else
{
if (mSearchHistory.length() >= 10) mSearchHistory.pop_back();
if (mSearchHistory.length() >= 10) mSearchHistory.removeLast();
mSearchHistory.prepend(entry);
}
}
Expand Down

0 comments on commit 62f9736

Please sign in to comment.