summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2020-07-29 05:16:15 +0200
committerArno <arno@disconnect.de>2020-07-29 05:16:15 +0200
commitb384639799a68ca7d7c07eee518d3ef4b34812d0 (patch)
treecce9e8dcf49f1cfc781e1647bb1215f7c7217b0c
parentcb0b296a44656de9e4528772f8bb904db37fc9aa (diff)
downloadSheMov-b384639799a68ca7d7c07eee518d3ef4b34812d0.tar.gz
SheMov-b384639799a68ca7d7c07eee518d3ef4b34812d0.tar.bz2
SheMov-b384639799a68ca7d7c07eee518d3ef4b34812d0.zip
Add collapse and expand all to SearchDialog
Thought about using QSignalMapper for this, but that would be too convoluted, thus the inline functions.
-rw-r--r--searchdialog.cpp18
-rw-r--r--searchdialog.h10
2 files changed, 24 insertions, 4 deletions
diff --git a/searchdialog.cpp b/searchdialog.cpp
index acfe1dd..6d81b58 100644
--- a/searchdialog.cpp
+++ b/searchdialog.cpp
@@ -167,16 +167,30 @@ ActorsAndMore::ActorsAndMore(QWidget *parent, Qt::WindowFlags flags) : QWidget(p
mResultModel = new QStandardItemModel;
QSortFilterProxyModel *resultProxy = new QSortFilterProxyModel;
resultProxy->setSourceModel(mResultModel);
- mResultView = new QTreeView;
+ mResultView = new SmView;
mResultView->setModel(resultProxy);
connect(mResultView->selectionModel(), &QItemSelectionModel::currentChanged, this, &ActorsAndMore::doData);
+ QAction *resultCollapseAllA = new QAction(Helper::icon(Qt::transparent, qApp->palette().color(QPalette::Text), QChar(0x2191), true, false), tr("Collapse all"), this);
+ connect(resultCollapseAllA, &QAction::triggered, this, &ActorsAndMore::collapseAllResult);
+ mResultView->addAction(resultCollapseAllA);
+ QAction *resultExpandAllA = new QAction(Helper::icon(Qt::transparent, qApp->palette().color(QPalette::Text), QChar(0x2193), true, false), tr("Expand all"), this);
+ connect(resultExpandAllA, &QAction::triggered, this, &ActorsAndMore::expandAllResult);
+ mResultView->addAction(resultExpandAllA);
+
+ // data view
mDataModel = new QStandardItemModel;
QSortFilterProxyModel *dataProxy = new QSortFilterProxyModel;
dataProxy->setSourceModel(mDataModel);
- mDataView = new QTreeView;
+ mDataView = new SmView;
mDataView->setExpandsOnDoubleClick(false);
connect(mDataView, &QTreeView::doubleClicked, this, &ActorsAndMore::dataDoubleClicked);
mDataView->setModel(dataProxy);
+ QAction *dataCollapseAllA = new QAction(Helper::icon(Qt::transparent, qApp->palette().color(QPalette::Text), QChar(0x2191), true, false), tr("Collapse all"), this);
+ connect(dataCollapseAllA, &QAction::triggered, this, &ActorsAndMore::collapseAllData);
+ mDataView->addAction(dataCollapseAllA);
+ QAction *dataExpandAllA = new QAction(Helper::icon(Qt::transparent, qApp->palette().color(QPalette::Text), QChar(0x2193), true, false), tr("Expand all"), this);
+ connect(dataExpandAllA, &QAction::triggered, this, &ActorsAndMore::expandAllData);
+ mDataView->addAction(dataExpandAllA);
QHBoxLayout *resultHBL = new QHBoxLayout;
resultHBL->addWidget(mResultView);
resultHBL->addWidget(mDataView);
diff --git a/searchdialog.h b/searchdialog.h
index 19d0d09..09ed259 100644
--- a/searchdialog.h
+++ b/searchdialog.h
@@ -10,6 +10,8 @@
#include <QDialog>
+#include "smview.h"
+
class QCheckBox;
class QLineEdit;
class QPushButton;
@@ -57,6 +59,10 @@ class ActorsAndMore : public QWidget {
void doSearch();
void doData(const QModelIndex &cur, const QModelIndex &prev);
void dataDoubleClicked(const QModelIndex &index);
+ void collapseAllResult() { mResultView->collapseAll(); }
+ void expandAllResult() { mResultView->expandAll(); }
+ void collapseAllData() { mDataView->collapseAll(); }
+ void expandAllData() { mDataView->expandAll(); }
private:
void searchActor(const QString &actor);
@@ -68,8 +74,8 @@ class ActorsAndMore : public QWidget {
QLineEdit *mSearch;
QStandardItemModel *mResultModel;
QStandardItemModel *mDataModel;
- QTreeView *mResultView;
- QTreeView *mDataView;
+ SmView *mResultView;
+ SmView *mDataView;
};
class SearchDialog : public QDialog {