summaryrefslogtreecommitdiffstats
path: root/mobile-widgets/qml
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2018-03-08 21:49:24 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-03-11 11:40:12 -0700
commitd3607e0b77d4128507ea3aed8e9d7a7c0a1cd367 (patch)
tree44be3330b62b0c28133aaf87fa6518049e903b05 /mobile-widgets/qml
parentfbbb6ba4fb748eace8d8f8674ec799813012cf0f (diff)
downloadsubsurface-d3607e0b77d4128507ea3aed8e9d7a7c0a1cd367.tar.gz
divelist.qml: add the setCurrentDiveListIndex() helper
Add the setCurrentDiveListIndex() wrapper for: diveListView.currentIndex = idx wich also makes it possible to disable the scroll animation when selecting dive list indexes which are too far apart. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'mobile-widgets/qml')
-rw-r--r--mobile-widgets/qml/DiveList.qml12
1 files changed, 12 insertions, 0 deletions
diff --git a/mobile-widgets/qml/DiveList.qml b/mobile-widgets/qml/DiveList.qml
index b724bdf3c..dbadda062 100644
--- a/mobile-widgets/qml/DiveList.qml
+++ b/mobile-widgets/qml/DiveList.qml
@@ -364,4 +364,16 @@ Kirigami.ScrollablePage {
event.accepted = true
}
}
+
+ function setCurrentDiveListIndex(idx, noScroll) {
+ diveListView.currentIndex = idx
+ // updating the index of the ListView triggers a non-linear scroll
+ // animation that can be very slow. the fix is to stop this animation
+ // by setting contentY to itself and then using positionViewAtIndex().
+ // the downside is that the view jumps to the index immediately.
+ if (noScroll) {
+ diveListView.contentY = diveListView.contentY
+ diveListView.positionViewAtIndex(idx, ListView.Center)
+ }
+ }
}