Skip to content

Commit

Permalink
Searchbar will now start default search if searchstring is empty
Browse files Browse the repository at this point in the history
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}
  • Loading branch information
HerrKermet committed Oct 15, 2023
1 parent eee3798 commit 3f9fd8a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
17 changes: 14 additions & 3 deletions plugins/gui/src/searchbar/searchbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <QStyle>
#include <QToolButton>
#include <QDebug>
#include <gui/searchbar/searchoptions.h>

namespace hal
{
Expand Down Expand Up @@ -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)
{
Expand All @@ -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()
Expand Down Expand Up @@ -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);
}
}
8 changes: 7 additions & 1 deletion plugins/gui/src/searchbar/searchoptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@
namespace hal
{
SearchOptions::SearchOptions()
{};
{
//construct default filter options
mExactMatch = false;
mCaseSensitive = false;
mRegularExpression = false;
mColumns = {};
};

SearchOptions::SearchOptions(int code)
{
Expand Down

0 comments on commit 3f9fd8a

Please sign in to comment.