Skip to content

Commit

Permalink
implemented SelectionTreeProxyModel iheritance from SearchProxyModel
Browse files Browse the repository at this point in the history
  • Loading branch information
neoneela committed Oct 14, 2023
1 parent 44779f6 commit 2d74494
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -371,5 +373,7 @@ namespace hal
GateDetailsTabWidget* mGateDetailsTabs;
NetDetailsTabWidget* mNetDetailsTabs;
ModuleDetailsTabWidget* mModuleDetailsTabs;
SelectionTreeProxyModel* mSelectionTreeProxyModel;
SelectionTreeModel* mSelectionTreeModel;
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#pragma once

#include "gui/gui_utils/sort.h"
#include "gui/searchbar/search_proxy_model.h"

#include <QSortFilterProxyModel>
#include <QRegularExpression>
Expand All @@ -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:
Expand Down Expand Up @@ -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:

Expand Down
1 change: 1 addition & 0 deletions plugins/gui/src/module_dialog/module_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -315,8 +330,8 @@ namespace hal
}

SelectionTreeProxyModel* proxy = static_cast<SelectionTreeProxyModel*>(mSelectionTreeView->model());
//mSelectionTreeView->setModel(mSelectionTreeProxyModel);
if (proxy->isGraphicsBusy()) return;

if (!mSearchbar->getCurrentText().isEmpty())
{
mSearchbar->clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -73,4 +73,12 @@ namespace hal
mSortMechanism = sortMechanism;
invalidate();
}

void SelectionTreeProxyModel::startSearch(QString text, int options)
{
mSearchString = text;
mSearchOptions = SearchOptions(options);
invalidateFilter();
}

}

0 comments on commit 2d74494

Please sign in to comment.