From a4ec5206017b668842d2b9b317300b94dcb43057 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 5 Feb 2016 22:54:47 -0800 Subject: QML UI: enable editing of weight But only if there is only one weight system defined in the dive. Otherwise display a read only text that explains that this cannot be edited. Signed-off-by: Dirk Hohndel --- qt-mobile/qml/DiveDetails.qml | 9 ++++++++- qt-mobile/qml/DiveDetailsEdit.qml | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) (limited to 'qt-mobile/qml') diff --git a/qt-mobile/qml/DiveDetails.qml b/qt-mobile/qml/DiveDetails.qml index aab113eef..ef51a71b2 100644 --- a/qt-mobile/qml/DiveDetails.qml +++ b/qt-mobile/qml/DiveDetails.qml @@ -70,7 +70,14 @@ MobileComponents.Page { buddy = diveDetailsListView.currentItem.modelData.dive.buddy divemaster = diveDetailsListView.currentItem.modelData.dive.divemaster notes = diveDetailsListView.currentItem.modelData.dive.notes - weight = diveDetailsListView.currentItem.modelData.dive.sumWeight + 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" } } diff --git a/qt-mobile/qml/DiveDetailsEdit.qml b/qt-mobile/qml/DiveDetailsEdit.qml index 3acf8ba98..90ca304e5 100644 --- a/qt-mobile/qml/DiveDetailsEdit.qml +++ b/qt-mobile/qml/DiveDetailsEdit.qml @@ -139,6 +139,7 @@ Item { } TextField { id: txtWeight + readOnly: (text == "cannot edit multiple weight systems" ? true : false) Layout.fillWidth: true } @@ -167,7 +168,7 @@ Item { // apply the changes to the dive_table manager.commitChanges(dive_id, detailsEdit.dateText, detailsEdit.locationText, detailsEdit.gpsText, detailsEdit.durationText, detailsEdit.depthText, detailsEdit.airtempText, detailsEdit.watertempText, detailsEdit.suitText, - detailsEdit.buddyText, detailsEdit.divemasterText, detailsEdit.notesText) + detailsEdit.buddyText, detailsEdit.divemasterText, detailsEdit.weightText, detailsEdit.notesText) // apply the changes to the dive detail view - since the edit could have changed the order // first make sure that we are looking at the correct dive - our model allows us to look // up the index based on the unique dive_id -- cgit v1.2.3-70-g09d2