mobile/divelist: implement model that shows all dives in trip-order

MobileSwipeModel is probably not an ideal name, but all I could come up with.

One of the main complications here is that our list is reversed with respect to
the source model. We should change that one day.  Probably by moving the
sorting down to the core-model.

Since looking up the source row is somewhat expensive, the lookup is cached for
a single entry because accesses come in bursts for a single dive. This should
be a good compromise and avoids keeping track of a full row-to-dive array.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Berthold Stoeger 2020-03-06 12:48:47 +01:00 committed by Dirk Hohndel
parent 71b378aa82
commit c34b7857fc
4 changed files with 449 additions and 5 deletions

View file

@ -230,7 +230,7 @@ Kirigami.Page {
}
function showDiveIndex(id) {
currentIndex = diveModel.getIdxForId(id);
currentIndex = swipeModel.getIdxForId(id);
diveDetailsListView.positionViewAtIndex(currentIndex, ListView.End);
}
@ -307,7 +307,7 @@ Kirigami.Page {
ListView {
id: diveDetailsListView
anchors.fill: parent
model: diveModel
model: swipeModel
currentIndex: -1
boundsBehavior: Flickable.StopAtBounds
maximumFlickVelocity: parent.width * 5
@ -335,7 +335,7 @@ Kirigami.Page {
}
ScrollIndicator.horizontal: ScrollIndicator { }
Connections {
target: diveModel
target: swipeModel
onCurrentDiveChanged: {
currentIndex = index.row
diveDetailsListView.positionViewAtIndex(currentIndex, ListView.End)