From 3f9fd8aa2ae8bfb92c033f5a9f5d72c411530438 Mon Sep 17 00:00:00 2001 From: HerrKermet Date: Sun, 15 Oct 2023 13:17:53 +0200 Subject: [PATCH] Searchbar will now start default search if searchstring is empty Filterbutton's state will now only be checked if the filter differs from the default settings Call to SearchOptions() will now return a Filter with default settings {search in each column with no specific filter} --- plugins/gui/src/searchbar/searchbar.cpp | 17 ++++++++++++++--- plugins/gui/src/searchbar/searchoptions.cpp | 8 +++++++- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/plugins/gui/src/searchbar/searchbar.cpp b/plugins/gui/src/searchbar/searchbar.cpp index 6709352f109..b7ae52ba00c 100644 --- a/plugins/gui/src/searchbar/searchbar.cpp +++ b/plugins/gui/src/searchbar/searchbar.cpp @@ -13,6 +13,7 @@ #include #include #include +#include namespace hal { @@ -205,9 +206,9 @@ namespace hal void Searchbar::handleTextEdited() { repolish(); - //if the line is empty then start a search with the given filter + //if the line is empty then start a search with default searchOptions - no filtering if(mLineEdit->text().isEmpty()){ - Q_EMIT triggerNewSearch(mLineEdit->text(), mCurrentOptions->toInt()); + Q_EMIT triggerNewSearch(mLineEdit->text(), SearchOptions().toInt()); } else if(mIncrementalSearch && mLineEdit->text().length() >= mMinCharsToStartIncSearch) { @@ -217,7 +218,13 @@ namespace hal void Searchbar::handleReturnPressed() { - Q_EMIT triggerNewSearch(mLineEdit->text(), mCurrentOptions->toInt()); + //if the line is empty then start a search with default searchOptions - no filtering + if(mLineEdit->text().isEmpty()){ + Q_EMIT triggerNewSearch(mLineEdit->text(), SearchOptions().toInt()); + } + else{ + Q_EMIT triggerNewSearch(mLineEdit->text(), mCurrentOptions->toInt()); + } } void Searchbar::handleClearClicked() @@ -271,5 +278,9 @@ namespace hal qInfo() << "Searchbar starts search with: " << txt << " " << mCurrentOptions->toInt() << " inc search: " << mIncrementalSearch << " " << mMinCharsToStartIncSearch; Q_EMIT triggerNewSearch(txt, mCurrentOptions->toInt()); } + if(mCurrentOptions->toInt() != SearchOptions().toInt()) + mSearchOptionsButton->setChecked(true); + else + mSearchOptionsButton->setChecked(false); } } diff --git a/plugins/gui/src/searchbar/searchoptions.cpp b/plugins/gui/src/searchbar/searchoptions.cpp index 926e6798c61..f7486ca2878 100644 --- a/plugins/gui/src/searchbar/searchoptions.cpp +++ b/plugins/gui/src/searchbar/searchoptions.cpp @@ -5,7 +5,13 @@ namespace hal { SearchOptions::SearchOptions() - {}; + { + //construct default filter options + mExactMatch = false; + mCaseSensitive = false; + mRegularExpression = false; + mColumns = {}; + }; SearchOptions::SearchOptions(int code) {