aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/divelistview.cpp16
-rw-r--r--qt-ui/divelistview.h1
2 files changed, 17 insertions, 0 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp
index 19d27a53e..d66313823 100644
--- a/qt-ui/divelistview.cpp
+++ b/qt-ui/divelistview.cpp
@@ -17,6 +17,7 @@
#include <QAction>
#include <QLineEdit>
#include <QKeyEvent>
+#include <QMenu>
DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false),
currentHeaderClicked(-1), searchBox(new QLineEdit(this))
@@ -270,3 +271,18 @@ void DiveListView::selectionChanged(const QItemSelection& selected, const QItemS
// now that everything is up to date, update the widgets
Q_EMIT currentDiveChanged(selected_dive);
}
+
+void DiveListView::mousePressEvent(QMouseEvent *event)
+{
+ // all we care about is the unmodified right click
+ if ( ! (event->modifiers() == Qt::NoModifier && event->buttons() & Qt::RightButton)) {
+ event->ignore();
+ QTreeView::mousePressEvent(event);
+ return;
+ }
+ QMenu popup(this);
+ popup.addAction(tr("expand all"), this, SLOT(expandAll()));
+ QAction *collapseAllAction = popup.addAction(tr("collapse all"), this, SLOT(collapseAll()));
+ if (popup.exec(event->globalPos()) == collapseAllAction)
+ selectDive(current_dive, true);
+}
diff --git a/qt-ui/divelistview.h b/qt-ui/divelistview.h
index 630f74e7f..2bce35612 100644
--- a/qt-ui/divelistview.h
+++ b/qt-ui/divelistview.h
@@ -28,6 +28,7 @@ public:
bool eventFilter(QObject* , QEvent* );
void unselectDives();
void selectDive(struct dive *, bool scrollto = false);
+ void mousePressEvent(QMouseEvent *event);
public slots:
void toggleColumnVisibilityByIndex();