main.qml: handle mapPage in pageStack.onCurrentItemChanged()

When the slot pageStack.onCurrentItemChanged() is reached
make sure that the stackView becomes non-interactive.
This prevents swiping left on the map to "go back".

Also, always reload the map markers when the map becomes visible.
This is not optimal and instead something in the lines of:
  DiveList.model.onChanged()
is a much better solution.

Ideally the map reload should happen on dive removal, dive addition,
dive edits and sync from cloud.

Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
Lubomir I. Ivanov 2018-03-08 22:28:42 +02:00 committed by Dirk Hohndel
parent fe9c3d4c95
commit 49f566d6d8

View file

@ -476,6 +476,14 @@ if you have network connectivity and want to sync your data to cloud storage."),
pageStack.onCurrentItemChanged: {
// This is called whenever the user navigates using the breadcrumbs in the header
// disable the left swipe to go back when on the map page
stackView.interactive = pageStack.currentItem.objectName !== mapPage.objectName
// is there a better way to reload the map markers instead of doing that
// every time the map page is shown - e.g. link to the dive list model somehow?
if (pageStack.currentItem.objectName === mapPage.objectName)
mapPage.reloadMap()
// In case we land on any page, not being the DiveDetails (which can be
// in multiple states, such as add, edit or view), just end the edit/add mode
if (pageStack.currentItem.objectName !== "DiveDetails" &&