KOSMIndoorMap

indoormap.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 Qt.labs.platform 1.0 as QPlatform
11 import org.kde.kirigami 2.6 as Kirigami
12 import org.kde.kpublictransport 1.0 as PublicTransport
13 import org.kde.kosmindoormap 1.0
14 import org.kde.kosmindoormap.kpublictransport 1.0
15 
16 Kirigami.ApplicationWindow {
17  globalDrawer: Kirigami.GlobalDrawer {
18  title: "Indoor Map"
19  titleIcon: "map-symbolic"
20  isMenu: true
21  actions: [
22  Kirigami.Action {
23  text: "Open O5M File"
24  icon.name: "document-open-symbolic"
25  onTriggered: fileDialog.open()
26  },
27  Kirigami.Action {
28  text: "Open MapCSS Stylesheet"
29  icon.name: "document-open-symbolic"
30  onTriggered: mapcssDialog.open()
31  },
32  Kirigami.Action {
33  text: "Reload Stylesheet"
34  icon.name: "view-refresh-symbolic"
35  onTriggered: {
36  var s = page.map.styleSheet;
37  page.map.styleSheet = "";
38  page.map.styleSheet = s;
39  }
40  },
41  Kirigami.Action { separator: true },
42  Kirigami.Action {
43  text: "Data Sources"
44  icon.name: "help-about-symbolic"
45  onTriggered: function() { applicationWindow().pageStack.push(attributionPage); }
46  },
47  Kirigami.Action {
48  id: aboutAction
49  text: "About"
50  icon.name: "help-about-symbolic"
51  onTriggered: function() { applicationWindow().pageStack.push(aboutPage); }
52  }
53  ]
54  }
55  contextDrawer: Kirigami.ContextDrawer {
56  id: contextDrawer
57  }
58 
59  QPlatform.FileDialog {
60  id: fileDialog
61  title: "Open OSM File"
62  fileMode: QPlatform.FileDialog.OpenFile
63  nameFilters: ["o5m file (*.o5m)", "OSM XML file (*.osm *.xml)", "PBF file (*.osm.pbf)"]
64  onAccepted: page.map.mapLoader.loadFromFile(fileDialog.file);
65  }
66  QPlatform.FileDialog {
67  id: mapcssDialog
68  title: "Open MapCSS Stylesheet"
69  fileMode: QPlatform.FileDialog.OpenFile
70  nameFilters: ["MapCSS stylesheet (*.mapcss)"]
71  onAccepted: page.map.styleSheet = mapcssDialog.file
72  }
73  PublicTransport.Manager { id: ptMgr }
74 
75  pageStack.initialPage: IndoorMapPage {
76  id: page
77  debug: debugAction.checked
78 
79  actions {
80  main: Kirigami.Action {
81  text: "Select Location"
82  icon.name: "search"
83  onTriggered: locationSheet.sheetOpen = true
84  }
85  contextualActions: [
86  Kirigami.Action {
87  text: "Light Style"
88  onTriggered: page.map.styleSheet = "breeze-light"
89  },
90  Kirigami.Action {
91  text: "Dark Style"
92  onTriggered: page.map.styleSheet = "breeze-dark"
93  },
94  Kirigami.Action {
95  text: "Diagnostic View"
96  onTriggered: page.map.styleSheet = "diagnostic"
97  },
98  Kirigami.Action {
99  id: debugAction
100  text: "Debug Info Model"
101  checkable: true
102  checked: false
103  },
104  Kirigami.Action {
105  id: platformAction
106  text: "Find Platform"
107  onTriggered: platformSheet.sheetOpen = true
108  visible: !platformModel.isEmpty
109  },
110  Kirigami.Action {
111  id: gateAction
112  text: "Find Gate"
113  onTriggered: gateSheet.sheetOpen = true
114  visible: !gateModel.isEmpty
115  }
116  ]
117  }
118 
119  PlatformModel {
120  id: platformModel
121  mapData: page.map.mapData
122  }
123 
124  Component {
125  id: platformDelegate
126  Kirigami.AbstractListItem {
127  property var platform: model
128  Row {
129  QQC2.Label { text: platform.lines.length == 0 ? platform.display : (platform.display + " - "); }
130  Repeater {
131  model: platform.lines
132  delegate: Row {
133  Kirigami.Icon {
134  id: icon
135  height: Kirigami.Units.iconSizes.small
136  width: implicitWidth
137  visible: source != ""
138  source: {
139  switch (platform.mode) {
140  case Platform.Rail:
141  return PublicTransport.LineMetaData.lookup(modelData, platform.coordinate.y, platform.coordinate.x, PublicTransport.Line.Train, true).logo;
142  case Platform.Tram:
143  return PublicTransport.LineMetaData.lookup(modelData, platform.coordinate.y, platform.coordinate.x, PublicTransport.Line.Tramway, true).logo;
144  case Platform.Subway:
145  return PublicTransport.LineMetaData.lookup(modelData, platform.coordinate.y, platform.coordinate.x, PublicTransport.Line.Metro, true).logo;
146  }
147  return "";
148  }
149  }
150  QQC2.Label {
151  text: modelData + " "
152  visible: icon.source == ""
153  }
154  }
155  }
156  }
157  highlighted: false
158  onClicked: {
159  page.map.view.floorLevel = model.level
160  page.map.view.centerOnGeoCoordinate(model.coordinate);
161  page.map.view.setZoomLevel(19, Qt.point(page.map.width / 2.0, page.map.height/ 2.0));
162  platformSheet.sheetOpen = false
163  }
164  }
165  }
166 
167  Kirigami.OverlaySheet {
168  id: platformSheet
169 
170  header: Kirigami.Heading {
171  text: "Find Platform"
172  }
173 
174  ListView {
175  model: platformModel
176 
177  section.property: "mode"
178  section.delegate: Kirigami.Heading {
180  level: 4
181  text: switch(parseInt(section)) {
182  case Platform.Rail: return "Railway";
183  case Platform.Subway: return "Subway";
184  case Platform.Tram: return "Tramway";
185  case Platform.Bus: return "Bus";
186  default: console.log(section, Platform.Rail); return section;
187  }
188  height: implicitHeight + Kirigami.Units.largeSpacing
189  verticalAlignment: Qt.AlignBottom
190  }
191  section.criteria: ViewSection.FullString
192  section.labelPositioning: ViewSection.CurrentLabelAtStart | ViewSection.InlineLabels
193 
194  delegate: platformDelegate
195  }
196  }
197 
198  GateModel {
199  id: gateModel
200  mapData: page.map.mapData
201  }
202 
203  Kirigami.OverlaySheet {
204  id: gateSheet
205 
206  header: Kirigami.Heading {
207  text: "Find Gate"
208  }
209 
210  ListView {
211  model: gateModel
212 
213  delegate: Kirigami.BasicListItem {
214  text: model.display
215  highlighted: false
216  onClicked: {
217  page.map.view.floorLevel = model.level
218  page.map.view.centerOnGeoCoordinate(model.coordinate);
219  page.map.view.setZoomLevel(18, Qt.point(page.map.width / 2.0, page.map.height/ 2.0));
220  gateSheet.sheetOpen = false
221  }
222  }
223  }
224  }
225 
226  LocationQueryOverlayProxyModel {
227  id: locationModel
228  sourceModel: PublicTransport.LocationQueryModel {
229  id: locationQuery
230  manager: ptMgr
231  }
232  mapData: page.map.mapData
233  }
234 
235  RealtimeEquipmentModel {
236  id: equipmentModel
237  mapData: page.map.mapData
238  realtimeModel: locationModel.sourceModel
239  }
240 
241  SelectLocationSheet {
242  id: locationSheet
243  publicTransportManager: ptMgr
244  onCoordinateSelected: function() {
245  page.map.mapLoader.loadForCoordinate(locationSheet.coordinate.y, locationSheet.coordinate.x);
246  page.map.view.beginTime = new Date();
247  page.map.view.endTime = new Date(page.map.view.beginTime.getTime() + 3600000);
248  // TODO timezone
249  }
250  }
251 
252  map.overlaySources: [ gateModel, platformModel, locationModel, equipmentModel ]
253  map.timeZone: "Europe/Berlin"
254 
255  header: RowLayout {
256  QQC2.Label { text: "Floor Level:" }
257  QQC2.ComboBox {
258  id: floorLevelCombo
259  model: page.map.floorLevels
260  textRole: "display"
261  currentIndex: page.map.floorLevels.rowForLevel(page.map.view.floorLevel);
262  onCurrentIndexChanged: if (currentIndex >= 0) { page.map.view.floorLevel = page.map.floorLevels.levelForRow(currentIndex); }
263  Layout.fillWidth: true
264  }
265  Connections {
266  target: page.map.view
267  function onFloorLevelChanged() { floorLevelCombo.currentIndex = page.map.floorLevels.rowForLevel(page.map.view.floorLevel); }
268  }
269 
270  QQC2.Slider {
271  id: zoomSlider
272  from: 14.0
273  to: 21.0
274  live: true
275  Layout.fillWidth: true
276 
277  onValueChanged: {
278  page.map.view.setZoomLevel(value, Qt.point(page.map.width / 2.0, page.map.height/ 2.0));
279  }
280  }
281  Connections {
282  target: page.map.view
283  function onZoomLevelChanged() { zoomSlider.value = page.map.view.zoomLevel; }
284  }
285  }
286 
287  coordinate: Qt.point(11.08196, 49.44572);
288  }
289 
290  Connections {
291  target: page.map
292  function onMapDataChanged() {
293  locationQuery.request.latitude = page.map.mapData.center.y;
294  locationQuery.request.longitude = page.map.mapData.center.x;
295  locationQuery.request.maximumDistance = page.map.mapData.radius;
296  locationQuery.request.types = PublicTransport.Location.RentedVehicleStation | PublicTransport.Location.RentedVehicle | PublicTransport.Location.Equipment;
297  }
298  }
299 
300  Component {
301  id: attributionPage
302  AttributionPage {
303  publicTransportManager: ptMgr
304  }
305  }
306 
307  Component {
308  id: aboutPage
309  Kirigami.AboutPage {
310  aboutData: {
311  "displayName": "KDE OSM Indoor Map",
312  "productName": "org.kde.kosmindoormap",
313  "componentName": "org.kde.kosmindoormap",
314  "shortDescription": "OSM Indoor Map Demo",
315  "homepage": "https://kde.org/",
316  "bugAddress": "[email protected]",
317  "version": "21.04",
318  "licenses": [
319  {
320  "name": "LGPL 2.0 or later",
321  "spdx": "LGPL-2.0-or-later"
322  }
323  ],
324  "copyrightStatement": "© 2020-2021 The KDE Team",
325  "desktopFileName": "kosmindoormap"
326  }
327  }
328  }
329 }
IconSizes iconSizes
QStringView level(QStringView ifopt)
QFuture< void > map(Sequence &sequence, MapFunctor function)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Thu Mar 30 2023 04:13:32 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.