From 2f0689d3b82f4e3db4e456b26e3dba299cfa18e4 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 7 Oct 2019 22:33:44 -0500 Subject: Mobile: move pageIndex function to main.qml This way it can be more easily called from other pages. Signed-off-by: Dirk Hohndel --- mobile-widgets/qml/DiveList.qml | 10 +--------- mobile-widgets/qml/main.qml | 8 ++++++++ 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'mobile-widgets/qml') diff --git a/mobile-widgets/qml/DiveList.qml b/mobile-widgets/qml/DiveList.qml index de06fb14e..18b51d70e 100644 --- a/mobile-widgets/qml/DiveList.qml +++ b/mobile-widgets/qml/DiveList.qml @@ -36,14 +36,6 @@ 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 { @@ -124,7 +116,7 @@ Kirigami.ScrollablePage { diveListView.currentIndex = index detailsWindow.showDiveIndex(index); // switch to detailsWindow (or push it if it's not in the stack) - var i = pageIndex(detailsWindow) + var i = rootItem.pageIndex(detailsWindow) if (i === -1) pageStack.push(detailsWindow) else diff --git a/mobile-widgets/qml/main.qml b/mobile-widgets/qml/main.qml index 94223c766..80dc329fe 100644 --- a/mobile-widgets/qml/main.qml +++ b/mobile-widgets/qml/main.qml @@ -90,6 +90,14 @@ Kirigami.ApplicationWindow { pageStack.push(mapPage) } + function pageIndex(pageToFind) { + for (var i = 0; i < pageStack.contentItem.contentChildren.length; i++) { + if (pageStack.contentItem.contentChildren[i] === pageToFind) + return i + } + return -1 + } + function startAddDive() { detailsWindow.state = "add" detailsWindow.dive_id = manager.addDive(); -- cgit v1.2.3-70-g09d2