diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2016-04-14 06:01:36 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-04-14 09:43:33 -0700 |
commit | 6e6cce770b671cea58251475546c77c5bc1468be (patch) | |
tree | cff3bd7b738bc9e08a0325d8d65bf7b08e4c502d /mobile-widgets/qml/DiveDetails.qml | |
parent | 5909e438c9394f7e831d7d9f912788ade87b6b1f (diff) | |
download | subsurface-6e6cce770b671cea58251475546c77c5bc1468be.tar.gz |
QML UI: keep QML manager and the UI in sync about selected dive
The manager can now directly update the index of the selected dive, and
the UI tells the manager the timestamp of the currently selected dive.
This allows the manager to pick the best possible dive as selected dive
if things change (for example if the dive list gets reloaded because it
changed in cloud storage).
Fixes #1009
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets/qml/DiveDetails.qml')
-rw-r--r-- | mobile-widgets/qml/DiveDetails.qml | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/mobile-widgets/qml/DiveDetails.qml b/mobile-widgets/qml/DiveDetails.qml index d562e0a98..262f2042c 100644 --- a/mobile-widgets/qml/DiveDetails.qml +++ b/mobile-widgets/qml/DiveDetails.qml @@ -9,6 +9,7 @@ import org.kde.kirigami 1.0 as Kirigami Kirigami.Page { id: diveDetailsPage property alias currentIndex: diveDetailsListView.currentIndex + property alias currentItem: diveDetailsListView.currentItem property alias dive_id: detailsEdit.dive_id property alias number: detailsEdit.number property alias date: detailsEdit.dateText @@ -25,6 +26,7 @@ Kirigami.Page { property alias startpressure: detailsEdit.startpressureText property alias endpressure: detailsEdit.endpressureText property alias gasmix: detailsEdit.gasmixText + property int updateCurrentIdx: manager.updateSelectedDive title: diveDetailsListView.currentItem ? diveDetailsListView.currentItem.modelData.dive.location : "Dive details" state: "view" @@ -108,6 +110,17 @@ Kirigami.Page { // if we were in view mode, don't accept the event and pop the page } + onUpdateCurrentIdxChanged: { + if (diveDetailsListView.currentIndex != updateCurrentIdx) { + diveDetailsListView.currentIndex = updateCurrentIdx + manager.selectedDiveTimestamp = diveDetailsListView.currentItem.modelData.dive.timestamp + } + } + + onCurrentItemChanged: { + manager.selectedDiveTimestamp = diveDetailsListView.currentItem.modelData.dive.timestamp + } + function showDiveIndex(index) { currentIndex = index; diveDetailsListView.positionViewAtIndex(index, ListView.Beginning); |