• 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
Search.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 
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 geocaching activity.
17  */
18 Page {
19  id: searchActivityPage
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 
30  ToolButton {
31  id: minimizeButton
32  checkable: true
33  checked: true
34  width: 60
35  flat: true
36  iconSource: main.icon( "actions/go-up", 48 );
37  }
38 
39  Item {}
40  }
41 
42  Rectangle {
43  id: searchResultView
44 
45  property bool minimized: !minimizeButton.checked
46  visible: !minimized
47 
48  anchors.bottom: searchActivityPage.bottom
49  anchors.left: searchActivityPage.left
50  width: searchActivityPage.horizontal ? (minimized ? 0 : searchActivityPage.width / 2) : searchActivityPage.width
51  height: searchActivityPage.horizontal ? searchActivityPage.height : (minimized ? 0 : searchActivityPage.height / 2)
52 
53  Behavior on height {
54  enabled: !searchActivityPage.horizontal;
55  NumberAnimation {
56  easing.type: Easing.InOutQuad;
57  duration: 250
58  }
59  }
60 
61  radius: 10
62  color: "#f7f7f7"
63  border.width: 2
64  border.color: "darkgray"
65  z: 10
66  opacity: 0.9
67  property string searchTerm: ""
68 
69  SearchField {
70  id: searchField
71  anchors.top: parent.top
72  anchors.left: parent.left
73  anchors.right: parent.right
74  anchors.margins: 10
75  onSearch: {
76  searchResultView.searchTerm = term
77  searchField.busy = true
78  marbleWidget.find( term )
79  searchResultListView.model = marbleWidget.search.searchResultModel()
80  }
81 
82  Component.onCompleted: {
83  marbleWidget.search.searchFinished.connect( searchFinished )
84  }
85 
86  function searchFinished() {
87  searchField.busy = false
88  }
89  }
90 
91  Label {
92  id: searchResultDescription
93  wrapMode: Text.WrapAtWordBoundaryOrAnywhere
94  anchors.top: searchField.bottom
95  anchors.left: parent.left
96  anchors.right: parent.right
97  anchors.margins: 10
98 
99  text: "<p>Example search terms<ul><li>London</li><li>Baker Street, London</li><li>Baker Street 221b, London</li><li>Restaurant, London</li></ul></p>"
100  visible: searchResultView.searchTerm === "" && searchResultListView.count === 0
101  }
102 
103  ListView {
104  id: searchResultListView
105  property int count: model === undefined ? 0 : model.count
106 
107  anchors.top: searchField.bottom
108  anchors.left: parent.left
109  anchors.right: parent.right
110  anchors.bottom: parent.bottom
111  anchors.margins: 10
112  model: marbleWidget.search.searchResultModel()
113  delegate: searchResultDelegate
114  highlight: Rectangle { color: "lightgray"; radius: 5 }
115  focus: true
116  clip: true
117  }
118 
119  ScrollDecorator {
120  flickableItem: searchResultListView
121  }
122  }
123 
124 
125  Item {
126  id: mapContainer
127  clip: true
128 
129  anchors.left: searchActivityPage.horizontal ? searchResultView.right : searchActivityPage.left
130  anchors.bottom: searchActivityPage.horizontal ? searchActivityPage.bottom : searchResultView.top
131  anchors.right: searchActivityPage.right
132  anchors.top: searchActivityPage.top
133 
134  function embedMarbleWidget() {
135  marbleWidget.parent = mapContainer
136  settings.projection = "Mercator"
137  var plugins = settings.defaultRenderPlugins
138  settings.removeElementsFromArray(plugins, ["coordinate-grid", "sun", "stars", "compass"])
139  settings.activeRenderPlugins = plugins
140  settings.mapTheme = settings.streetMapTheme
141  settings.gpsTracking = false
142  settings.showPositionIndicator = true
143  marbleWidget.tracking.positionMarkerType = Tracking.Circle
144  settings.showTrack = false
145  marbleWidget.visible = true
146  }
147 
148  Component.onDestruction: {
149  if ( marbleWidget.parent === mapContainer ) {
150  marbleWidget.parent = null
151  marbleWidget.visible = false
152  }
153  }
154  }
155 
156  Component {
157  id: searchResultDelegate
158 
159  Item {
160  id: searchResultItem
161  width: parent.width - 20
162  height: column.height + 10
163  x: 10
164  y: 5
165  property bool detailed: ListView.isCurrentItem
166 
167  Column {
168  id: column
169 
170  Row {
171  spacing: 5
172 
173  Label {
174  id: searchResultText
175  anchors.verticalCenter: parent.verticalCenter
176  text: "<font size=\"-1\">" + (index+1) + ". " + display + "</font>"
177  width: searchResultItem.width - bookmarkButton.width - parent.spacing - 10
178  wrapMode: searchResultItem.detailed ? Text.WrapAtWordBoundaryOrAnywhere : Text.NoWrap
179  clip: true
180 
181  MouseArea {
182  anchors.fill: parent
183  onClicked: {
184  searchResultListView.currentIndex = index
185  marbleWidget.centerOn( longitude, latitude )
186  }
187  }
188  }
189 
190  ToolButton {
191  id: bookmarkButton
192  anchors.verticalCenter: parent.verticalCenter
193  flat: true
194  height: 38
195  width: 38
196  property bool isBookmark: marbleWidget.bookmarks.isBookmark(longitude,latitude)
197  iconSource: isBookmark ? "qrc:/icons/bookmark.png" : "qrc:/icons/bookmark-disabled.png"
198  visible: searchResultItem.detailed
199  onClicked: {
200  if ( isBookmark ) {
201  marbleWidget.bookmarks.removeBookmark(longitude,latitude)
202  } else {
203  marbleWidget.bookmarks.addBookmark(longitude,latitude, display, "Default")
204  }
205  isBookmark = marbleWidget.bookmarks.isBookmark(longitude,latitude)
206  }
207  }
208  }
209 
210  Row {
211  spacing: 5
212  visible: searchResultItem.detailed
213 
214  Button {
215  id: carButton
216  width: 120
217  iconSource: "qrc:/icons/routing-motorcar.svg"
218  onClicked: {
219  marbleWidget.routing.routingProfile = "Motorcar"
220  searchActivityPage.startRouting(longitude, latitude)
221  }
222  }
223 
224  Button {
225  id: bikeButton
226  width: 80
227  iconSource: "qrc:/icons/routing-bike.svg"
228  onClicked: {
229  marbleWidget.routing.routingProfile = "Bicycle"
230  searchActivityPage.startRouting(longitude, latitude)
231  }
232  }
233 
234  Button {
235  id: pedButton
236  width: 60
237  iconSource: "qrc:/icons/routing-pedestrian.svg"
238  onClicked: {
239  marbleWidget.routing.routingProfile = "Pedestrian"
240  searchActivityPage.startRouting(longitude, latitude)
241  }
242  }
243  }
244  }
245  }
246  }
247 
248  onStatusChanged: {
249  if ( status === PageStatus.Activating ) {
250  mapContainer.embedMarbleWidget()
251  }
252  }
253 
254  function startRouting(longitude, latitude)
255  {
256  settings.gpsTracking = true
257  marbleWidget.routing.clearRoute()
258  marbleWidget.routing.setVia( 0, marbleWidget.tracking.lastKnownPosition.longitude, marbleWidget.tracking.lastKnownPosition.latitude )
259  marbleWidget.routing.setVia( 1, longitude, latitude )
260  openActivity( "Routing" )
261  }
262 }
Tracking
Definition: Tracking.qml:16
Button
Definition: cloud-sync/Button.qml:11
SearchField
Definition: SearchField.qml:14
Rectangle
Marble::radius
static qreal radius(qreal zoom)
Definition: thumbnailer.cpp:99
Tracking::Circle
Definition: Tracking.h:48
MarbleWindow::icon
void icon(name, size)
MarbleToolIcon
Definition: harmattan/MarbleToolIcon.qml:10
MarbleWindow::showNavigation
void showNavigation()
main
Definition: examples/cpp/marbleQuick2/main.qml:3
SearchField::busy
bool busy
Definition: SearchField.qml:19
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