Skip to content

Commit

Permalink
added signal logic in SearchBar class
Browse files Browse the repository at this point in the history
  • Loading branch information
neoneela committed Sep 26, 2023
1 parent abefc8f commit ea6d712
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 19 deletions.
3 changes: 2 additions & 1 deletion plugins/gui/include/gui/searchbar/searchbar.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ namespace hal
// If set to false, one has to manually implement 'Exact Match'/'Case Sensitive' functionality
bool mEmitTextWithFlags = true;

SearchOptions mCurrentOptions;
SearchOptions* mCurrentOptions;
bool mIncrementalSearch;
};
}
2 changes: 1 addition & 1 deletion plugins/gui/include/gui/searchbar/searchoptions_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ namespace hal
*/
SearchOptionsDialog(QWidget *parent = nullptr);
void emitOptions();
SearchOptions getOptions() const;
SearchOptions* getOptions() const;
QString getText() const;

Q_SIGNALS:
Expand Down
17 changes: 8 additions & 9 deletions plugins/gui/src/searchbar/searchbar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ namespace hal

ensurePolished();

mCurrentOptions = new SearchOptions(9);//exact match and search in all columns is on
mIncrementalSearch = false;
mSearchIconLabel->setPixmap(gui_utility::getStyledSvgIcon(mSearchIconStyle, mSearchIcon).pixmap(QSize(16, 16)));
mSearchIconLabel->installEventFilter(this);
mLineEdit->setPlaceholderText("Search");
Expand Down Expand Up @@ -221,18 +223,15 @@ namespace hal
void Searchbar::handleTextEdited()
{
repolish();
// TODO : emit only if incremental search switched on and minimum number of characters entered in search field

// TODO : should emit triggerNewSearch()
// Q_EMIT textEdited(mEmitTextWithFlags ? getCurrentTextWithFlags() : getCurrentText());
if(mIncrementalSearch && mLineEdit->text().length()>=3)
{
Q_EMIT triggerNewSearch(mLineEdit->text(), mCurrentOptions->toInt());
}
}

void Searchbar::handleReturnPressed()
{
// Q_EMIT returnPressed();

// TODO : check if member variables present
Q_EMIT triggerNewSearch(mLineEdit->text(), mCurrentOptions.toInt());
Q_EMIT triggerNewSearch(mLineEdit->text(), mCurrentOptions->toInt());
}

void Searchbar::handleClearClicked()
Expand Down Expand Up @@ -286,7 +285,7 @@ namespace hal
mCurrentOptions = sd.getOptions();

QString txt = sd.getText(); // TODO : get modified text from sd
Q_EMIT triggerNewSearch(txt, mCurrentOptions.toInt());
Q_EMIT triggerNewSearch(txt, mCurrentOptions->toInt());
}
}
}
14 changes: 6 additions & 8 deletions plugins/gui/src/searchbar/searchoptions_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,6 @@ namespace hal
//TODO maybe delete this because edit triggers also the mSearchBtn signal as if it was clicked. Currently the emit search is emited twice while pressing Enter
// discuss with Joern
connect(mLineEdit, &QLineEdit::returnPressed, this, &SearchOptionsDialog::emitStartSearch);



}


Expand All @@ -60,18 +57,19 @@ namespace hal
}


void SearchOptionsDialog::emitOptions(){
void SearchOptionsDialog::emitOptions()
{
mSearchText = mInputBox->currentText();
int options = SearchOptions::toInt(mExactMatchBox->isChecked(), mCaseSensitiveBox->isChecked(), mRegExBox->isChecked(), {});
int options = SearchOptions::toInt(mExactMatchBox->isChecked(), mCaseSensitiveBox->isChecked(), mRegExBox->isChecked(), {}); //TO-DO: fill the columns
qInfo() << "Emit search with string: " << mSearchText << " and options: " << options;

Q_EMIT emitOptions(mSearchText, options);
}

SearchOptions SearchOptionsDialog::getOptions() const
SearchOptions* SearchOptionsDialog::getOptions() const
{
SearchOptions retval;
// TODO :: retval.setOptions()
SearchOptions* retval = new SearchOptions();
retval->setOptions(mExactMatchBox->isChecked(), mCaseSensitiveBox->isChecked(), mRegExBox->isChecked(), {}); //TO-DO: fill the columns
return retval;
}

Expand Down

0 comments on commit ea6d712

Please sign in to comment.