From 65fe892cba622ef2b9a5f7ec70e78eb98909f90c Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Sun, 12 Jan 2020 22:42:57 -0800 Subject: mobile UI: set the correct location string when editing dives In some situations we ended up with the wrong location name. One way to reproduce the problem was to edit an existing dive location to be a substring of an existing location name. Save the dive, then immediately edit it again. The wrong location would be filled in. The code here looks strange and unnecessary, but it seems to fix the issue. The aliases don't seem to make the code any easier to understand. This replaces them in the case of the location combo box with direct accesses to the data on the DiveDetailsEdit page. It may be worth removing all of them. The locationModel alias was unused. Signed-off-by: Dirk Hohndel --- mobile-widgets/qml/DiveDetails.qml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'mobile-widgets') diff --git a/mobile-widgets/qml/DiveDetails.qml b/mobile-widgets/qml/DiveDetails.qml index 2a20271ef..46e9952a2 100644 --- a/mobile-widgets/qml/DiveDetails.qml +++ b/mobile-widgets/qml/DiveDetails.qml @@ -25,8 +25,6 @@ Kirigami.Page { property alias depth: detailsEdit.depthText property alias duration: detailsEdit.durationText property alias location: detailsEdit.locationText - property alias locationModel: detailsEdit.locationModel - property alias locationIndex: detailsEdit.locationIndex property alias gps: detailsEdit.gpsText property alias notes: detailsEdit.notesText property alias suitIndex: detailsEdit.suitIndex @@ -251,8 +249,14 @@ Kirigami.Page { dive_id = modelData.id number = modelData.number date = modelData.dateTime - location = modelData.location !== undefined ? location : "" - locationIndex = manager.locationList.indexOf(modelData.location) + var locationText = modelData.location !== undefined ? modelData.location : "" + var locationIndex = manager.locationList.indexOf(modelData.location) + if (locationIndex >= 0) { + detailsEdit.locationIndex = locationIndex + detailsEdit.locationText = manager.locationList[locationIndex] // this shouldn't be necessary, but apparently it is + } else { + detailsEdit.locationText = locationText + } gps = modelData.gps gpsCheckbox = false duration = modelData.duration -- cgit v1.2.3-70-g09d2