summaryrefslogtreecommitdiffstats
path: root/qt-ui
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-06-06 06:51:15 +0900
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-06-06 06:51:15 +0900
commit235833b93e3c065ab0759617a5a331bcdb568ddf (patch)
treefd7369f10ac87df455fd97a33dc73ce6bb2b7016 /qt-ui
parent582253fe88a6e50c416ba7e037f99f1508e48a56 (diff)
downloadsubsurface-235833b93e3c065ab0759617a5a331bcdb568ddf.tar.gz
Only show expand/collapse context menu when in tree mode
The options make no sense when in list view mode. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui')
-rw-r--r--qt-ui/divelistview.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp
index 9e3ceb52e..4aeb3b646 100644
--- a/qt-ui/divelistview.cpp
+++ b/qt-ui/divelistview.cpp
@@ -274,6 +274,7 @@ void DiveListView::selectionChanged(const QItemSelection& selected, const QItemS
void DiveListView::mousePressEvent(QMouseEvent *event)
{
+ QAction *collapseAction = NULL;
// all we care about is the unmodified right click
if ( ! (event->modifiers() == Qt::NoModifier && event->buttons() & Qt::RightButton)) {
event->ignore();
@@ -281,11 +282,13 @@ void DiveListView::mousePressEvent(QMouseEvent *event)
return;
}
QMenu popup(this);
- popup.addAction(tr("expand all"), this, SLOT(expandAll()));
- popup.addAction(tr("collapse all"), this, SLOT(collapseAll()));
- QAction *collapseAction = popup.addAction(tr("collapse"), this, SLOT(collapseAll()));
+ if (currentLayout == DiveTripModel::TREE) {
+ popup.addAction(tr("expand all"), this, SLOT(expandAll()));
+ popup.addAction(tr("collapse all"), this, SLOT(collapseAll()));
+ collapseAction = popup.addAction(tr("collapse"), this, SLOT(collapseAll()));
+ }
// "collapse all" really closes all trips,
- // "collaps" keeps the trip with the selected dive open
- if (popup.exec(event->globalPos()) == collapseAction)
+ // "collapse" keeps the trip with the selected dive open
+ if (popup.exec(event->globalPos()) == collapseAction && collapseAction)
selectDive(current_dive, true);
}