From 2c8f962ecc32dc5b5d3c9f3218568ff1c6b4064f Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 20 Feb 2020 13:25:44 -0800 Subject: mobile UI: allow adding a dive to a trip from context menu Right now this is only available on the DiveDetails screen. The menu entries are only enabled if there is such a trip to add the dive to (and if the dive isn't already part of a trip). Signed-off-by: Dirk Hohndel --- mobile-widgets/qml/DiveDetails.qml | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'mobile-widgets') diff --git a/mobile-widgets/qml/DiveDetails.qml b/mobile-widgets/qml/DiveDetails.qml index 5bed0f5ef..f1feeedd7 100644 --- a/mobile-widgets/qml/DiveDetails.qml +++ b/mobile-widgets/qml/DiveDetails.qml @@ -61,13 +61,28 @@ Kirigami.Page { property QtObject removeDiveFromTripAction: Kirigami.Action { text: qsTr ("Remove this dive from trip") - enabled: currentItem && currentItem.modelData.diveInTrip + enabled: currentItem && currentItem.modelData && currentItem.modelData.diveInTrip onTriggered: { manager.appendTextToLog("remove dive #" + currentItem.modelData.number + " from its trip") manager.removeDiveFromTrip(currentItem.modelData.id) } } - property QtObject addDiveToTripAction: Kirigami.Action { text: qsTr ("Add dive to trip ") } + property QtObject addDiveToTripAboveAction: Kirigami.Action { + text: qsTr ("Add dive to trip above") + enabled: currentItem && currentItem.modelData && !currentItem.modelData.diveInTrip && currentItem.modelData.tripAbove !== -1 + onTriggered: { + manager.appendTextToLog("add dive #" + currentItem.modelData.number + " to trip with id " + currentItem.modelData.tripAbove) + manager.addDiveToTrip(currentItem.modelData.id, currentItem.modelData.tripAbove) + } + } + property QtObject addDiveToTripBelowAction: Kirigami.Action { + text: qsTr ("Add dive to trip below") + enabled: currentItem && currentItem.modelData && !currentItem.modelData.diveInTrip && currentItem.modelData.tripBelow !== -1 + onTriggered: { + manager.appendTextToLog("add dive #" + currentItem.modelData.number + " to trip with id " + currentItem.modelData.tripBelow) + manager.addDiveToTrip(currentItem.modelData.id, currentItem.modelData.tripBelow) + } + } property QtObject undoAction: Kirigami.Action { text: qsTr("Undo") + " " + manager.undoText enabled: manager.undoText !== "" @@ -78,7 +93,7 @@ Kirigami.Page { enabled: manager.redoText !== "" onTriggered: manager.redo() } - property variant contextactions: [ removeDiveFromTripAction, addDiveToTripAction, undoAction, redoAction ] + property variant contextactions: [ removeDiveFromTripAction, addDiveToTripAboveAction, addDiveToTripBelowAction, undoAction, redoAction ] states: [ State { -- cgit v1.2.3-70-g09d2