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

marble

  • sources
  • kde-4.12
  • kdeedu
  • marble
  • src
  • apps
  • marble-touch
PlacemarkEditor.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 2012 Dennis Nienhüser <earthwings@gentoo.org>
8 
9 import QtQuick 1.0
10 import com.nokia.meego 1.0
11 import org.kde.edu.marble 0.11
12 
13 Item {
14  id: root
15  z: 10
16 
17  property Placemark placemark
18 
19  function editPlacemark(placemark)
20  {
21  root.placemark = placemark
22  placemarkLabel.text = placemark.name
23  distanceLabel.text = (marbleWidget.tracking.lastKnownPosition.distance(placemark.coordinate.longitude, placemark.coordinate.latitude) / 1000).toFixed(1) + " km"
24  flickrPhotosModel.update()
25  }
26 
27  function startRouting()
28  {
29  settings.gpsTracking = true
30  marbleWidget.routing.clearRoute()
31  marbleWidget.routing.setVia( 0, marbleWidget.tracking.lastKnownPosition.longitude, marbleWidget.tracking.lastKnownPosition.latitude )
32  marbleWidget.routing.setVia( 1, root.placemark.coordinate.longitude, root.placemark.coordinate.latitude )
33  openActivity( "Routing" )
34  }
35 
36  Item {
37  id: wrapper
38  anchors.fill: parent
39  width: parent.width
40  anchors.margins: 5
41 
42  Column {
43  id: content
44  width: parent.width
45  spacing: 10
46 
47  Item {
48  id: headerItem
49  width: parent.width
50  height: Math.max(placemarkLabel.height, bookmarkButton.height)
51 
52  Label {
53  id: placemarkLabel
54  anchors.left: parent.left
55  anchors.right: bookmarkButton.left
56  anchors.verticalCenter: parent.verticalCenter
57  }
58 
59  ToolButton {
60  id: bookmarkButton
61  anchors.verticalCenter: parent.verticalCenter
62  anchors.right: parent.right
63 
64  property bool isBookmark: root.placemark != undefined && marbleWidget.bookmarks.isBookmark(root.placemark.coordinate.longitude,root.placemark.coordinate.latitude)
65  iconSource: isBookmark ? "qrc:/icons/bookmark.png" : "qrc:/icons/bookmark-disabled.png"
66 
67  width: 32
68  height: 32
69  flat: true
70 
71  onClicked: {
72  if ( isBookmark ) {
73  marbleWidget.bookmarks.removeBookmark(root.placemark.coordinate.longitude, root.placemark.coordinate.latitude)
74  } else {
75  marbleWidget.bookmarks.addBookmark(root.placemark.coordinate.longitude, root.placemark.coordinate.latitude, root.placemark.name, "Default")
76  }
77  isBookmark = marbleWidget.bookmarks.isBookmark(root.placemark.coordinate.longitude, root.placemark.coordinate.latitude)
78  }
79  }
80  }
81 
82  Rectangle {
83  id: horizontalLine
84  anchors.left: parent.left
85  anchors.right: parent.right
86  color: "darkgray"
87  height: 1
88  }
89 
90  Row {
91  id: routingItem
92  width: parent.width
93  height: carButton.height
94  spacing: 10
95 
96  Button {
97  id: carButton
98  width: 120
99  iconSource: "qrc:/icons/routing-motorcar.svg"
100  onClicked: {
101  marbleWidget.routing.routingProfile = "Motorcar"
102  root.startRouting()
103  }
104  }
105 
106  Button {
107  id: bikeButton
108  width: 80
109  iconSource: "qrc:/icons/routing-bike.svg"
110  onClicked: {
111  marbleWidget.routing.routingProfile = "Bicycle"
112  root.startRouting()
113  }
114  }
115 
116  Button {
117  id: pedButton
118  width: 60
119  iconSource: "qrc:/icons/routing-pedestrian.svg"
120  onClicked: {
121  marbleWidget.routing.routingProfile = "Pedestrian"
122  root.startRouting()
123  }
124  }
125 
126  Label {
127  id: distanceLabel
128  anchors.bottom: parent.bottom
129  anchors.right: parent.right
130  text: "0 km"
131  }
132  }
133 
134  Item {
135  id: photoItem
136  anchors.left: parent.left
137  anchors.right: parent.right
138  height: 64
139 
140  Item {
141  id: weatherItem
142  anchors.left: parent.left
143  width: 234
144  Repeater {
145  model: weatherModel
146 
147  Item {
148  Image {
149  id: weatherConditionImage
150  visible: weatherConditionImage.source !== ""
151 
152  width: 64
153  height: width
154  fillMode: Image.PreserveAspectFit
155  smooth: true
156  property string condition: weatherCondition
157  property string icon: ""
158  onConditionChanged: icon = parseCondition(weatherCondition, clouds)
159  source: icon === "" ? "" : Marble.resolvePath("weather/weather-" + icon + ".png")
160  }
161 
162  Flickable {
163  anchors.left: weatherConditionImage.right
164  anchors.margins: 5
165  width: 160
166  height: 64
167  contentWidth: 160
168  contentHeight: temperatureLabel.height
169  clip: true
170 
171  Label {
172  id: temperatureLabel
173  width: 160
174  property string cloudsText: clouds === "n/a" ? "" : clouds
175  property string weatherConditionText: weatherCondition === "n/a" ? "" : (cloudsText === "" ? "" : ", ") + weatherCondition
176  text: "<font size=\"-2\">" + temperature + " °C<br />" + cloudsText + weatherConditionText + "</font>"
177  }
178  }
179 
180  function parseCondition(condition, clouds) {
181  if (condition === "light rain") return "showers-scattered"
182  if (condition.match("rain")) return "showers"
183  if (condition.match("drizzle")) return "showers"
184  if (condition === "light snow") return "snow-scattered"
185  if (condition.match("hail")) return "hail"
186  if (condition.match("snow")) return "snow"
187  if (condition.match("ice")) return "freezing-rain"
188  if (condition === "mist") return "mist"
189  if (condition === "fog") return "mist"
190  if (condition === "smoke") return "mist"
191  if (condition === "volcanic ash") return "mist"
192  if (condition === "sand") return "mist"
193  if (condition === "haze") return "mist"
194  if (condition === "spray") return "mist"
195  if (condition === "widespread dust") return "mist"
196  if (condition === "squall") return "storm"
197  if (condition === "sandstorm") return "storm"
198  if (condition === "duststorm") return "storm"
199  if (condition === "well developed dust/sand whirls") return "storm"
200  //console.debug("unknown condition " + condition)
201 
202  if (clouds === "clear sky") return "clear";
203  if (clouds === "few clouds") return "few-clouds";
204  if (clouds === "scattered clouds") return "few-clouds";
205  if (clouds === "broken clouds") return "clouds";
206  if (clouds === "overcast") return "many-clouds";
207  //console.debug("unknown clouds " + clouds)
208 
209  return ""
210  }
211  }
212  }
213  }
214 
215  ListView {
216  id: photoView
217  anchors.right: parent.right
218  visible: flickrPhotosModel.count > 0
219  height: parent.height
220  width: 162
221  spacing: 4
222  orientation: ListView.Horizontal
223  snapMode: ListView.SnapToItem
224  clip: true
225 
226  model: flickrPhotosModel
227  delegate: Rectangle {
228  anchors.verticalCenter: parent.verticalCenter
229  color: photoView.currentIndex === index ? "lightblue" : "darkgray"
230  smooth: true
231  width: 79
232  height: 79
233  scale: photoImage.status === Image.Ready ? 1.0 : 0.0
234 
235  Image {
236  id: photoImage
237  anchors.centerIn: parent
238  width: 75
239  height: 75
240  fillMode: Image.PreserveAspectCrop
241  source: "http://farm" + farm + ".static.flickr.com/" + server + "/" + photoId + "_" + secret + "_s.jpg"
242  smooth: true
243  clip: true
244  }
245 
246  Behavior on scale {
247  NumberAnimation {
248  easing.type: Easing.InOutQuad
249  duration: 500
250  }
251  }
252  }
253  }
254  }
255  }
256  }
257 
258  XmlListModel {
259  id: flickrPhotosModel
260 
261  property double longitude: root.placemark != undefined ? root.placemark.coordinate.longitude : 0.0
262  property double latitude: root.placemark != undefined ? root.placemark.coordinate.latitude : 0.0
263 
264  property string url: ""
265 
266  source: settings.workOffline ? "" : url
267  query: "/rsp/photos/photo"
268 
269  XmlRole { name: "photoId"; query: "@id/string()" }
270  XmlRole { name: "secret"; query: "@secret/string()" }
271  XmlRole { name: "server"; query: "@server/string()" }
272  XmlRole { name: "farm"; query: "@farm/string()" }
273 
274  function update()
275  {
276  url = "http://www.flickr.com/services/rest/?method=flickr.photos.search&format=rest&api_key=620131a1b82b000c9582b94effcdc636&lon=" + longitude + "&lat=" + latitude + "&radius=0.1&license=1,2,3,4,5,6,7"
277  }
278  }
279 
280  XmlListModel {
281  id: weatherModel
282 
283  property double longitude: root.placemark != undefined ? root.placemark.coordinate.longitude : 0.0
284  property double latitude: root.placemark != undefined ? root.placemark.coordinate.latitude : 0.0
285 
286  source: settings.workOffline ? "" : "http://ws.geonames.org/findNearByWeatherXML?lat=" + latitude + "&lng=" + longitude
287  query: "/geonames/observation"
288 
289  XmlRole { name: "temperature"; query: "temperature/string()" }
290  XmlRole { name: "weatherCondition"; query: "weatherCondition/string()" }
291  XmlRole { name: "clouds"; query: "clouds/string()" }
292  }
293 
294  Connections { target: marbleWidget; onPlacemarkSelected: root.editPlacemark(placemark) }
295 }
Placemark::name
QString name
Definition: Placemark.h:34
Button
Definition: cloud-sync/Button.qml:11
ToolButton
Rectangle
XmlListModel
Item
Placemark
Wraps a GeoDataPlacemark for QML access.
Definition: Placemark.qml:11
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:52 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
  • kstars
  • libkdeedu
  •   keduvocdocument
  • 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