• 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
MainWidget.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 2011 Daniel Marth <danielmarth@gmx.at>
9 // Copyright 2013 Bernhard Beschow <bbeschow@cs.tu-berlin.de>
10 
11 import QtQuick 1.0
12 import org.kde.edu.marble 0.11
13 import com.nokia.meego 1.0
14 
15 /*
16  * Main widget containing the map, models for routing, search, etc.
17  *
18  * @todo: Rename MarbleWidget or similar
19  */
20 Item {
21  id: screen
22  anchors.fill: parent
23  visible: false
24 
25  signal mouseClickGeoPosition(real longitude, real latitude)
26  signal placemarkSelected(variant placemark)
27 
28  property alias mapThemeModel: map.mapThemeModel
29  property alias radius: map.radius
30 
31  property alias bookmarks: map.bookmarks
32  property alias routing: map.routing
33  property alias search: map.search
34  property alias tracking: map.tracking
35  property alias navigation: map.navigation
36  property alias cloudSync: map.cloudSync
37 
38  // The widget representing the map.
39  MarbleWidget {
40  id: map
41  anchors.fill: parent
42 
44  property bool initialized: false
45 
46  workOffline: settings.workOffline
47  mapThemeId: settings.mapTheme
48  radius: settings.quitRadius
49  projection: settings.projection
50  activeFloatItems: [ "compass", "scalebar", "progress" ]
51  activeRenderPlugins: settings.activeRenderPlugins
52 
53  property Bookmarks bookmarks: Bookmarks {
54  map: map
55  }
56 
57  property Routing routing: Routing {
58  map: map
59  }
60 
61  // The grouped property "tracking" provides access to tracking related
62  // properties.
63  property Tracking tracking: Tracking {
64  // Connect the position source from below with the map.
65  map: map
66  positionSource: positionProvider
67  showTrack: settings.showTrack
68  positionMarker: marker
69 
70  onLastKnownPositionChanged: {
71  settings.lastKnownLongitude = map.tracking.lastKnownPosition.longitude
72  settings.lastKnownLatitude = map.tracking.lastKnownPosition.latitude
73  map.updatePositionIndicator()
74  }
75  }
76 
77  property Navigation navigation: Navigation {
78  map: map
79  muted: settings.voiceNavigationMuted
80  speaker: settings.voiceNavigationSpeaker
81  soundEnabled: settings.voiceNavigationSoundEnabled
82  }
83 
84  property CloudSync cloudSync: CloudSync {
85  id: cloudSync
86  map: map
87  owncloudServer: settings.owncloudServer
88  owncloudUsername: settings.owncloudUsername
89  owncloudPassword: settings.owncloudPassword
90  }
91 
92  Component.onCompleted: {
93  mouseClickGeoPosition.connect( screen.mouseClickGeoPosition )
94 
95  // Load last center of the map.
96  center.longitude = settings.quitLongitude
97  center.latitude = settings.quitLatitude
98  tracking.lastKnownPosition.longitude = settings.lastKnownLongitude
99  tracking.lastKnownPosition.latitude = settings.lastKnownLatitude
100  initialized = true
101  }
102 
103  Component.onDestruction: {
104  settings.quitRadius = radius
105  settings.quitLongitude = center.longitude
106  settings.quitLatitude = center.latitude
107  }
108 
109  property Search search: Search {
110  map: map
111  // Delegate of a search result.
113  placemarkDelegate:
114  Image {
115  id: searchDelegate
116  source: "qrc:/icons/placemark.svg"
117  transformOrigin: Item.Bottom
118  width: 32
119  fillMode: Image.PreserveAspectFit
120  smooth: true
121 
122  Text {
123  text: (index+1)
124  width: 32
125  height: 32
126  anchors.top: parent.top
127  anchors.left: parent.left
128  horizontalAlignment: Text.AlignHCenter
129  verticalAlignment: Text.AlignVCenter
130  color: "white"
131  font.bold: true
132  font.pixelSize: 20
133  }
134 
135  Rectangle {
136  id: routingOptions
137  visible: false
138  color: "white"
139  width: 250
140  height: nameLabel.height + routingButtons.height + 30
141  border.width: 1
142  border.color: "gray"
143  radius: 10
144  // Name of the search result.
145  Label {
146  id: nameLabel
147  text: display
148  anchors.top: parent.top
149  anchors.left: parent.left
150  anchors.right: parent.right
151  anchors.margins: 10
152  font.pixelSize: 18
153 
154  MouseArea {
155  anchors.fill: parent
156  onClicked: routingOptions.visible = false
157  }
158  }
159  // Route button
160  Column {
161  id: routingButtons
162  anchors.bottom: parent.bottom
163  anchors.horizontalCenter: parent.horizontalCenter
164  anchors.bottomMargin: 10
165  spacing: 5
166  Rectangle {
167  color: "white"
168  width: 230
169  height: 35
170  border.width: 1
171  border.color: "gray"
172  radius: 10
173  Label {
174  text: "Route"
175  anchors.centerIn: parent
176  font.pixelSize: 18
177  }
178  MouseArea {
179  anchors.fill: parent
180  onClicked: {
181  routingOptions.visible = false
182  settings.gpsTracking = true
183  map.routing.clearRoute()
184  map.routing.setVia( 0, map.tracking.lastKnownPosition.longitude, map.tracking.lastKnownPosition.latitude )
185  map.routing.setVia( 1, longitude, latitude )
186  openActivity( "Routing" )
187  }
188  }
189  }
190  }
191  }
192  // Show search result info if the placemark is clicked.
193  MouseArea {
194  anchors.fill: parent
195  onClicked: {
196  routingOptions.visible = !routingOptions.visible
197  }
198  }
199 
200  Connections {
201  target: map
202  onMouseClickGeoPosition: routingOptions.visible = false
203  }
204  }
205  }
206 
207  onPlacemarkSelected: {
208  pageStack.find(function(page) {
209  // Open the Placemark activity unless it's already the top most page
210  // id is not a QML Item property, hence the uid workaround
211  if (page.uid !== "edu.kde.org.marble.placemarkActivityPage") {
212  openPage("qrc:/activities/Placemark.qml");
213  }
214  return true;
215  })
216  screen.placemarkSelected(placemark)
217  }
218  }
219 
220  // Delivers the current (gps) position.
221  PositionSource {
222  id: positionProvider
223 
224  map: map
225 
226  // Can optionally be used to select a specific position provider
227  // plugin of marble. Per default the first one is used.
228  // The value is the nameId() of an installed Marble PositionProviderPlugin,
229  // e.g. Gpsd
230  source: "QtMobilityPositionProviderPlugin"
231 
232  // This starts/stops gps tracking.
233  active: settings.gpsTracking
234 
235  // Start a small grow/shrink animation of the marker to indicate position updates.
236  onPositionChanged: {
237  growAnimation.running = true
238  }
239  }
240 
241  // A marker that indicates the current position.
242  Image {
243  id: marker
244  width: 60
245  fillMode: Image.PreserveAspectFit
246  smooth: true
247  source: positionProvider.hasPosition ? "qrc:/icons/marker.svg" : "qrc:/icons/marker-yellow.svg"
248  visible: false
249 
250  // Animation that grows/shrinks the marker.
251  PropertyAnimation on x { duration: 300; easing.type: Easing.OutBounce }
252  PropertyAnimation on y { duration: 300; easing.type: Easing.OutBounce }
253  SequentialAnimation {
254  id: growAnimation
255  PropertyAnimation {
256  target: marker
257  properties: "scale"
258  to: 1.2
259  duration: 150
260  }
261  PropertyAnimation {
262  target: marker
263  properties: "scale"
264  to: 1.0
265  duration: 150
266  }
267  }
268  }
269 
270  PositionIndicator {
271  anchors.fill: parent
272  visible: settings.showPositionIndicator
273 
274  map: map
275  tracking: tracking
276  }
277 
278  // Starts a search for the passed term.
279  function find( term ) {
280  map.search.find( term )
281  }
282 
283  // Centers map on passed coordinates.
284  function centerOn( lon, lat ) {
285  map.center.longitude = lon
286  map.center.latitude = lat
287  }
288 
289  function setGeoSceneProperty( key, value ) {
290  map.setGeoSceneProperty( key, value )
291  }
292 
293  function downloadRoute( offset, from, to ) {
294  map.downloadRoute( offset, from, to )
295  }
296 
297  function downloadArea( from, to ) {
298  map.downloadArea( from, to )
299  }
300 
301  function getCenter() {
302  return map.center
303  }
304 
305  function setDataPluginDelegate( id, delegate ) {
306  map.setDataPluginDelegate( id, delegate )
307  }
308 
309  function renderPlugin( name ) {
310  return map.renderPlugin( name )
311  }
312 }
tracking
Definition: position-tracking.qml:12
Tracking
Definition: Tracking.qml:16
PositionIndicator
Definition: PositionIndicator.qml:12
search
Definition: google-search.qml:12
Routing
Definition: Routing.qml:15
Rectangle
Marble::radius
static qreal radius(qreal zoom)
Definition: thumbnailer.cpp:99
PositionSource
Definition: PositionSource.h:25
QtConcurrent::map
QFuture< void > map(Sequence &sequence, MapFunction function)
Search
Definition: Search.qml:15
CloudSync
Definition: CloudSync.h:22
Navigation
Definition: Navigation.qml:16
MarbleWidget
Wraps a Marble::MarbleWidget, providing access to important properties and methods.
Definition: MarbleDeclarativeWidget.h:50
Bookmarks
Definition: Bookmarks.h:40
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:40 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