From b07a1cc8b61d1e3d2beb3180dffe6fef621f7e55 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 7 Oct 2019 16:23:28 -0500 Subject: 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 --- mobile-widgets/qml/DiveList.qml | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'mobile-widgets/qml') 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 } } -- cgit v1.2.3-70-g09d2