diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-05-24 10:28:11 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-05-24 10:28:11 -0700 |
commit | 032ea241916549801cd656593821d43bb8fd9f55 (patch) | |
tree | c9600a5e4f7a4887cc60fa32a02699793b8fb2be | |
parent | bc047238d4630c2090cbd424e26f6476b1cd435a (diff) | |
download | subsurface-032ea241916549801cd656593821d43bb8fd9f55.tar.gz |
Dive list: more consistent handling of "add to trip"
When multiple dives are selected, we need to be smarter about when to show
"add to trip immediately above" or "... below". This code is quite
readable, I think, and does the trick.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | qt-ui/divelistview.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index 49877dc71..c541783cc 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -750,9 +750,20 @@ void DiveListView::contextMenuEvent(QContextMenuEvent *event) popup.addAction(tr("remove dive(s) from trip"), this, SLOT(removeFromTrip())); popup.addAction(tr("create new trip above"), this, SLOT(newTripAbove())); if (!d->divetrip) { - if (is_trip_before_after(d, (currentOrder == Qt::AscendingOrder))) + struct dive *top = d; + struct dive *bottom = d; + if (d->selected) { + if (currentOrder == Qt::AscendingOrder) { + top = first_selected_dive(); + bottom = last_selected_dive(); + } else { + top = last_selected_dive(); + bottom = first_selected_dive(); + } + } + if (is_trip_before_after(top, (currentOrder == Qt::AscendingOrder))) popup.addAction(tr("add dive(s) to trip immediately above"), this, SLOT(addToTripAbove())); - if (is_trip_before_after(d, (currentOrder == Qt::DescendingOrder))) + if (is_trip_before_after(bottom, (currentOrder == Qt::DescendingOrder))) popup.addAction(tr("add dive(s) to trip immediately below"), this, SLOT(addToTripBelow())); } } |