diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2019-10-19 22:12:50 -0400 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-10-20 16:08:55 -0400 |
commit | 613a3112d27e2d40c3a4eeb7fb061f4739279157 (patch) | |
tree | 1cf0ba01a5c9af758897b7d5919e21822c2dfe94 /mobile-widgets/qml/DiveDetails.qml | |
parent | 09c7115e2192c30ee86007b1dcdec04134813751 (diff) | |
download | subsurface-613a3112d27e2d40c3a4eeb7fb061f4739279157.tar.gz |
Mobile: get dive details directly from the model
By getting a DiveObjectHelper and then dereferencing that we ended up
creating hundres and hundreds of these objects, only to immediately
destroy them after using a tiny part of the data.
Instead make those data available directly from the model, without
having to create a DiveObjectHelper forst.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets/qml/DiveDetails.qml')
-rw-r--r-- | mobile-widgets/qml/DiveDetails.qml | 61 |
1 files changed, 31 insertions, 30 deletions
diff --git a/mobile-widgets/qml/DiveDetails.qml b/mobile-widgets/qml/DiveDetails.qml index d766970ff..4d9f7fc63 100644 --- a/mobile-widgets/qml/DiveDetails.qml +++ b/mobile-widgets/qml/DiveDetails.qml @@ -52,7 +52,7 @@ Kirigami.Page { property alias cylinderModel3: detailsEdit.cylinderModel3 property alias cylinderModel4: detailsEdit.cylinderModel4 - title: currentItem && currentItem.modelData ? currentItem.modelData.dive.location : qsTr("Dive details") + title: currentItem && currentItem.modelData ? currentItem.modelData.location : qsTr("Dive details") state: "view" leftPadding: 0 topPadding: Kirigami.Units.gridUnit / 2 @@ -68,7 +68,7 @@ Kirigami.Page { target: diveDetailsPage; actions { right: deleteAction - left: currentItem ? (currentItem.modelData && currentItem.modelData.dive.gps !== "" ? mapAction : null) : null + left: currentItem ? (currentItem.modelData && currentItem.modelData.gps !== "" ? mapAction : null) : null } } }, @@ -153,7 +153,7 @@ Kirigami.Page { name: ":/icons/trash-empty.svg" } onTriggered: { - var deletedId = currentItem.modelData.dive.id + var deletedId = currentItem.modelData.id var deletedIndex = diveDetailsListView.currentIndex manager.deleteDive(deletedId) pageStack.pop() @@ -181,7 +181,7 @@ Kirigami.Page { } onTriggered: { showMap() - mapPage.centerOnDiveSite(currentItem.modelData.dive.dive_site) + mapPage.centerOnDiveSite(currentItem.modelData.diveSite) } } @@ -218,11 +218,11 @@ Kirigami.Page { // why do we do this? What consumes this? manager.selectedDiveTimestamp = currentItem.modelData.dive.timestamp // make sure the core data structures reflect that this dive is selected - manager.selectDive(currentItem.modelData.dive.id) + manager.selectDive(currentItem.modelData.id) // update the map to show the highlighted flag and center on it if (rootItem.pageIndex(mapPage) !== -1) { mapPage.reloadMap() - mapPage.centerOnDiveSite(currentItem.modelData.dive.dive_site) + mapPage.centerOnDiveSite(currentItem.modelData.diveSite) } } @@ -251,34 +251,35 @@ Kirigami.Page { // set things up for editing - so make sure that the detailsEdit has // all the right data (using the property aliases set up above) var dive = currentItem.modelData.dive - dive_id = dive.id - number = dive.number - date = dive.date + " " + dive.time - location = dive.location - locationIndex = manager.locationList.indexOf(dive.location) - gps = dive.gps + var modelData = currentItem.modelData + dive_id = modelData.id + number = modelData.number + date = modelData.dateTime + location = modelData.location + locationIndex = manager.locationList.indexOf(modelData.location) + gps = modelData.gps gpsCheckbox = false - duration = dive.duration - depth = dive.depth - airtemp = dive.airTemp - watertemp = dive.waterTemp - suitIndex = manager.suitList.indexOf(dive.suit) - if (dive.buddy.indexOf(",") > 0) { - buddyIndex = manager.buddyList.indexOf(dive.buddy.split(",", 1).toString()) + duration = modelData.duration + depth = modelData.depth + airtemp = modelData.airTemp + watertemp = modelData.waterTemp + suitIndex = manager.suitList.indexOf(modelData.suit) + if (modelData.buddy.indexOf(",") > 0) { + buddyIndex = manager.buddyList.indexOf(modelData.buddy.split(",", 1).toString()) } else { - buddyIndex = manager.buddyList.indexOf(dive.buddy) + buddyIndex = manager.buddyList.indexOf(modelData.buddy) } - buddyText = dive.buddy; - if (dive.divemaster.indexOf(",") > 0) { - divemasterIndex = manager.divemasterList.indexOf(dive.divemaster.split(",", 1).toString()) + buddyText = modelData.buddy; + if (modelData.diveMaster.indexOf(",") > 0) { + divemasterIndex = manager.divemasterList.indexOf(modelData.diveMaster.split(",", 1).toString()) } else { - divemasterIndex = manager.divemasterList.indexOf(dive.divemaster) + divemasterIndex = manager.divemasterList.indexOf(modelData.diveMaster) } - divemasterText = dive.divemaster - notes = dive.notes - if (dive.singleWeight) { + divemasterText = modelData.diveMaster + notes = modelData.notes + if (modelData.singleWeight) { // we have only one weight, go ahead, have fun and edit it - weight = dive.sumWeight + weight = modelData.sumWeight } else { // careful when translating, this text is "magic" in DiveDetailsEdit.qml weight = "cannot edit multiple weight systems" @@ -292,8 +293,8 @@ Kirigami.Page { cylinderIndex2 = dive.cylinderList.indexOf(usedCyl[2]) cylinderIndex3 = dive.cylinderList.indexOf(usedCyl[3]) cylinderIndex4 = dive.cylinderList.indexOf(usedCyl[4]) - rating = dive.rating - visibility = dive.visibility + rating = modelData.rating + visibility = modelData.viz diveDetailsPage.state = "edit" } |