From d9763100940cbcff297d88a0f1597ba7bd07ea01 Mon Sep 17 00:00:00 2001 From: Henrik Brautaset Aronsen Date: Sun, 7 Feb 2016 22:23:06 +0100 Subject: Add top-right edit and back buttons for mobile Adds a back button in edit mode, and an edit button for view mode. Signed-off-by: Henrik Brautaset Aronsen Signed-off-by: Dirk Hohndel --- qt-mobile/qml/DiveDetails.qml | 51 ++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 23 deletions(-) (limited to 'qt-mobile/qml/DiveDetails.qml') diff --git a/qt-mobile/qml/DiveDetails.qml b/qt-mobile/qml/DiveDetails.qml index ef51a71b2..b2744ec1e 100644 --- a/qt-mobile/qml/DiveDetails.qml +++ b/qt-mobile/qml/DiveDetails.qml @@ -56,29 +56,7 @@ MobileComponents.Page { state = "view" Qt.inputMethod.hide() } else { - // set things up for editing - so make sure that the detailsEdit has - // all the right data (using the property aliases set up above) - dive_id = diveDetailsListView.currentItem.modelData.dive.id - number = diveDetailsListView.currentItem.modelData.dive.number - date = diveDetailsListView.currentItem.modelData.dive.date + " " + diveDetailsListView.currentItem.modelData.dive.time - location = diveDetailsListView.currentItem.modelData.dive.location - duration = diveDetailsListView.currentItem.modelData.dive.duration - depth = diveDetailsListView.currentItem.modelData.dive.depth - airtemp = diveDetailsListView.currentItem.modelData.dive.airTemp - watertemp = diveDetailsListView.currentItem.modelData.dive.waterTemp - suit = diveDetailsListView.currentItem.modelData.dive.suit - buddy = diveDetailsListView.currentItem.modelData.dive.buddy - divemaster = diveDetailsListView.currentItem.modelData.dive.divemaster - notes = diveDetailsListView.currentItem.modelData.dive.notes - if (diveDetailsListView.currentItem.modelData.dive.singleWeight) { - // we have only one weight, go ahead, have fun and edit it - weight = diveDetailsListView.currentItem.modelData.dive.sumWeight - } else { - // careful when translating, this text is "magic" in DiveDetailsEdit.qml - weight = "cannot edit multiple weight systems" - } - - diveDetailsPage.state = "edit" + startEditMode() } } } @@ -87,6 +65,33 @@ MobileComponents.Page { currentIndex = index; diveDetailsListView.positionViewAtIndex(index, ListView.Beginning); } + + 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) + dive_id = diveDetailsListView.currentItem.modelData.dive.id + number = diveDetailsListView.currentItem.modelData.dive.number + date = diveDetailsListView.currentItem.modelData.dive.date + " " + diveDetailsListView.currentItem.modelData.dive.time + location = diveDetailsListView.currentItem.modelData.dive.location + duration = diveDetailsListView.currentItem.modelData.dive.duration + depth = diveDetailsListView.currentItem.modelData.dive.depth + airtemp = diveDetailsListView.currentItem.modelData.dive.airTemp + watertemp = diveDetailsListView.currentItem.modelData.dive.waterTemp + suit = diveDetailsListView.currentItem.modelData.dive.suit + buddy = diveDetailsListView.currentItem.modelData.dive.buddy + divemaster = diveDetailsListView.currentItem.modelData.dive.divemaster + notes = diveDetailsListView.currentItem.modelData.dive.notes + if (diveDetailsListView.currentItem.modelData.dive.singleWeight) { + // we have only one weight, go ahead, have fun and edit it + weight = diveDetailsListView.currentItem.modelData.dive.sumWeight + } else { + // careful when translating, this text is "magic" in DiveDetailsEdit.qml + weight = "cannot edit multiple weight systems" + } + + diveDetailsPage.state = "edit" + } + onWidthChanged: diveDetailsListView.positionViewAtIndex(diveDetailsListView.currentIndex, ListView.Beginning); ScrollView { -- cgit v1.2.3-70-g09d2