[PATCH 2/3] Move endEditMode() to DiveDetails.qml

subsurface at henrik.synth.no subsurface at henrik.synth.no
Sun Feb 7 13:23:07 PST 2016


From: Henrik Brautaset Aronsen <subsurface at henrik.synth.no>

Having endEditMode() in main.qml seemed wrong somehow.

Signed-off-by: Henrik Brautaset Aronsen <subsurface at henrik.synth.no>
---
 qt-mobile/qml/DiveDetails.qml | 10 +++++++---
 qt-mobile/qml/TopBar.qml      |  2 +-
 qt-mobile/qml/main.qml        | 17 ++++++-----------
 3 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/qt-mobile/qml/DiveDetails.qml b/qt-mobile/qml/DiveDetails.qml
index b2744ec..7fc2a8b 100644
--- a/qt-mobile/qml/DiveDetails.qml
+++ b/qt-mobile/qml/DiveDetails.qml
@@ -47,9 +47,7 @@ MobileComponents.Page {
 		iconName: state !== "view" ? "dialog-cancel" : "document-edit"
 		onTriggered: {
 			if (state === "edit") {
-				// just cancel the edit state
-				state = "view"
-				Qt.inputMethod.hide()
+				endEditMode()
 			} else if (state === "add") {
 				// edit was canceled - so remove the dive from the dive list
 				manager.addDiveAborted(dive_id)
@@ -66,6 +64,12 @@ MobileComponents.Page {
 		diveDetailsListView.positionViewAtIndex(index, ListView.Beginning);
 	}
 
+	function endEditMode() {
+		// just cancel the edit state
+		state = "view";
+		Qt.inputMethod.hide();
+	}
+
 	function startEditMode() {
 		// set things up for editing - so make sure that the detailsEdit has
 		// all the right data (using the property aliases set up above)
diff --git a/qt-mobile/qml/TopBar.qml b/qt-mobile/qml/TopBar.qml
index 4f3f6fe..338b78f 100644
--- a/qt-mobile/qml/TopBar.qml
+++ b/qt-mobile/qml/TopBar.qml
@@ -138,7 +138,7 @@ Rectangle {
 				height: parent.height
 				width: parent.width
 				onClicked: {
-					endEditMode()
+					detailsWindow.endEditMode()
 				}
 			}
 		}
diff --git a/qt-mobile/qml/main.qml b/qt-mobile/qml/main.qml
index fae6422..6af5a36 100644
--- a/qt-mobile/qml/main.qml
+++ b/qt-mobile/qml/main.qml
@@ -20,11 +20,6 @@ MobileComponents.ApplicationWindow {
 	visible: false
 	opacity: 0
 
-	function endEditMode() {
-		detailsWindow.state = "view"
-		// somehow also should deal with the icon for the Action Button
-	}
-
 	globalDrawer: MobileComponents.GlobalDrawer {
 		title: "Subsurface"
 		titleIcon: "qrc:/qml/subsurface-mobile-icon.png"
@@ -37,21 +32,21 @@ MobileComponents.ApplicationWindow {
 					for (var i=stackView.depth; i>1; i--) {
 						stackView.pop()
 					}
-					endEditMode()
+					detailsWindow.endEditMode()
 				}
 			},
 			Action {
 				text: "Cloud credentials"
 				onTriggered: {
 					stackView.push(cloudCredWindow)
-					endEditMode()
+					detailsWindow.endEditMode()
 				}
 			},
 			Action {
 				text: "Preferences"
 				onTriggered: {
 					stackView.push(prefsWindow)
-					endEditMode()
+					detailsWindow.endEditMode()
 				}
 			},
 			MobileComponents.ActionGroup {
@@ -61,7 +56,7 @@ MobileComponents.ApplicationWindow {
 				Action {
 					text: "Download from computer"
 					onTriggered: {
-						endEditMode()
+						detailsWindow.endEditMode()
 						stackView.push(downloadDivesWindow)
 					}
 				}
@@ -89,14 +84,14 @@ MobileComponents.ApplicationWindow {
 				Action {
 					text: "Refresh"
 					onTriggered: {
-						endEditMode()
+						detailsWindow.endEditMode()
 						manager.loadDives();
 					}
 				}
 				Action {
 					text: "Upload to cloud"
 					onTriggered: {
-						endEditMode()
+						detailsWindow.endEditMode()
 						manager.saveChanges();
 					}
 				}
-- 
2.7.0



More information about the subsurface mailing list