diff --git a/plugins/gui/include/gui/searchbar/searchoptions_dialog.h b/plugins/gui/include/gui/searchbar/searchoptions_dialog.h index 1b7ea325e87..7ce1973086b 100644 --- a/plugins/gui/include/gui/searchbar/searchoptions_dialog.h +++ b/plugins/gui/include/gui/searchbar/searchoptions_dialog.h @@ -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(); @@ -67,5 +69,6 @@ namespace hal QLabel* mColumnLabel; QPushButton* mSearchBtn; QPushButton* mCloseBtn; + }; } diff --git a/plugins/gui/src/searchbar/search_proxy_model.cpp b/plugins/gui/src/searchbar/search_proxy_model.cpp index b990786d049..18c1e01ecb5 100644 --- a/plugins/gui/src/searchbar/search_proxy_model.cpp +++ b/plugins/gui/src/searchbar/search_proxy_model.cpp @@ -10,7 +10,7 @@ namespace hal { void SearchProxyModel::startSearch(QString text, int options) { opts = new SearchOptions(options); - qInfo() << "startSearch emitted"; + qInfo() << "Proxy received searchOptions"; } } diff --git a/plugins/gui/src/searchbar/searchoptions_dialog.cpp b/plugins/gui/src/searchbar/searchoptions_dialog.cpp index 4ff2fe86aa2..da24ae6d128 100644 --- a/plugins/gui/src/searchbar/searchoptions_dialog.cpp +++ b/plugins/gui/src/searchbar/searchoptions_dialog.cpp @@ -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); @@ -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); @@ -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))); @@ -52,10 +53,17 @@ 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() @@ -63,4 +71,12 @@ namespace hal // 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); + } }