diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2019-10-07 16:23:28 -0500 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-10-13 11:32:27 -0700 |
commit | b07a1cc8b61d1e3d2beb3180dffe6fef621f7e55 (patch) | |
tree | 184915e4bed47f54e2766e2621846c694856115f /mobile-widgets/qml/DiveList.qml | |
parent | d8cc8732bdaa8782a24a7e6dd53a393fea957f30 (diff) | |
download | subsurface-b07a1cc8b61d1e3d2beb3180dffe6fef621f7e55.tar.gz |
Mobile: when switching to the details, reuse existing page
While pageStack.push() can handle pushing a page that's already there,
that creates an unfortunate sequence of currentItemChanged signal which
leads us to do the wrong thing with our map hack.
This commit changes things around to first look for the page in the page
stack and just switch to it, and only pushing the page as new if it
cannoot be found oon the page stack.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'mobile-widgets/qml/DiveList.qml')
-rw-r--r-- | mobile-widgets/qml/DiveList.qml | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/mobile-widgets/qml/DiveList.qml b/mobile-widgets/qml/DiveList.qml index b2c99a02b..e6b557efe 100644 --- a/mobile-widgets/qml/DiveList.qml +++ b/mobile-widgets/qml/DiveList.qml @@ -36,6 +36,14 @@ Kirigami.ScrollablePage { } } + function pageIndex(pageToFind) { + for (var i = 0; i < pageStack.contentItem.contentChildren.length; i++) { + if (pageStack.contentItem.contentChildren[i] === pageToFind) + return i + } + return -1 + } + Component { id: diveDelegate Kirigami.AbstractListItem { @@ -112,7 +120,12 @@ Kirigami.ScrollablePage { if (detailsWindow.state === "view") { diveListView.currentIndex = index detailsWindow.showDiveIndex(index); - pageStack.push(detailsWindow); + // switch to detailsWindow (or push it if it's not in the stack) + var i = pageIndex(detailsWindow) + if (i === -1) + pageStack.push(detailsWindow) + else + pageStack.currentIndex = i } } |