• 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
OfflineDataPage.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 QtMultimediaKit 1.1
11 import com.nokia.meego 1.0
12 import org.kde.edu.marble 0.11
13 
14 Page {
15  id: offlineDataPage
16 
17  tools: ToolBarLayout {
18  MarbleToolIcon {
19  iconSource: main.icon( "actions/go-previous-view", 48 );
20  onClicked: pageStack.pop()
21  }
22  }
23 
24  OfflineDataModel {
25  id: offlineDataModel
26  }
27 
28  Row {
29  id: monavStatus
30  anchors.left: parent.left
31  anchors.right: parent.right
32  anchors.top: parent.top
33  anchors.topMargin: 10
34 
35  visible: !Marble.canExecute("monav-daemon") && !Marble.canExecute("MoNavD")
36 
37  MarbleToolIcon {
38  id: statusIcon
39  anchors.verticalCenter: parent.verticalCenter
40  iconSource: main.icon( "status/task-attention", 48 );
41  }
42 
43  Label {
44  anchors.verticalCenter: parent.verticalCenter
45  /*readonly*/ property string monavStoreUrl: "http://store.ovi.mobi/content/250322"
46  width: parent.width - statusIcon.width
47  text: "Please install Monav Routing Daemon (free) to enable offline routing. <a href=\"" + monavStoreUrl + "\">Install now</a>."
48  wrapMode: Text.Wrap
49 
50  onLinkActivated: Qt.openUrlExternally(link)
51  }
52  }
53 
54  SearchField {
55  id: search
56  anchors.top: monavStatus.visible ? monavStatus.bottom : parent.top
57  anchors.topMargin: 5
58  width: parent.width
59  onSearch: {
60  offlineDataModel.setFilterFixedString(term)
61  }
62  }
63 
64  ButtonRow {
65  id: filterRow
66  anchors.left: parent.left
67  anchors.right: parent.right
68  anchors.top: search.bottom
69  anchors.topMargin: 10
70  anchors.margins: 5
71  checkedButton: noFilter
72 
73  Button {
74  id: noFilter
75  text: "All"
76  }
77 
78  Button {
79  id: motorcarFilter
80  iconSource: "qrc:/icons/routing-motorcar.svg";
81  width: 120
82  }
83 
84  Button {
85  id: bikeFilter
86  iconSource: "qrc:/icons/routing-bike.svg";
87  width: 80
88  }
89 
90  Button {
91  id: pedestrianFilter
92  iconSource: "qrc:/icons/routing-pedestrian.svg";
93  width: 60
94  }
95 
96  onCheckedButtonChanged: {
97  offlineDataModel.setVehicleTypeFilter(
98  (filterRow.checkedButton === noFilter ? OfflineDataModel.Any : OfflineDataModel.None) |
99  (filterRow.checkedButton === motorcarFilter ? OfflineDataModel.Motorcar : OfflineDataModel.None) |
100  (filterRow.checkedButton === bikeFilter ? OfflineDataModel.Bicycle : OfflineDataModel.None) |
101  (filterRow.checkedButton === pedestrianFilter ? OfflineDataModel.Pedestrian : OfflineDataModel.None) )
102  }
103  }
104 
105 
106  ListView {
107  id: dataView
108  model: offlineDataModel
109  anchors.left: parent.left
110  anchors.right: parent.right
111  anchors.top: filterRow.bottom
112  anchors.bottom: parent.bottom
113  anchors.topMargin: 10
114  anchors.margins: 5
115  delegate: dataDelegate
116  highlight: Rectangle { radius: 5; color: "lightsteelblue" }
117  highlightMoveDuration: 200
118  spacing: 10
119  section.property: "continent"
120  section.delegate: sectionDelegate
121  currentIndex: -1
122  clip: true
123  }
124 
125  ScrollDecorator {
126  flickableItem: dataView
127  }
128 
129  Component {
130  id: sectionDelegate
131 
132  Rectangle {
133  color: Qt.rgba(0/255, 102/255, 255/255, 1)
134  width: dataView.width
135  height: childrenRect.height
136  radius: 5
137 
138  Label {
139  x: 5
140  width: parent.width
141  text: section
142  color: Qt.rgba(238/255, 238/255, 236/255, 1)
143  }
144  }
145  }
146 
147  Component {
148  id: dataDelegate
149 
150  Item {
151  id: delegateRoot
152  width: parent.width
153  height: row.height
154  property bool installing: transitioning
155  property bool selected: ListView.view.currentIndex === idx
156  property bool showDetails: selected || installing
157  property int idx: index
158 
159  Row {
160  id: row
161  spacing: 10
162 
163  Image {
164  id: previewIcon
165  anchors.verticalCenter: parent.verticalCenter
166  width: 45
167  smooth: true
168  fillMode: Image.PreserveAspectFit
169  source: name.search(/Bicycle/) !== -1 ? "qrc:/icons/routing-bike.svg" : (name.search(/Pedestrian/) !== -1 ? "qrc:/icons/routing-pedestrian.svg" : "qrc:/icons/routing-motorcar.svg")
170  }
171 
172  Item {
173  id: textItem
174  width: delegateRoot.width - row.spacing - previewIcon.width - 10
175  height: nameLabel.height + (delegateRoot.showDetails ? versionLabel.height + installButton.height + 15 : 0)
176 
177  Label {
178  id: nameLabel
179  width: parent.width
180  text: display
181  font.bold: upgradable
182  }
183 
184  Label {
185  id: versionLabel
186  width: parent.width
187  anchors.top: nameLabel.bottom
188  anchors.topMargin: 5
189  visible: delegateRoot.showDetails
190  property string localVersion: "<font size=\"-1\">Version installed: " + installedreleasedate + "</font>"
191  property string displaySize: delegateRoot.showDetails && !settings.workOffline ? " (" + formatSize() + ")" : ""
192  text: "<font size=\"-1\">Version available: " + releasedate + displaySize + "</font>" + (installed ? "<br />" + localVersion : "")
193 
194  function formatSize() {
195  var length = size
196 
197  if (length<0) {
198  return ""
199  }
200 
201  var unit = 0
202  for (var i=0; i<9 && length >= 1000; ++i) {
203  length /= 1000.0
204  ++unit
205  }
206 
207  switch (unit) {
208  case 0: return length.toFixed(1) + " byte"
209  case 1: return length.toFixed(1) + " kB"
210  case 2: return length.toFixed(1) + " MB"
211  case 3: return length.toFixed(1) + " GB"
212  case 4: return length.toFixed(1) + " TB"
213  case 5: return length.toFixed(1) + " PB"
214  case 6: return length.toFixed(1) + " EB"
215  case 7: return length.toFixed(1) + " ZB"
216  case 8: return length.toFixed(1) + " YB"
217  }
218  }
219  }
220 
221  ProgressBar {
222  id: progressBar
223  visible: delegateRoot.installing
224  anchors.top: versionLabel.bottom
225  width: parent.width - 50
226  anchors.margins: 20
227  minimumValue: 0.0
228  maximumValue: 1.0
229  indeterminate: true
230 
231  Connections {
232  target: offlineDataModel
233  onInstallationProgressed: {
234  if (newstuffindex === delegateRoot.idx) {
235  progressBar.indeterminate = false
236  progressBar.value = progress
237  }
238  }
239  onInstallationFinished: {
240  if (newstuffindex === delegateRoot.idx) {
241  delegateRoot.installing = false
242  }
243  }
244  onInstallationFailed: {
245  if (newstuffindex === delegateRoot.idx) {
246  delegateRoot.installing = false
247  }
248  }
249  onUninstallationFinished: {
250  if (newstuffindex === delegateRoot.idx) {
251  delegateRoot.installing = false
252  }
253  }
254  }
255  }
256 
257  MouseArea {
258  anchors.fill: parent
259  onClicked: delegateRoot.ListView.view.currentIndex = delegateRoot.idx
260  }
261 
262  ToolButton {
263  anchors.left: progressBar.right
264  anchors.leftMargin: 5
265  anchors.verticalCenter: progressBar.verticalCenter
266  visible: delegateRoot.installing
267  width: 40
268  flat: true
269  iconSource: main.icon( "actions/dialog-cancel", 32 );
270  onClicked: {
271  progressBar.indeterminate = true
272  offlineDataModel.cancel(delegateRoot.idx)
273  }
274  }
275 
276  Button {
277  id: installButton
278  text: installed && upgradable ? "Upgrade" : "Install"
279  enabled: !installed || upgradable
280  anchors.top: versionLabel.bottom
281  anchors.left: parent.left
282  anchors.margins: 5
283  width: parent.width / 2 - 5
284  visible: delegateRoot.selected && !delegateRoot.installing
285  onClicked: {
286  progressBar.indeterminate = true
287  delegateRoot.installing = true
288  offlineDataModel.install(delegateRoot.idx)
289  }
290  }
291 
292  Button {
293  text: "Remove"
294  anchors.top: versionLabel.bottom
295  anchors.right: parent.right
296  anchors.left: installButton.right
297  anchors.margins: 5
298  width: parent.width / 2 - 5
299  visible: delegateRoot.selected && !delegateRoot.installing
300  enabled: installed
301  onClicked: {
302  progressBar.indeterminate = true
303  delegateRoot.installing = true
304  offlineDataModel.uninstall(delegateRoot.idx)
305  }
306  }
307  }
308  }
309  }
310  }
311 }
search
Definition: google-search.qml:12
Button
Definition: cloud-sync/Button.qml:11
OfflineDataModel::Pedestrian
Definition: OfflineDataModel.h:31
SearchField
Definition: SearchField.qml:14
Rectangle
Marble::radius
static qreal radius(qreal zoom)
Definition: thumbnailer.cpp:99
OfflineDataModel::None
Definition: OfflineDataModel.h:28
OfflineDataModel::Bicycle
Definition: OfflineDataModel.h:30
MarbleWindow::icon
void icon(name, size)
MarbleToolIcon
Definition: harmattan/MarbleToolIcon.qml:10
main
Definition: examples/cpp/marbleQuick2/main.qml:3
OfflineDataModel::Any
Definition: OfflineDataModel.h:32
OfflineDataModel::Motorcar
Definition: OfflineDataModel.h:29
OfflineDataModel
Definition: OfflineDataModel.h:18
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