From f19e10209cc334640d14dce67ee9c0da8e3485bc Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Wed, 1 Sep 2021 14:35:48 -0700 Subject: mobile: fix broken cylinder name tracking in dive edit Prior to this change, we had two different cylinder lists as models for drop down boxes - one that prepends the "no default cylinder" entry (which we need for setting up no default cylinder to be used in the app), and another one that only includes actual cylinders. The problem occured if a dive is created before the first time we edit an existing dive: in this case we are applying indices across the two models, but the indices are of course off by one; this results in actually picking the wrong cylinder. So each time we try to edit a dive, we end up with the previous cylinder in the list. This commit simplifies the code by having only one place where we create list of cylinder names (which is then used as the model for the combo box). It also uses more logical names for the two 'flavors' of this list to make it clear which one is supposed to be used (the regular list when editing or adding dives, the one with the "no default cylinder" entry prependet for the Settings page). Reported-by: Brian Fransen Signed-off-by: Dirk Hohndel --- mobile-widgets/qml/main.qml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'mobile-widgets/qml') diff --git a/mobile-widgets/qml/main.qml b/mobile-widgets/qml/main.qml index f16e85808..ea26e3afd 100644 --- a/mobile-widgets/qml/main.qml +++ b/mobile-widgets/qml/main.qml @@ -168,11 +168,11 @@ Kirigami.ApplicationWindow { detailsWindow.suitModel = manager.suitList detailsWindow.suitIndex = -1 detailsWindow.suitText = "" - detailsWindow.cylinderModel0 = manager.cylinderInit - detailsWindow.cylinderModel1 = manager.cylinderInit - detailsWindow.cylinderModel2 = manager.cylinderInit - detailsWindow.cylinderModel3 = manager.cylinderInit - detailsWindow.cylinderModel4 = manager.cylinderInit + detailsWindow.cylinderModel0 = manager.cylinderListInit + detailsWindow.cylinderModel1 = manager.cylinderListInit + detailsWindow.cylinderModel2 = manager.cylinderListInit + detailsWindow.cylinderModel3 = manager.cylinderListInit + detailsWindow.cylinderModel4 = manager.cylinderListInit detailsWindow.cylinderIndex0 = PrefEquipment.default_cylinder == "" ? -1 : detailsWindow.cylinderModel0.indexOf(PrefEquipment.default_cylinder) detailsWindow.usedCyl = ["",] detailsWindow.weight = "" @@ -482,7 +482,7 @@ if you have network connectivity and want to sync your data to cloud storage."), text: qsTr("Settings") onTriggered: { globalDrawer.close() - settingsWindow.defaultCylinderModel = manager.cylinderInit + settingsWindow.defaultCylinderModel = manager.defaultCylinderListInit PrefEquipment.default_cylinder === "" ? defaultCylinderIndex = "-1" : defaultCylinderIndex = settingsWindow.defaultCylinderModel.indexOf(PrefEquipment.default_cylinder) showPage(settingsWindow) detailsWindow.endEditMode() -- cgit v1.2.3-70-g09d2