diff --git a/plugins/gui/include/gui/selection_details_widget/selection_details_widget.h b/plugins/gui/include/gui/selection_details_widget/selection_details_widget.h index 9f7df1984ce..b2bea6b6fd8 100644 --- a/plugins/gui/include/gui/selection_details_widget/selection_details_widget.h +++ b/plugins/gui/include/gui/selection_details_widget/selection_details_widget.h @@ -27,6 +27,8 @@ #include "gui/content_widget/content_widget.h" #include "gui/selection_details_widget/tree_navigation/selection_tree_item.h" +#include "gui/selection_details_widget/tree_navigation/selection_tree_proxy.h" +#include "gui/selection_details_widget/tree_navigation/selection_tree_model.h" #include "hal_core/defines.h" class QTableWidget; @@ -371,5 +373,7 @@ namespace hal GateDetailsTabWidget* mGateDetailsTabs; NetDetailsTabWidget* mNetDetailsTabs; ModuleDetailsTabWidget* mModuleDetailsTabs; + SelectionTreeProxyModel* mSelectionTreeProxyModel; + SelectionTreeModel* mSelectionTreeModel; }; } diff --git a/plugins/gui/include/gui/selection_details_widget/tree_navigation/selection_tree_proxy.h b/plugins/gui/include/gui/selection_details_widget/tree_navigation/selection_tree_proxy.h index 651f397bc22..1bf2949f006 100644 --- a/plugins/gui/include/gui/selection_details_widget/tree_navigation/selection_tree_proxy.h +++ b/plugins/gui/include/gui/selection_details_widget/tree_navigation/selection_tree_proxy.h @@ -26,6 +26,7 @@ #pragma once #include "gui/gui_utils/sort.h" +#include "gui/searchbar/search_proxy_model.h" #include #include @@ -39,7 +40,7 @@ namespace hal * A proxy model to filter the SelectionTreeModel. This allows to search efficiently through the * model and the results can be displayed within the view in a tree-styled fashion. */ - class SelectionTreeProxyModel : public QSortFilterProxyModel + class SelectionTreeProxyModel : public SearchProxyModel { Q_OBJECT public: @@ -78,6 +79,7 @@ namespace hal * @param sortMechanism - The new mechanism. */ void setSortMechanism(gui_utility::mSortMechanism sortMechanism); + void startSearch(QString text, int options) override; protected: diff --git a/plugins/gui/src/module_dialog/module_dialog.cpp b/plugins/gui/src/module_dialog/module_dialog.cpp index 3cc9ea7eabe..42baae901b9 100644 --- a/plugins/gui/src/module_dialog/module_dialog.cpp +++ b/plugins/gui/src/module_dialog/module_dialog.cpp @@ -85,6 +85,7 @@ namespace hal { mTreeView->setModel(mModuleTreeProxyModel); mTreeView->expandAll(); + mButtonBox = new QDialogButtonBox(QDialogButtonBox::Ok|QDialogButtonBox::Cancel, this); layout->addWidget(mButtonBox, 3, 0, 1, 3, Qt::AlignHCenter); diff --git a/plugins/gui/src/selection_details_widget/selection_details_widget.cpp b/plugins/gui/src/selection_details_widget/selection_details_widget.cpp index 56dfae249cc..8c3043b3068 100644 --- a/plugins/gui/src/selection_details_widget/selection_details_widget.cpp +++ b/plugins/gui/src/selection_details_widget/selection_details_widget.cpp @@ -74,7 +74,20 @@ namespace hal QVBoxLayout* containerLayout = new QVBoxLayout(treeViewContainer); + + + + mSelectionTreeView = new SelectionTreeView(treeViewContainer); + + mSelectionTreeModel = new SelectionTreeModel(this); + mSelectionTreeProxyModel = new SelectionTreeProxyModel(this); + mSelectionTreeProxyModel->setSourceModel(mSelectionTreeModel); + mSelectionTreeView->setModel(mSelectionTreeProxyModel); + + //mSelectionTreeProxyModel->setSourceModel(mSelectionTreeView->model()); + //mSelectionTreeView->setModel(mSelectionTreeProxyModel); + mSelectionTreeView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); mSelectionTreeView->setMinimumWidth(280); mSelectionTreeView->hide(); @@ -143,6 +156,8 @@ namespace hal connect(mSearchbar, &Searchbar::textEdited, this, &SelectionDetailsWidget::updateSearchIcon); connect(mSelectionTreeView, &SelectionTreeView::itemDoubleClicked, this, &SelectionDetailsWidget::handleTreeViewItemFocusClicked); connect(mSelectionTreeView, &SelectionTreeView::focusItemClicked, this, &SelectionDetailsWidget::handleTreeViewItemFocusClicked); + + connect(mSearchbar, &Searchbar::triggerNewSearch, mSelectionTreeProxyModel, &SelectionTreeProxyModel::startSearch); } void SelectionDetailsWidget::selectionToModuleMenu() @@ -315,8 +330,8 @@ namespace hal } SelectionTreeProxyModel* proxy = static_cast(mSelectionTreeView->model()); + //mSelectionTreeView->setModel(mSelectionTreeProxyModel); if (proxy->isGraphicsBusy()) return; - if (!mSearchbar->getCurrentText().isEmpty()) { mSearchbar->clear(); diff --git a/plugins/gui/src/selection_details_widget/tree_navigation/selection_tree_model.cpp b/plugins/gui/src/selection_details_widget/tree_navigation/selection_tree_model.cpp index 56778615107..78e605069ac 100644 --- a/plugins/gui/src/selection_details_widget/tree_navigation/selection_tree_model.cpp +++ b/plugins/gui/src/selection_details_widget/tree_navigation/selection_tree_model.cpp @@ -16,6 +16,7 @@ namespace hal mRootItem = new SelectionTreeItemRoot; // root item has no parent + connect(gNetlistRelay,&NetlistRelay::moduleNameChanged,this,&SelectionTreeModel::handleModuleItemChanged); connect(gNetlistRelay,&NetlistRelay::moduleTypeChanged,this,&SelectionTreeModel::handleModuleItemChanged); connect(gNetlistRelay,&NetlistRelay::gateNameChanged,this,&SelectionTreeModel::handleGateItemChanged); diff --git a/plugins/gui/src/selection_details_widget/tree_navigation/selection_tree_proxy.cpp b/plugins/gui/src/selection_details_widget/tree_navigation/selection_tree_proxy.cpp index 3f98627c2bb..55a21b0aba4 100644 --- a/plugins/gui/src/selection_details_widget/tree_navigation/selection_tree_proxy.cpp +++ b/plugins/gui/src/selection_details_widget/tree_navigation/selection_tree_proxy.cpp @@ -7,7 +7,7 @@ namespace hal { SelectionTreeProxyModel::SelectionTreeProxyModel(QObject* parent) - : QSortFilterProxyModel(parent), mSortMechanism(gui_utility::mSortMechanism::lexical), mGraphicsBusy(0) + : SearchProxyModel(parent), mSortMechanism(gui_utility::mSortMechanism::lexical), mGraphicsBusy(0) { mFilterExpression.setPatternOptions(QRegularExpression::CaseInsensitiveOption); } @@ -73,4 +73,12 @@ namespace hal mSortMechanism = sortMechanism; invalidate(); } + + void SelectionTreeProxyModel::startSearch(QString text, int options) + { + mSearchString = text; + mSearchOptions = SearchOptions(options); + invalidateFilter(); + } + }