From 6d52d0f7618f4b4b42c3b0e543ef5891abdd4f0d Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Tue, 23 Feb 2016 14:05:28 +0100 Subject: QML UI: add context menu to delete dive This allows the user to delete the currently shown dive. This action takes effect right away, no confirmation, it gets right away written to the local git cache. One idea for an undo operation here could be to simply reset the git tree to HEAD^ and reload. Not elegant, but would work. Signed-off-by: Dirk Hohndel --- qt-mobile/qml/DiveDetails.qml | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'qt-mobile/qml/DiveDetails.qml') diff --git a/qt-mobile/qml/DiveDetails.qml b/qt-mobile/qml/DiveDetails.qml index 1877feb09..83a8b3a93 100644 --- a/qt-mobile/qml/DiveDetails.qml +++ b/qt-mobile/qml/DiveDetails.qml @@ -31,16 +31,19 @@ MobileComponents.Page { states: [ State { name: "view" + PropertyChanges { target: diveDetailsPage; contextualActions: deleteAction } PropertyChanges { target: diveDetailList; visible: true } PropertyChanges { target: detailsEditScroll; visible: false } }, State { name: "edit" + PropertyChanges { target: diveDetailsPage; contextualActions: null } PropertyChanges { target: diveDetailList; visible: false } PropertyChanges { target: detailsEditScroll; visible: true } }, State { name: "add" + PropertyChanges { target: diveDetailsPage; contextualActions: null } PropertyChanges { target: diveDetailList; visible: false } PropertyChanges { target: detailsEditScroll; visible: true } } @@ -53,26 +56,19 @@ MobileComponents.Page { state = "view" Qt.inputMethod.hide() } -/* this can be done by hitting the back key - contextualActions: [ + + property list deleteAction: [ Action { - text: state === "view" ? "Back to dive list" : "Cancel" - iconName: "dialog-cancel" + text: "Delete dive" + iconName: "trash-empty" onTriggered: { - if (state === "view") { - stackView.pop() - contextDrawer.close() - } else if (state === "edit") { - endEditMode() - contextDrawer.close() - } else { - endAddMode() - contextDrawer.close() - } + manager.deleteDive(diveDetailsListView.currentItem.modelData.dive.id) + stackView.pop() + contextDrawer.close() } } ] - */ + mainAction: Action { iconName: state !== "view" ? "document-save" : "document-edit" onTriggered: { -- cgit v1.2.3-70-g09d2