• 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
  • activities
Explore.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 Utku Aydın <utkuaydin34@gmail.com>
8 
9 import QtQuick 1.0
10 import QtWebKit 1.0
11 import com.nokia.meego 1.0
12 import org.kde.edu.marble 0.11
13 import ".."
14 
15 Page {
16  id: exploreActivityPage
17  anchors.fill: parent
18 
19  property bool horizontal: width / height > 1.20
20 
21  tools: ToolBarLayout {
22  MarbleToolIcon {
23  iconSource: main.icon( "actions/go-home", 48 );
24  onClicked: main.navigationMenu.open()
25  }
26 
27  MarbleToolIcon {
28  id: menuIcon
29  iconSource: main.icon( "actions/show-menu", 48 );
30  onClicked: {
31  if (main.components === "plasma") {
32  pageMenu.visualParent = menuIcon
33  }
34  pageMenu.open()
35  }
36  }
37  }
38 
39  Menu {
40  id: pageMenu
41  content: MarbleMenuLayout {
42  MenuItem {
43  text: "Login"
44  onClicked: pageStack.push(authPage)
45  }
46  }
47  }
48 
49  Page {
50  id: authPage
51  WebView {
52  id: authWebView
53  anchors.fill: parent
54 
55  property string authUrl: "https://foursquare.com/oauth2/authenticate?response_type=token"
56  property string redirectUri: "http://edu.kde.org/marble/dummy"
57  property string clientId: "YPRWSYFW1RVL4PJQ2XS5G14RTOGTHOKZVHC1EP5KCCCYQPZF"
58 
59  url: authUrl + "&redirect_uri=" + redirectUri + "&client_id=" + clientId
60  onLoadFinished: {
61  if( marbleWidget.renderPlugin( "foursquare" ).storeAccessToken( url ) ) {
62  stop.trigger()
63  authButton.checked = false
64  }
65  }
66  }
67 
68  tools: ToolBarLayout {
69  MarbleToolIcon {
70  iconSource: main.icon( "actions/go-previous-view", 48 );
71  onClicked: pageStack.pop()
72  }
73  }
74  }
75 
76  Item {
77  id: mapContainer
78  anchors.fill: parent
79  clip: true
80 
81  function embedMarbleWidget() {
82  marbleWidget.parent = mapContainer
83  settings.projection = "Mercator"
84  var plugins = settings.defaultRenderPlugins
85  plugins.push( "foursquare" )
86 
87  settings.activeRenderPlugins = plugins
88  settings.mapTheme = settings.streetMapTheme
89  settings.gpsTracking = true
90  settings.showPositionIndicator = true
91  settings.showTrack = false
92 
93  marbleWidget.tracking.positionMarkerType = Tracking.Circle
94  marbleWidget.visible = true
95  marbleWidget.setDataPluginDelegate( "foursquare", foursquareDelegate )
96  }
97 
98  Component.onDestruction: {
99  marbleWidget.setDataPluginDelegate( "foursquare", 0 )
100  if ( marbleWidget.parent === mapContainer ) {
101  marbleWidget.parent = null
102  marbleWidget.visible = false
103  }
104  }
105  }
106 
107  onStatusChanged: {
108  if ( status === PageStatus.Activating ) {
109  mapContainer.embedMarbleWidget()
110  }
111  }
112 
113  Component {
114  id: foursquareDelegate
115 
116  Rectangle {
117  id: venueRectangle
118  property int padding: 7
119  width: container.width + padding
120  height: container.height + padding
121  scale: 0.0
122  color: "#88D788"
123  border.color: "#39AC39"
124  border.width: 2
125  radius: 3
126 
127  SequentialAnimation {
128  id: venueAppearAnimation
129  PauseAnimation { duration: Math.random() * 100 }
130  NumberAnimation {
131  target: venueRectangle
132  property: "scale"
133  to: 1.0
134  duration: 150
135  }
136  }
137 
138  Component.onCompleted: {
139  venueAppearAnimation.running = true
140  }
141 
142  Item {
143  id: container
144  width: 32 + ( focus ? venueName.width + venueName.anchors.leftMargin : 0 )
145  height: Math.max( 32, venueName.height )
146  anchors.horizontalCenter: parent.horizontalCenter
147  anchors.verticalCenter: parent.verticalCenter
148 
149  Rectangle {
150  id: iconFallBack
151  width: 30
152  height: width
153  radius: 5
154  color: "white"
155  border.width: 2
156  border.color: "darkgray"
157  }
158 
159  Image {
160  id: categoryIcon
161  source: categoryIconUrl
162  anchors.verticalCenter: parent.verticalCenter
163  }
164 
165  Text {
166  id: venueName
167  scale: container.focus ? 1.0 : 0.0
168  text: name
169  anchors.left: iconFallBack.right
170  anchors.leftMargin: 5
171  anchors.verticalCenter: parent.verticalCenter
172  visible: parent.focus ? true : false
173 
174  Behavior on scale { NumberAnimation { duration: 150 } }
175  }
176 
177  Behavior on width { NumberAnimation { duration: 150 } }
178  onFocusChanged: sticky = focus
179  }
180 
181  function updateDetails() {
182  venueDetails.venueId = identifier
183  venueDetails.name = name
184  venueDetails.category = category
185  venueDetails.address = address
186  venueDetails.city = city
187  venueDetails.country = country
188  venueDetails.usersCount = usersCount
189  venueDetails.largeIcon = categoryLargeIconUrl
190  }
191 
192  MouseArea {
193  anchors.fill: parent
194  onClicked: {
195  if( container.focus == true ) {
196  updateDetails()
197  listModel.retrieve()
198  venueDetails.visible = true
199  } else {
200  container.focus = true
201  }
202  }
203  }
204  }
205  }
206 
207  Rectangle {
208  id: venueDetails
209 
210  anchors.bottom: exploreActivityPage.bottom
211  width: exploreActivityPage.horizontal ?
212  Math.max( exploreActivityPage.width / 4, minWidth() + 14 ) : exploreActivityPage.width
213  height: exploreActivityPage.horizontal ? exploreActivityPage.height : exploreActivityPage.height / 3
214  visible: false
215  radius: 10
216  color: "#f7f7f7"
217  border.width: 2
218  border.color: "darkgray"
219 
220  property string venueId
221  property string name
222  property string category
223  property string address
224  property string city
225  property string country
226  property string usersCount
227  property string largeIcon
228 
229  function minWidth() {
230  return Math.max(detailName.width,
231  detailCategory.width,
232  detailAddress.width,
233  detailCity.width,
234  detailCountry.width)
235  }
236 
237  Image {
238  id: detailIcon
239  source: venueDetails.largeIcon
240  anchors.top: venueDetails.top
241  anchors.left: detailName.left
242  anchors.topMargin: 10
243  }
244 
245  Text {
246  id: detailName
247  text: venueDetails.name
248  anchors.top: detailIcon.bottom
249  anchors.left: venueDetails.left
250  anchors.topMargin: 5
251  anchors.leftMargin: 7
252  }
253 
254  Text {
255  id: detailCategory
256  text: venueDetails.category
257  anchors.top: detailName.bottom
258  anchors.left: detailName.left
259  }
260 
261  Text {
262  id: detailAddressTitle
263  text: qsTr( "Address" )
264  anchors.top: detailCategory.bottom
265  anchors.left: detailName.left
266  anchors.topMargin: 5
267  font.bold: true
268  }
269 
270  Text {
271  id: detailAddress
272  text: venueDetails.address
273  anchors.top: detailAddressTitle.bottom
274  anchors.left: detailName.left
275  }
276 
277  Text {
278  id: detailCity
279  text: venueDetails.city
280  anchors.top: detailAddress.bottom
281  anchors.left: detailName.left
282  }
283 
284  Text {
285  id: detailCountry
286  text: venueDetails.country
287  anchors.top: detailCity.bottom
288  anchors.left: detailName.left
289  }
290 
291  ListView {
292  id: photoView
293  width: exploreActivityPage.horizontal ? venueDetails.width - anchors.margins : 64
294 
295  anchors.top: exploreActivityPage.horizontal ? detailCountry.bottom : venueDetails.top
296  anchors.left: exploreActivityPage.horizontal ? venueDetails.left : venueDetails.horizontalCenter
297  anchors.bottom: venueDetails.bottom
298  anchors.right:venueDetails.right
299  anchors.margins: 5
300  spacing: 2
301 
302  model: listModel
303  orientation: ListView.Vertical
304  clip: true
305 
306  delegate: Image {
307  id: venuePhoto
308  width: photoView.width
309  scale: 0.0
310  fillMode: Image.PreserveAspectFit
311  source: url
312  smooth: true
313 
314  SequentialAnimation {
315  id: photoAppearAnimation
316  PauseAnimation { duration: Math.random() * 100 }
317  NumberAnimation {
318  target: venuePhoto
319  property: "scale"
320  to: 1.0
321  duration: 150
322  }
323  }
324 
325  Component.onCompleted: {
326  photoAppearAnimation.running = true
327  }
328  }
329  }
330 
331  Item {
332  id: modelData
333  property string clientId: "YPRWSYFW1RVL4PJQ2XS5G14RTOGTHOKZVHC1EP5KCCCYQPZF"
334  property string clientSecret: "5L2JDCAYQCEJWY5FNDU4A1RWATE4E5FIIXXRM41YBTFSERUH"
335  property string source: "https://api.foursquare.com/v2/venues/" + venueDetails.venueId + "/photos?v=20120617&group=venue&limit=5&client_id=" + clientId + "&client_secret=" + clientSecret
336 
337  ListModel {
338  id: listModel
339  property string oldId
340 
341  function retrieve() {
342  if( oldId == venueDetails.venueId ) {
343  return
344  }
345 
346  var xhr = new XMLHttpRequest;
347  xhr.open( "GET", modelData.source );
348  xhr.onreadystatechange = function() {
349  if( xhr.readyState === XMLHttpRequest.DONE ) {
350  listModel.oldId = venueDetails.venueId
351  listModel.clear()
352  var data = JSON.parse( xhr.responseText );
353  for( var item in data.response.photos.items ) {
354  var photo = data.response.photos.items[ item ];
355  listModel.append({
356  url: photo.prefix + "original" + photo.suffix,
357  width: photo.width,
358  height: photo.height
359  });
360  }
361  }
362  }
363 
364  xhr.send();
365  }
366  }
367  }
368 
369  Behavior on width { NumberAnimation { duration: 150 } }
370  }
371 }
MarbleWindow::components
string components
Definition: harmattan/MarbleWindow.qml:19
Tracking
Definition: Tracking.qml:16
MarbleWindow::navigationMenu
alias navigationMenu
Definition: harmattan/MarbleWindow.qml:21
ListModel
Rectangle
MenuItem
Tracking::Circle
Definition: Tracking.h:48
Item
MarbleWindow::icon
void icon(name, size)
MarbleMenuLayout
Definition: harmattan/MarbleMenuLayout.qml:10
MarbleToolIcon
Definition: harmattan/MarbleToolIcon.qml:10
main
Definition: main.qml:12
Page
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:49 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