• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • apps
  • marble-touch
  • activities
Routing.qml
Go to the documentation of this file.
1 // This file is part of the Marble Virtual Globe.
2 //
3 // This program is free software licensed under the GNU LGPL. You can
4 // find a copy of this license in LICENSE.txt in the top directory of
5 // the source code.
6 //
7 // Copyright 2011 Dennis Nienhüser <earthwings@gentoo.org>
8 // Copyright 2013 Andrei Duma <andrei.duma.dorian@gmail.com>
9 
10 import QtQuick 1.0
11 import com.nokia.meego 1.0
12 import org.kde.edu.marble 0.11
13 import ".."
14 
15 /*
16  * Page for routing activity.
17  */
18 Page {
19  id: routingActivityPage
20  anchors.fill: parent
21 
22  property bool horizontal: width / height > 1.20
23 
24  tools: ToolBarLayout {
25  MarbleToolIcon {
26  iconSource: main.icon( "actions/go-home", 48 );
27  onClicked: main.showNavigation()
28  }
29  ToolButton {
30  id: minimizeButton
31  iconSource: main.icon( "actions/go-up", 48 );
32  checkable: true
33  checked: true
34  width: 60
35  flat: true
36  }
37  MarbleToolIcon {
38  iconSource: main.icon( "places/user-identity", 48 );
39  onClicked: {
40  marbleWidget.centerOn( marbleWidget.tracking.lastKnownPosition.longitude, marbleWidget.tracking.lastKnownPosition.latitude )
41  if (marbleWidget.zoom < 22026 ) {
42  marbleWidget.zoom = 86250
43  }
44  }
45  }
46  ToolButton {
47  iconSource: main.icon( "devices/network-wireless", 48 );
48  checkable: true
49  checked: !settings.workOffline
50  onCheckedChanged: settings.workOffline = !checked
51  width: 60
52  flat: true
53  }
54  MarbleToolIcon {
55  id: menuIcon
56  iconSource: main.icon( "actions/show-menu", 48 );
57  onClicked: {
58  if (main.components === "plasma") {
59  pageMenu.visualParent = menuIcon
60  }
61  pageMenu.open()
62  }
63  }
64  }
65 
66  Menu {
67  id: pageMenu
68  content: MarbleMenuLayout {
69  MenuItem {
70  text: "Start Navigation"
71  onClicked: openActivity( "Navigation" )
72  }
73 
74  MenuItem {
75  text: "Prepare Offline Usage"
76  onClicked: downloadSheet.open()
77  }
78 
79  MenuItem {
80  text: "Save Route"
81  onClicked: {
82  saveRouteDialog.filename = "route-" + Qt.formatDateTime(new Date(), "yyyy-MM-dd_hh.mm.ss") + ".kml"
83  saveRouteDialog.open()
84  }
85  }
86 
87  MenuItem {
88  text: "Save Route to Cloud"
89  onClicked: marbleWidget.cloudSync.uploadRoute()
90  visible: settings.owncloudSync
91  }
92 
93  MenuItem {
94  text: "Open Route"
95  onClicked: openRouteDialog.open()
96  }
97 
98  MenuItem {
99  text: "Cloud Routes"
100  onClicked: manageRoutesSheet.open()
101  visible: settings.owncloudSync
102  }
103 
104  MenuItemSwitch {
105  text: "Elevation Profile"
106  checked: false
107  onCheckedChanged: {
108  var plugins = settings.activeRenderPlugins
109  if ( checked ) {
110  plugins.push("elevationprofile")
111  } else {
112  settings.removeElementsFromArray(plugins, ["elevationprofile"])
113  }
114  settings.activeRenderPlugins = plugins
115  marbleWidget.setGeoSceneProperty( "hillshading", checked )
116  }
117  }
118  }
119  }
120 
121  Flickable {
122  id: searchResultView
123  contentWidth: width
124  contentHeight: routeEditor.height + waypointListView.height
125 
126  property bool minimized: !minimizeButton.checked
127  visible: !minimized
128 
129  anchors.bottom: routingActivityPage.bottom
130  anchors.left: routingActivityPage.left
131  width: routingActivityPage.horizontal ? (minimized ? 0 : routingActivityPage.width / 2) : routingActivityPage.width
132  height: routingActivityPage.horizontal ? routingActivityPage.height : (minimized ? 0 : routingActivityPage.height / 2)
133 
134  Behavior on height {
135  enabled: !routingActivityPage.horizontal;
136  NumberAnimation {
137  easing.type: Easing.InOutQuad;
138  duration: 250
139  }
140  }
141 
142  RouteEditor {
143  id: routeEditor
144  anchors.top: parent.top
145  anchors.left: parent.left
146  anchors.right: parent.right
147  anchors.margins: 5
148  }
149 
150  ListView {
151  id: waypointListView
152  anchors.top: routeEditor.bottom
153  anchors.left: parent.left
154  anchors.right: parent.right
155  anchors.margins: 5
156  height: 74 * count
157 
158  model: marbleWidget.routing.waypointModel()
159  delegate: turnTypeDelegate
160  highlight: Rectangle { color: "lightsteelblue"; radius: 5 }
161  highlightMoveDuration: 200
162  focus: true
163  interactive: false
164  spacing: 4
165  clip: true
166  }
167  }
168 
169  ScrollDecorator {
170  flickableItem: searchResultView
171  }
172 
173  Item {
174  id: mapContainer
175  clip: true
176 
177  anchors.left: routingActivityPage.horizontal ? searchResultView.right : routingActivityPage.left
178  anchors.bottom: routingActivityPage.horizontal ? routingActivityPage.bottom : searchResultView.top
179  anchors.right: routingActivityPage.right
180  anchors.top: routingActivityPage.top
181 
182  function embedMarbleWidget() {
183  marbleWidget.parent = mapContainer
184  settings.projection = "Mercator"
185  var plugins = settings.defaultRenderPlugins
186  settings.removeElementsFromArray(plugins, ["coordinate-grid", "sun", "stars", "compass"])
187  settings.activeRenderPlugins = plugins
188  settings.mapTheme = settings.streetMapTheme
189  settings.gpsTracking = true
190  settings.showPositionIndicator = true
191  marbleWidget.tracking.positionMarkerType = Tracking.Circle
192  settings.showTrack = false
193  marbleWidget.visible = true
194  }
195 
196  Component.onDestruction: {
197  if ( marbleWidget.parent === mapContainer ) {
198  marbleWidget.parent = null
199  marbleWidget.visible = false
200  }
201  }
202  }
203 
204  FileSaveDialog {
205  id: saveRouteDialog
206  anchors.fill: parent
207  folder: "/home/user/MyDocs"
208  filename: ""
209  nameFilters: [ "*.kml" ]
210 
211  onAccepted: { marbleWidget.routing.saveRoute( folder + "/" + filename ); }
212  }
213 
214  FileOpenDialog {
215  id: openRouteDialog
216  anchors.fill: parent
217  folder: "/home/user/MyDocs"
218  nameFilters: [ "*.kml", "*.gpx" ]
219 
220  onAccepted: { marbleWidget.routing.openRoute( folder + "/" + filename ); }
221  }
222 
223  Component {
224  id: turnTypeDelegate
225 
226  Column {
227  width: parent.width
228  spacing: 4
229 
230  Row {
231  id: row
232  width: parent.width
233  Image {
234  id: turnIcon
235  width: 64; height: 64
236  source: "qrc" + turnTypeIcon
237  }
238 
239  Label {
240  anchors.verticalCenter: parent.verticalCenter
241  font.pixelSize: 18
242  text: display;
243  width: parent.width - turnIcon.width - 20
244  wrapMode: Text.WrapAtWordBoundaryOrAnywhere
245 
246  MouseArea {
247  anchors.fill: parent
248  onClicked: {
249  waypointListView.currentIndex = index
250  marbleWidget.centerOn(longitude, latitude)
251  }
252  }
253  }
254  }
255 
256  Rectangle {
257  x: 5
258  width: parent.width - 20
259  height: 1
260  color: "white"
261  }
262  }
263  }
264 
265  onStatusChanged: {
266  if ( status === PageStatus.Activating ) {
267  mapContainer.embedMarbleWidget()
268  }
269  }
270 
271  Sheet {
272  id: manageRoutesSheet
273  rejectButtonText: "Back"
274 
275  content: ListView {
276  id: routeView
277  anchors.fill: parent
278  spacing: 5
279  clip: true
280 
281  model: marbleWidget.cloudSync.routeModel
282  delegate: routeViewDelegate
283 
284  highlight: Rectangle {
285  color: "lightsteelblue"
286  radius: 5
287  }
288  }
289  }
290 
291  Component {
292  id: routeViewDelegate
293 
294  Item {
295  property bool selected: routeView.currentIndex === index
296 
297  MouseArea {
298  anchors.fill: parent
299  onClicked: routeView.currentIndex = index
300  }
301 
302  width: routeView.width
303  height: routeTopBox.height + (selected ? routeControlBox.height + 15 : 10)
304 
305  Item {
306  id: routeTopBox
307  anchors.margins: 5
308  anchors.top: parent.top
309  anchors.left: parent.left
310  anchors.right: parent.right
311  height: previewImage.height
312 
313  Image {
314  id: previewImage
315  source: previewUrl
316  width: 128; height: 128
317  }
318 
319  Item {
320  id: routeInfo
321 
322  anchors.left: previewImage.right
323  anchors.leftMargin: 5
324  anchors.right: parent.right
325  anchors.top: parent.top
326  anchors.bottom: parent.bottom
327 
328  Text {
329  id: nameText
330  text: name
331  anchors.centerIn: parent
332  width: parent.width - 20
333  wrapMode: Text.WrapAtWordBoundaryOrAnywhere
334  font.pixelSize: 18
335  }
336  }
337  }
338 
339  Item {
340  id: routeControlBox
341  visible: selected
342 
343  anchors.top: routeTopBox.bottom
344  anchors.left: parent.left
345  anchors.right: parent.right
346  anchors.margins: 5
347 
348  height: openButton.height
349 
350  Button {
351  id: openButton
352 
353  width: 100
354  text: "Open"
355  onClicked: {
356  marbleWidget.cloudSync.openRoute( identifier )
357  manageRoutesSheet.close()
358  }
359  }
360 
361  Row {
362  anchors.right: parent.right
363  spacing: 5
364  Rectangle {
365  radius: 25
366  width: cacheControlBox.width + 12
367  height: cacheControlBox.height - 1
368  Row {
369  id: cacheControlBox
370  anchors.right: parent.right
371  spacing: 10
372  Text {
373  anchors.verticalCenter: parent.verticalCenter
374  text: isCached ? "On device" : "Not on device"
375  font.pixelSize: 18
376  }
377 
378  Button {
379  width: 56
380  iconSource: main.icon( "actions/download", 32 )
381  onClicked: {
382  marbleWidget.cloudSync.downloadRoute( identifier )
383  }
384  visible: !isCached
385  }
386 
387  Button {
388  width: 56
389  iconSource: main.icon( "actions/dialog-cancel", 32 )
390  onClicked: {
391  marbleWidget.cloudSync.removeRouteFromDevice( identifier )
392  }
393  visible: isCached
394  }
395  }
396  }
397  Rectangle {
398  radius: 25
399  width: cloudControlBox.width + 12
400  height: cloudControlBox.height - 1
401  Row {
402  id: cloudControlBox
403  anchors.right: parent.right
404  spacing: 10
405  Text {
406  anchors.verticalCenter: parent.verticalCenter
407  text: isOnCloud ? "In cloud" : "Not in cloud"
408  font.pixelSize: 18
409  }
410 
411  Button {
412  width: 56
413  iconSource: main.icon( "actions/upload", 32 )
414  onClicked: {
415  marbleWidget.cloudSync.uploadRoute( identifier )
416  }
417  visible: !isOnCloud
418  }
419 
420  Button {
421  width: 56
422  iconSource: main.icon( "actions/dialog-cancel", 32 )
423  onClicked: {
424  marbleWidget.cloudSync.deleteRouteFromCloud( identifier )
425  }
426  visible: isOnCloud
427  }
428  }
429  }
430  }
431  }
432  }
433  }
434 
435  Sheet {
436  id: downloadSheet
437 
438  acceptButtonText: "Download"
439  rejectButtonText: "Cancel"
440 
441  content {
442  Column {
443  anchors.fill: parent
444  anchors.margins: 10
445  spacing: 10
446 
447  Label {
448  text: "<font size=\"-1\">Select the map images to download for offline usage. Note that routing data and voice navigation speakers must be downloaded in the Preferences.</font>"
449  color: "gray"
450  width: parent.width
451  }
452 
453  Label { text: "Download Mode" }
454 
455  ButtonRow {
456  id: downloadTypeSwitch
457  checkedButton: routeButton
458  property bool routeMode: checkedButton === routeButton
459 
460  Button {
461  id: routeButton
462  text: "Route"
463  }
464 
465  Button {
466  id: areaButton
467  text: "Visible Area"
468  }
469  }
470 
471  Label {
472  width: parent.width
473  text: downloadTypeSwitch.routeMode ? "The current route area is downloaded" : "The currently visible map area is downloaded"
474  color: "gray"
475  wrapMode: Text.WordWrap
476  }
477 
478  Label { text: "Level of detail" }
479 
480  Slider {
481  id: tileSlider
482  stepSize: 1
483  valueIndicatorVisible: true
484  minimumValue: 11
485  maximumValue: 16
486  value: 14
487  valueIndicatorText: "tile level " + value
488  width: parent.width
489  }
490 
491  Label {
492  anchors.left: tileSlider.left
493  anchors.right: tileSlider.right
494  anchors.margins: 30
495  color: "gray"
496  text: humanValue()
497  function humanValue() {
498  switch (tileSlider.value) {
499  case 11: return "Very coarse"
500  case 12: return "Cities with names"
501  case 13: return "Villages and suburbs with names"
502  case 14: return "Important streets with names"
503  case 15: return "Many streets with names"
504  case 16: return "Most streets with names"
505  }
506  }
507  }
508 
509  Label {
510  text: "Side margin"
511  visible: downloadTypeSwitch.routeMode
512  }
513 
514  Slider {
515  id: offsetSlider
516  visible: downloadTypeSwitch.routeMode
517  stepSize: 50
518  valueIndicatorVisible: true
519  valueIndicatorText: value + " meter"
520  minimumValue: 100
521  value: 500
522  maximumValue: 2500
523  width: parent.width
524  }
525  }
526  }
527 
528  onAccepted: {
529  if (downloadTypeSwitch.routeMode) {
530  marbleWidget.downloadRoute( offsetSlider.value, 0, tileSlider.value )
531  } else {
532  marbleWidget.downloadArea( 0, tileSlider.value )
533  }
534  }
535  }
536 }
MarbleWindow::components
string components
Definition: harmattan/MarbleWindow.qml:19
Tracking
Definition: Tracking.qml:16
MenuItemSwitch::checked
alias checked
Definition: harmattan/MenuItemSwitch.qml:54
FileOpenDialog
Definition: FileOpenDialog.qml:10
Button
Definition: cloud-sync/Button.qml:11
FileSaveDialog
Definition: FileSaveDialog.qml:10
RouteEditor
Definition: RouteEditor.qml:11
Rectangle
MenuItem
Marble::radius
static qreal radius(qreal zoom)
Definition: thumbnailer.cpp:99
MenuItemSwitch
Definition: harmattan/MenuItemSwitch.qml:49
Tracking::Circle
Definition: Tracking.h:48
MarbleWindow::icon
void icon(name, size)
MarbleMenuLayout
Definition: harmattan/MarbleMenuLayout.qml:10
MarbleToolIcon
Definition: harmattan/MarbleToolIcon.qml:10
MarbleWindow::showNavigation
void showNavigation()
main
Definition: examples/cpp/marbleQuick2/main.qml:3
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:41 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal