aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/divelistview.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-15 11:32:19 +0900
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-15 11:32:19 +0900
commit5961579cda23c05b1d4bdc8251accfc8132aad4f (patch)
treeaa7d7acc9db3e556b8b719768933654de1b68a2d /qt-ui/divelistview.cpp
parent2c57568d563feb95ef67bb8480bbb839d2daaaf8 (diff)
downloadsubsurface-5961579cda23c05b1d4bdc8251accfc8132aad4f.tar.gz
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 <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/divelistview.cpp')
-rw-r--r--qt-ui/divelistview.cpp25
1 files changed, 24 insertions, 1 deletions
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<void*>();
+ 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()));