Skip to content

Commit

Permalink
Implemented Incremental Search signal-slot
Browse files Browse the repository at this point in the history
  • Loading branch information
HerrKermet committed Sep 22, 2023
1 parent 7672597 commit b810358
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
3 changes: 3 additions & 0 deletions plugins/gui/include/gui/searchbar/searchoptions_dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,13 @@ namespace hal
* @param parent - The parent widget.
*/
SearchOptionsDialog(QWidget *parent = nullptr);
void emitOptions();

Q_SIGNALS:
void emitOptions(QString text, int options);

public Q_SLOTS:
void textEdited(QString);
void optionsChanged();
void emitStartSearch();

Expand All @@ -67,5 +69,6 @@ namespace hal
QLabel* mColumnLabel;
QPushButton* mSearchBtn;
QPushButton* mCloseBtn;

};
}
2 changes: 1 addition & 1 deletion plugins/gui/src/searchbar/search_proxy_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace hal {
void SearchProxyModel::startSearch(QString text, int options)
{
opts = new SearchOptions(options);
qInfo() << "startSearch emitted";
qInfo() << "Proxy received searchOptions";
}

}
24 changes: 20 additions & 4 deletions plugins/gui/src/searchbar/searchoptions_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace hal
searchProxy = new SearchProxyModel();
//TODO fix layout size to prevent overlapping
mLayout = new QGridLayout(this);

mLayout->setRowMinimumHeight(0,35);
mInputBox = new QComboBox();
mInputBox->setEditable(true);

Expand All @@ -27,7 +27,7 @@ namespace hal
mSearchBtn = new QPushButton("Search");
mCloseBtn = new QPushButton("Close");

searchText = mInputBox->currentText();
QString searchString;

mLayout->addWidget(mInputBox, 0, 0, 0, 3, Qt::AlignTop);
mLayout->addWidget(mIncrementalSearchBox, 1, 0);
Expand All @@ -42,6 +42,7 @@ namespace hal
connect(mCloseBtn, &QPushButton::clicked, this, &SearchOptionsDialog::close);

//TODO get corresponding proxy
connect(mInputBox, &QComboBox::currentTextChanged, this, &SearchOptionsDialog::textEdited);
connect(mSearchBtn, &QPushButton::clicked, this, &SearchOptionsDialog::emitStartSearch);
connect(this, SIGNAL(emitOptions(QString, int)), searchProxy, SLOT(startSearch(QString, int)));

Expand All @@ -52,15 +53,30 @@ namespace hal

}

void SearchOptionsDialog::textEdited(QString text)
{
//check if incremental search is enabled and start and min 3 symbols
if(mIncrementalSearchBox->isChecked() && text.length() >= 3){
emitOptions();
}
}

void SearchOptionsDialog::emitStartSearch()
{
qInfo() << "emitstartSearch";
Q_EMIT emitOptions(searchText, SearchOptions::toInt(mExactMatchBox->isChecked(), mCaseSensitiveBox->isChecked(), mRegExBox->isChecked(), {}));
emitOptions();
}

void SearchOptionsDialog::optionsChanged()
{
// searchProxy->startSearch(12, "");
//searchProxy->updateProxy(mExactMatchBox->isChecked(), mCaseSensitiveBox->isChecked(), mRegExBox->isChecked(), {}, searchText);
}

void SearchOptionsDialog::emitOptions(){
searchText = mInputBox->currentText();
int options = SearchOptions::toInt(mExactMatchBox->isChecked(), mCaseSensitiveBox->isChecked(), mRegExBox->isChecked(), {});
qInfo() << "Emit search with string: " << searchText << " and options: " << options;

Q_EMIT emitOptions(searchText, options);
}
}

0 comments on commit b810358

Please sign in to comment.