aboutsummaryrefslogtreecommitdiffstats
path: root/mobile-widgets/qml
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2018-03-08 21:53:00 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-03-11 11:40:12 -0700
commit27ad58aa78a336dbc221563dbcf876c4872abe07 (patch)
treeaf6d017de02bb471a0c10e0997e4a61ad86fb4f8 /mobile-widgets/qml
parent8b43633c7d22a31f882919f535a8fc332f61af62 (diff)
downloadsubsurface-27ad58aa78a336dbc221563dbcf876c4872abe07.tar.gz
mappage.qml: add a Kirigami page for the map widget
The Page object has the following functionality: - reloadMap(): reload all map markers. - centerOnDiveSiteUUID(): center the map on a dive site uuid. - centerOnLocation(): the map on a latitude, longitude in decimal. - Select a dive list entry based on a marker selected on the map via diveList.setCurrentDiveListIndex() Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'mobile-widgets/qml')
-rw-r--r--mobile-widgets/qml/MapPage.qml49
1 files changed, 49 insertions, 0 deletions
diff --git a/mobile-widgets/qml/MapPage.qml b/mobile-widgets/qml/MapPage.qml
new file mode 100644
index 000000000..ee1e99dc2
--- /dev/null
+++ b/mobile-widgets/qml/MapPage.qml
@@ -0,0 +1,49 @@
+// SPDX-License-Identifier: GPL-2.0
+import QtQuick 2.6
+import QtPositioning 5.3
+import org.subsurfacedivelog.mobile 1.0
+import org.kde.kirigami 2.2 as Kirigami
+
+Kirigami.Page {
+ id: mapPage
+ objectName: "MapPage"
+ title: qsTr("Map")
+ leftPadding: 0
+ topPadding: 0
+ rightPadding: 0
+ bottomPadding: 0
+
+ MapWidget {
+ id: mapWidget
+ anchors.fill: parent
+ onSelectedDivesChanged: {
+ if (list.length === 0) {
+ console.warn("main.qml: onSelectedDivesChanged(): received empty list!")
+ return
+ }
+ var id = list[0] // only single dive selection is supported
+ var idx = diveModel.getIdxForId(id)
+ if (idx === -1) {
+ console.warn("main.qml: onSelectedDivesChanged(): cannot find list index for dive id:", id)
+ return
+ }
+ diveList.setCurrentDiveListIndex(idx, true)
+ }
+ }
+
+ function reloadMap() {
+ mapWidget.mapHelper.reloadMapLocations()
+ }
+
+ function centerOnDiveSiteUUID(uuid) {
+ if (!uuid) {
+ console.warn("main.qml: centerOnDiveSiteUUI(): uuid is undefined!")
+ return
+ }
+ mapWidget.mapHelper.centerOnDiveSiteUUID(uuid)
+ }
+
+ function centerOnLocation(lat, lon) {
+ mapWidget.map.centerOnCoordinate(QtPositioning.coordinate(lat, lon))
+ }
+}