From 032ea241916549801cd656593821d43bb8fd9f55 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sat, 24 May 2014 10:28:11 -0700 Subject: 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 --- qt-ui/divelistview.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'qt-ui') 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())); } } -- cgit v1.2.3-70-g09d2