aboutsummaryrefslogtreecommitdiffstats
path: root/mobile-widgets/qml
diff options
context:
space:
mode:
authorGravatar Jan Mulder <jlmulder@xs4all.nl>2018-01-28 09:52:51 +0100
committerGravatar Jan Mulder <jlmulder@xs4all.nl>2018-01-31 14:48:14 +0100
commitfed2c5b6a1c71649bcb310c0bd118cb1abcf9ea0 (patch)
tree78bd219027237280e3eafb33005583b755079557 /mobile-widgets/qml
parent728e007c5c3eff08cd3dc213ebc3034a9513d4c9 (diff)
downloadsubsurface-fed2c5b6a1c71649bcb310c0bd118cb1abcf9ea0.tar.gz
mobile cleanup: unduplicate code and do not loop over dives (1)
This is the first of a set of commits that are (very) similar. It appeared that a number of more or less static lists, which are constructed by a loop over all dives in the logbook, were executed when changing focus to a next dive. For example, the in this commit addressed list of used dive suits. What was wrong was that the suitList was linked to a dive. There is only a need to construct the list of used suits when data is changed (and obviously, once on startup of the app). Further, it appeared that a lot of code was duplicated and that we can use (in this case) the same code from the desktop completionmodels.cpp. Basically, this commit involves the following changes: - include completionmodels.cpp in mobile and desktop (so move it from the desktop only category to the generic category). - remove double code from DiveObjectHelper.cpp - Do not differentiate in the init phase and the normal refresh of the list - the per dive logic is now only the getting of a previously constructed list (in init or update of the divelist). There are no visible changes in the UI, other than a better performance when scrolling over dive details. Signed-off-by: Jan Mulder <jlmulder@xs4all.nl>
Diffstat (limited to 'mobile-widgets/qml')
-rw-r--r--mobile-widgets/qml/DiveDetails.qml3
-rw-r--r--mobile-widgets/qml/DiveDetailsEdit.qml3
-rw-r--r--mobile-widgets/qml/main.qml2
3 files changed, 3 insertions, 5 deletions
diff --git a/mobile-widgets/qml/DiveDetails.qml b/mobile-widgets/qml/DiveDetails.qml
index 1db5efc36..a285e62e4 100644
--- a/mobile-widgets/qml/DiveDetails.qml
+++ b/mobile-widgets/qml/DiveDetails.qml
@@ -30,7 +30,6 @@ Kirigami.Page {
property alias notes: detailsEdit.notesText
property alias suitIndex: detailsEdit.suitIndex
property alias suitText: detailsEdit.suitText
- property alias suitModel: detailsEdit.suitModel
property alias weight: detailsEdit.weightText
property alias startpressure: detailsEdit.startpressureText
property alias endpressure: detailsEdit.endpressureText
@@ -237,7 +236,7 @@ Kirigami.Page {
depth = currentItem.modelData.dive.depth
airtemp = currentItem.modelData.dive.airTemp
watertemp = currentItem.modelData.dive.waterTemp
- suitIndex = currentItem.modelData.dive.suitList.indexOf(currentItem.modelData.dive.suit)
+ suitIndex = manager.suitList.indexOf(currentItem.modelData.dive.suit)
if (currentItem.modelData.dive.buddy.indexOf(",") > 0) {
buddyText = currentItem.modelData.dive.buddy;
} else {
diff --git a/mobile-widgets/qml/DiveDetailsEdit.qml b/mobile-widgets/qml/DiveDetailsEdit.qml
index e680e1734..5808f78a7 100644
--- a/mobile-widgets/qml/DiveDetailsEdit.qml
+++ b/mobile-widgets/qml/DiveDetailsEdit.qml
@@ -224,8 +224,7 @@ Item {
}
HintsTextEdit {
id: suitBox
- model: diveDetailsListView.currentItem && diveDetailsListView.currentItem.modelData !== null ?
- diveDetailsListView.currentItem.modelData.dive.suitList : null
+ model: manager.suitList
inputMethodHints: Qt.ImhNoPredictiveText
Layout.fillWidth: true
}
diff --git a/mobile-widgets/qml/main.qml b/mobile-widgets/qml/main.qml
index da7089d4f..2df8d9f67 100644
--- a/mobile-widgets/qml/main.qml
+++ b/mobile-widgets/qml/main.qml
@@ -92,7 +92,7 @@ Kirigami.ApplicationWindow {
detailsWindow.location = ""
detailsWindow.gps = ""
detailsWindow.duration = ""
- detailsWindow.suitModel = manager.suitInit
+ detailsWindow.suitModel = manager.suitList
detailsWindow.suitIndex = -1
detailsWindow.suitText = ""
detailsWindow.cylinderModel = manager.cylinderInit