diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2014-05-24 08:27:42 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2014-05-24 08:27:42 -0700 |
commit | ba1c4fcec1760748846ff6ad14127409bed0a783 (patch) | |
tree | c0e4b16c620ccfd420459605c1e7e4f5caf8b75f /qt-ui/divelistview.cpp | |
parent | 2a88a72f1aeae6a0dd9713d9c4779d8d009f9335 (diff) | |
download | subsurface-ba1c4fcec1760748846ff6ad14127409bed0a783.tar.gz |
Add some helper functions
First step towards getting the "add to trip" logic in the divelist context
menu to be consistent and correct.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/divelistview.cpp')
-rw-r--r-- | qt-ui/divelistview.cpp | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index ebad73b09..49877dc71 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -634,18 +634,10 @@ void DiveListView::addToTrip(bool below) if (d->selected) { // we are right-clicking on one of possibly many selected dive(s) // find the top selected dive, depending on the list order - if (delta == 1) { - for_each_dive (idx, d) { - if (d->selected) - pd = d; - } - d = pd; // this way we have the chronologically last - } else { - for_each_dive (idx, d) { - if (d->selected) - break; // now that's the chronologically first - } - } + if (delta == 1) + d = last_selected_dive(); + else + d = first_selected_dive(); } // now find the trip "above" in the dive list if ((pd = get_dive(get_divenr(d) + delta)) != NULL) { @@ -757,8 +749,12 @@ void DiveListView::contextMenuEvent(QContextMenuEvent *event) if (d) { popup.addAction(tr("remove dive(s) from trip"), this, SLOT(removeFromTrip())); popup.addAction(tr("create new trip above"), this, SLOT(newTripAbove())); - popup.addAction(tr("add dive(s) to trip immediately above"), this, SLOT(addToTripAbove())); - popup.addAction(tr("add dive(s) to trip immediately below"), this, SLOT(addToTripBelow())); + if (!d->divetrip) { + if (is_trip_before_after(d, (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))) + popup.addAction(tr("add dive(s) to trip immediately below"), this, SLOT(addToTripBelow())); + } } if (trip) { popup.addAction(tr("merge trip with trip above"), this, SLOT(mergeTripAbove())); |