mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Add context menu to dive list
So far we support "expand all" and "collapse" all. This still needs to be restricted to only be shown when in trip / tree mode. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
4b405caa2c
commit
74d23ed83b
2 changed files with 17 additions and 0 deletions
|
@ -17,6 +17,7 @@
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QKeyEvent>
|
#include <QKeyEvent>
|
||||||
|
#include <QMenu>
|
||||||
|
|
||||||
DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false),
|
DiveListView::DiveListView(QWidget *parent) : QTreeView(parent), mouseClickSelection(false),
|
||||||
currentHeaderClicked(-1), searchBox(new QLineEdit(this))
|
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
|
// now that everything is up to date, update the widgets
|
||||||
Q_EMIT currentDiveChanged(selected_dive);
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -28,6 +28,7 @@ public:
|
||||||
bool eventFilter(QObject* , QEvent* );
|
bool eventFilter(QObject* , QEvent* );
|
||||||
void unselectDives();
|
void unselectDives();
|
||||||
void selectDive(struct dive *, bool scrollto = false);
|
void selectDive(struct dive *, bool scrollto = false);
|
||||||
|
void mousePressEvent(QMouseEvent *event);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void toggleColumnVisibilityByIndex();
|
void toggleColumnVisibilityByIndex();
|
||||||
|
|
Loading…
Add table
Reference in a new issue