From 5961579cda23c05b1d4bdc8251accfc8132aad4f Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 15 Nov 2013 11:32:19 +0900 Subject: Manually add trips from dive list context menu We had all the logic, we were just lacking the UI. Fixes #243 Signed-off-by: Dirk Hohndel --- qt-ui/divelistview.cpp | 25 ++++++++++++++++++++++++- qt-ui/divelistview.h | 1 + 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'qt-ui') diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index b905b32be..57fae2955 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -459,6 +459,28 @@ void DiveListView::removeFromTrip() reload(currentLayout, false); } +void DiveListView::newTripAbove() +{ + dive_trip_t *trip; + int idx; + struct dive *d = (struct dive *) contextMenuIndex.data(DiveTripModel::DIVE_ROLE).value(); + if (!d) // shouldn't happen as we only are setting up this action if this is a dive + return; + rememberSelection(); + trip = create_and_hookup_trip_from_dive(d); + if (d->selected) { + for_each_dive(idx, d) { + if (!d->selected) + continue; + add_dive_to_trip(d, trip); + } + } + trip->expanded = 1; + mark_divelist_changed(TRUE); + reload(currentLayout, false); + restoreSelection(); +} + void DiveListView::deleteDive() { int nr; @@ -506,7 +528,8 @@ void DiveListView::contextMenuEvent(QContextMenuEvent *event) popup.addAction(tr("collapse all"), this, SLOT(collapseAll())); collapseAction = popup.addAction(tr("collapse"), this, SLOT(collapseAll())); if (d) { - popup.addAction(tr("remove dive from trip"), this, SLOT(removeFromTrip())); + popup.addAction(tr("Remove dive from trip"), this, SLOT(removeFromTrip())); + popup.addAction(tr("Create new trip above"), this, SLOT(newTripAbove())); } if (trip) { popup.addAction(tr("Merge trip with trip above"), this, SLOT(mergeTripAbove())); diff --git a/qt-ui/divelistview.h b/qt-ui/divelistview.h index 222a9929a..d03167635 100644 --- a/qt-ui/divelistview.h +++ b/qt-ui/divelistview.h @@ -42,6 +42,7 @@ public slots: void fixMessyQtModelBehaviour(); void mergeTripAbove(); void mergeTripBelow(); + void newTripAbove(); void mergeDives(); void saveSelectedDivesAs(); void exportSelectedDivesAsUDDF(); -- cgit v1.2.3-70-g09d2