• 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
MapThemePage.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: preferencesPage
16 
17  tools: ToolBarLayout {
18  MarbleToolIcon {
19  iconSource: main.icon( "actions/go-previous-view", 48 );
20  onClicked: pageStack.pop()
21  }
22  }
23 
24  NewstuffModel {
25  id: themeInstallModel
26  provider: "http://edu.kde.org/marble/newstuff/maps-4.5.xml"
27  registryFile: "~/.kde/share/apps/knewstuff3/marble.knsregistry"
28  }
29 
30  ListView {
31  id: themeView
32  anchors.fill: parent
33  anchors.margins: 5
34  model: themeInstallModel
35  delegate: themeDelegate
36  highlight: Rectangle { radius: 5; color: "lightsteelblue" }
37  highlightMoveDuration: 200
38  spacing: 10
39  currentIndex: -1
40  }
41 
42  ScrollDecorator {
43  flickableItem: themeView
44  }
45 
46  Component {
47  id: themeDelegate
48 
49  Item {
50  id: delegateRoot
51  width: parent.width
52  height: row.height
53  property bool installing: transitioning
54  property bool selected: ListView.view.currentIndex === idx
55  property bool showDetails: selected || installing
56  property int idx: index
57 
58  Row {
59  id: row
60  spacing: 10
61 
62  Item {
63  width: previewIcon.width
64  height: Math.max(previewIcon.height + (delegateRoot.showDetails ? versionLabel.height + 5 : 0), textItem.height)
65 
66  Image {
67  id: previewIcon
68  anchors.top: parent.top
69  source: settings.workOffline ? "" : preview
70  width: 136
71  height: 136
72 
73  Image {
74  id: fallbackIcon
75  anchors.centerIn: parent
76  source: "qrc:/icons/activity-virtualglobe.png"
77  width: 128
78  height: 128
79  opacity: (previewIcon.status == Image.Loading || settings.workOffline) ? 1.0 : 0.0
80  Behavior on opacity { NumberAnimation {} }
81  }
82  }
83 
84  Label {
85  id: versionLabel
86  width: parent.width
87  anchors.top: previewIcon.bottom
88  anchors.topMargin: 5
89  visible: delegateRoot.showDetails
90  text: delegateRoot.showDetails ? "<p><font size=\"-1\">Version: " + version + "<br />" + releasedate + "<br />" + formatSize() + "</font></p>" : ""
91 
92  function formatSize() {
93  if (settings.workOffline) {
94  return ""
95  }
96 
97  var length = size
98 
99  if (length<0) {
100  return ""
101  }
102 
103  var unit = 0
104  for (var i=0; i<9 && length >= 1000; ++i) {
105  length /= 1000.0
106  ++unit
107  }
108 
109  switch (unit) {
110  case 0: return length.toFixed(1) + " byte"
111  case 1: return length.toFixed(1) + " kB"
112  case 2: return length.toFixed(1) + " MB"
113  case 3: return length.toFixed(1) + " GB"
114  case 4: return length.toFixed(1) + " TB"
115  case 5: return length.toFixed(1) + " PB"
116  case 6: return length.toFixed(1) + " EB"
117  case 7: return length.toFixed(1) + " ZB"
118  case 8: return length.toFixed(1) + " YB"
119  }
120  }
121  }
122  }
123 
124  Item {
125  id: textItem
126  width: delegateRoot.width - row.spacing - previewIcon.width - 10
127  height: nameLabel.height + summaryLabel.height + (delegateRoot.showDetails ? installButton.height + 10 : 0)
128 
129  Label {
130  id: nameLabel
131  width: parent.width
132  text: display
133  font.bold: upgradable
134  }
135 
136  Label {
137  id: summaryLabel
138  width: parent.width
139  anchors.top: nameLabel.bottom
140  property string details: "<p><font size=\"-1\">Author: " + author + "</font></p><p><font size=\"-1\">License: " + license + "</font></p>"
141  text: "<p><font size=\"-1\">" + summary + (delegateRoot.showDetails ? details : "") + "</font></p>"
142  }
143 
144  ProgressBar {
145  id: progressBar
146  visible: delegateRoot.installing
147  anchors.top: summaryLabel.bottom
148  width: parent.width - 50
149  anchors.margins: 20
150  minimumValue: 0.0
151  maximumValue: 1.0
152  indeterminate: true
153 
154  Connections {
155  target: themeInstallModel
156  onInstallationProgressed: {
157  if (newstuffindex === delegateRoot.idx) {
158  progressBar.indeterminate = false
159  progressBar.value = progress
160  }
161  }
162  onInstallationFinished: {
163  if (newstuffindex === delegateRoot.idx) {
164  delegateRoot.installing = false
165  }
166  }
167  onInstallationFailed: {
168  if (newstuffindex === delegateRoot.idx) {
169  delegateRoot.installing = false
170  }
171  }
172  onUninstallationFinished: {
173  if (newstuffindex === delegateRoot.idx) {
174  delegateRoot.installing = false
175  }
176  }
177  }
178  }
179 
180  MouseArea {
181  anchors.fill: parent
182  onClicked: delegateRoot.ListView.view.currentIndex = delegateRoot.idx
183  }
184 
185  ToolButton {
186  anchors.left: progressBar.right
187  anchors.leftMargin: 5
188  anchors.verticalCenter: progressBar.verticalCenter
189  visible: delegateRoot.installing
190  width: 40
191  flat: true
192  iconSource: main.icon( "actions/dialog-cancel", 32 );
193  onClicked: {
194  progressBar.indeterminate = true
195  themeInstallModel.cancel(delegateRoot.idx)
196  }
197  }
198 
199  Button {
200  id: installButton
201  text: installed && upgradable ? "Upgrade" : "Install"
202  enabled: !installed || upgradable
203  anchors.top: summaryLabel.bottom
204  anchors.left: parent.left
205  anchors.margins: 5
206  width: parent.width / 2 - 5
207  visible: delegateRoot.selected && !delegateRoot.installing
208  onClicked: {
209  progressBar.indeterminate = true
210  delegateRoot.installing = true
211  themeInstallModel.install(delegateRoot.idx)
212  }
213  }
214 
215  Button {
216  text: "Remove"
217  anchors.top: summaryLabel.bottom
218  anchors.right: parent.right
219  anchors.left: installButton.right
220  anchors.margins: 5
221  width: parent.width / 2 - 5
222  visible: delegateRoot.selected && !delegateRoot.installing
223  enabled: installed
224  onClicked: {
225  progressBar.indeterminate = true
226  delegateRoot.installing = true
227  themeInstallModel.uninstall(delegateRoot.idx)
228  }
229  }
230  }
231  }
232  }
233  }
234 }
Button
Definition: cloud-sync/Button.qml:11
ToolButton
Rectangle
Item
MarbleWindow::icon
void icon(name, size)
MarbleToolIcon
Definition: harmattan/MarbleToolIcon.qml:10
main
Definition: main.qml:12
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:51 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