KOSMIndoorMap

IndoorMapPage.qml
1 /*
2  SPDX-FileCopyrightText: 2020 Volker Krause <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 import QtQuick 2.12
8 import QtQuick.Layouts 1.1
9 import QtQuick.Controls 2.1 as QQC2
10 import org.kde.kirigami 2.7 as Kirigami
11 import org.kde.kosmindoormap 1.0
12 
13 Kirigami.Page {
14  title: map.floorLevels.hasName(map.view.floorLevel) ? map.floorLevels.name(map.view.floorLevel) : ("Floor " + map.floorLevels.name(map.view.floorLevel));
15  property point coordinate
16  property alias map: map
17  property alias debug: infoModel.debug
18 
19  topPadding: 0
20  bottomPadding: 0
21  leftPadding: 0
22  rightPadding: 0
23 
24  // prevent swipe to the right changing pages, we want to pan the map instead
25  // TODO in theory we could make this conditional to having panned the map all the way to the right
26  Kirigami.ColumnView.preventStealing: true
27 
28  actions {
29  left: Kirigami.Action {
30  iconName: "go-down-symbolic"
31  enabled: map.floorLevels.hasFloorLevelBelow(map.view.floorLevel)
32  onTriggered: map.view.floorLevel = map.floorLevels.floorLevelBelow(map.view.floorLevel)
33  }
34  right: Kirigami.Action {
35  iconName: "go-up-symbolic"
36  enabled: map.floorLevels.hasFloorLevelAbove(map.view.floorLevel)
37  onTriggered: map.view.floorLevel = map.floorLevels.floorLevelAbove(map.view.floorLevel)
38  }
39  }
40 
41  OSMElementInformationModel {
42  id: infoModel
43  debug: true
44  }
45 
46  IndoorMapInfoSheet {
47  id: elementDetailsSheet
48  model: infoModel
49  mapData: page.map.mapData
50  }
51 
52  FloorLevelChangeModel {
53  id: floorLevelChangeModel
54  currentFloorLevel: map.view.floorLevel
55  floorLevelModel: map.floorLevels
56  }
57 
58  Kirigami.OverlaySheet {
59  id: elevatorSheet
60  header: Kirigami.Heading {
61  text: "Elevator"
62  }
63  ListView {
64  model: floorLevelChangeModel
65  delegate: Kirigami.BasicListItem {
66  highlighted: false
67  text: model.display
68  bold: model.isCurrentFloor
69  onClicked: {
70  elevatorSheet.sheetOpen = false;
71  map.view.floorLevel = model.floorLevel;
72  }
73  }
74  }
75  }
76 
77  IndoorMap {
78  id: map
79  anchors.fill: parent
80 
82  map: map
83  anchors.left: map.left
84  anchors.bottom: map.bottom
85  width: 0.3 * map.width
86  }
87 
89  anchors.right: map.right
90  anchors.bottom: map.bottom
91  }
92 
93  onElementPicked: {
94  floorLevelChangeModel.element = element;
95  if (floorLevelChangeModel.hasSingleLevelChange) {
96  showPassiveNotification("Switched to floor " + floorLevelChangeModel.destinationLevelName, "short");
97  map.view.floorLevel = floorLevelChangeModel.destinationLevel;
98  return;
99  } else if (floorLevelChangeModel.hasMultipleLevelChanges) {
100  elevatorSheet.sheetOpen = true;
101  return;
102  }
103 
104  infoModel.element = element;
105  if (infoModel.name != "" || infoModel.debug) {
106  elementDetailsSheet.sheetOpen = true;
107  }
108  }
109  onElementLongPressed: {
110  // this provides info model access for elements with other interactions
111  infoModel.element = element;
112  if (infoModel.name != "" || infoModel.debug) {
113  elementDetailsSheet.sheetOpen = true;
114  }
115  }
116  }
117 
118  onCoordinateChanged: map.mapLoader.loadForCoordinate(coordinate.y, coordinate.x);
119 }
QTextStream & right(QTextStream &stream)
QTextStream & left(QTextStream &stream)
QML item for displaying a train station or airport map.
Definition: IndoorMap.qml:13
QFuture< void > map(Sequence &sequence, MapFunctor function)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Oct 25 2021 23:04:00 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.