From 2f1e930668c1a2205a09ee835908d28b2bdedcdd Mon Sep 17 00:00:00 2001 From: Arno Date: Fri, 2 Feb 2018 18:13:27 +0100 Subject: Implement context menu for search results Subclass QTreeView to show a custom context menu. Since the depth of some items is > 1, add an option to expand and collapse a node recursively. --- searchdialog.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'searchdialog.cpp') diff --git a/searchdialog.cpp b/searchdialog.cpp index 1f59839..8c255c8 100644 --- a/searchdialog.cpp +++ b/searchdialog.cpp @@ -15,6 +15,7 @@ #include #include "searchdialog.h" +#include "searchview.h" #include "helper.h" SearchDialog::SearchDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, f){ @@ -39,7 +40,7 @@ SearchDialog::SearchDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, mResM = new QStandardItemModel; QSortFilterProxyModel *resMProxy = new QSortFilterProxyModel; resMProxy->setSourceModel(mResM); - mResV = new QTreeView; + mResV = new SearchView; mResV->setModel(resMProxy); connect(mResV->selectionModel(), &QItemSelectionModel::currentChanged, this, &SearchDialog::doResult); QHBoxLayout *resGBL = new QHBoxLayout; @@ -49,7 +50,7 @@ SearchDialog::SearchDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent, mDataM = new QStandardItemModel; QSortFilterProxyModel *dataMProxy = new QSortFilterProxyModel; dataMProxy->setSourceModel(mDataM); - mDataV = new QTreeView; + mDataV = new SearchView; mDataV->setModel(dataMProxy); QHBoxLayout *dataGBL = new QHBoxLayout; dataGBL->addWidget(mDataV); -- cgit v1.2.3-70-g09d2