• 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
  • lib
  • marble
  • geodata
  • handlers
  • dgml
DgmlDownloadPolicyTagHandler.cpp
Go to the documentation of this file.
1 /*
2 Copyright 2009, 2010 Jens-Michael Hoffmann <jmho@c-xx.com>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with this library. If not, see <http://www.gnu.org/licenses/>.
16 */
17 
18 #include "DgmlDownloadPolicyTagHandler.h"
19 
20 #include "DgmlAttributeDictionary.h"
21 #include "DgmlElementDictionary.h"
22 #include "GeoParser.h"
23 #include "GeoSceneTiled.h"
24 
25 #include "MarbleGlobal.h"
26 #include "MarbleDebug.h"
27 
28 namespace Marble
29 {
30 namespace dgml
31 {
32 static GeoTagHandlerRegistrar handler( GeoParser::QualifiedName( dgmlTag_DownloadPolicy,
33  dgmlTag_nameSpace20 ),
34  new DgmlDownloadPolicyTagHandler );
35 
36 // Error handling:
37 // Here it is not possible to return an error code or throw an exception
38 // so in case of an error we just ignore the element.
39 
40 GeoNode* DgmlDownloadPolicyTagHandler::parse( GeoParser& parser ) const
41 {
42  // Check whether the tag is valid
43  Q_ASSERT( parser.isStartElement() && parser.isValidElement( dgmlTag_DownloadPolicy ));
44 
45  // Checking for parent item
46  GeoStackItem parentItem = parser.parentElement();
47  if ( !parentItem.represents( dgmlTag_Texture ) && !parentItem.represents( dgmlTag_Vectortile ) ) {
48  qCritical( "Parse error: parent element is not 'texture' or 'vectortile'" );
49  return 0;
50  }
51 
52  // Attribute usage
53  DownloadUsage usage;
54  const QString usageStr = parser.attribute( dgmlAttr_usage ).trimmed();
55  if ( usageStr == "Browse" )
56  usage = DownloadBrowse;
57  else if ( usageStr == "Bulk" )
58  usage = DownloadBulk;
59  else {
60  qCritical( "Parse error: invalid attribute downloadPolicy/@usage" );
61  return 0;
62  }
63 
64  // Attribute maximumConnections
65  const QString maximumConnectionsStr = parser.attribute( dgmlAttr_maximumConnections ).trimmed();
66  bool ok;
67  const int maximumConnections = maximumConnectionsStr.toInt( &ok );
68  if ( !ok ) {
69  qCritical( "Parse error: invalid attribute downloadPolicy/@maximumConnections" );
70  return 0;
71  }
72 
73  parentItem.nodeAs<GeoSceneTiled>()->addDownloadPolicy( usage, maximumConnections );
74  return 0;
75 }
76 
77 }
78 }
DgmlAttributeDictionary.h
Marble::DownloadUsage
DownloadUsage
This enum is used to describe the type of download.
Definition: MarbleGlobal.h:164
Marble::dgml::dgmlTag_DownloadPolicy
const char * dgmlTag_DownloadPolicy
Definition: DgmlElementDictionary.cpp:43
Marble::GeoNode
A shared base class for all classes that are mapped to a specific tag (ie.
Definition: GeoDocument.h:60
GeoParser.h
Marble::GeoParser::parentElement
GeoStackItem parentElement(unsigned int depth=0) const
Definition: GeoParser.cpp:122
Marble::GeoSceneTiled
Definition: GeoSceneTiled.h:43
Marble::DownloadBrowse
Browsing mode, normal operation of Marble, like a web browser.
Definition: MarbleGlobal.h:166
Marble::dgml::dgmlTag_Texture
const char * dgmlTag_Texture
Definition: DgmlElementDictionary.cpp:71
Marble::dgml::handler
static GeoTagHandlerRegistrar handler(GeoParser::QualifiedName(dgmlTag_DownloadPolicy, dgmlTag_nameSpace20), new DgmlDownloadPolicyTagHandler)
MarbleDebug.h
Marble::GeoParser
Definition: GeoParser.h:40
Marble::dgml::dgmlAttr_maximumConnections
const char * dgmlAttr_maximumConnections
Definition: DgmlAttributeDictionary.cpp:51
Marble::GeoParser::attribute
QString attribute(const char *attributeName) const
Definition: GeoParser.cpp:200
QString::toInt
int toInt(bool *ok, int base) const
QString::trimmed
QString trimmed() const
Marble::dgml::dgmlTag_nameSpace20
const char * dgmlTag_nameSpace20
Definition: DgmlElementDictionary.cpp:31
DgmlDownloadPolicyTagHandler.h
DgmlElementDictionary.h
Marble::GeoStackItem
Definition: GeoParser.h:97
QString
MarbleGlobal.h
Marble::dgml::dgmlAttr_usage
const char * dgmlAttr_usage
Definition: DgmlAttributeDictionary.cpp:70
Marble::GeoParser::isValidElement
virtual bool isValidElement(const QString &tagName) const
Definition: GeoParser.cpp:117
Marble::dgml::dgmlTag_Vectortile
const char * dgmlTag_Vectortile
Definition: DgmlElementDictionary.cpp:76
QXmlStreamReader::isStartElement
bool isStartElement() const
Marble::dgml::DgmlDownloadPolicyTagHandler::parse
virtual GeoNode * parse(GeoParser &) const
Definition: DgmlDownloadPolicyTagHandler.cpp:40
GeoSceneTiled.h
Marble::GeoParser::QualifiedName
QPair< QString, QString > QualifiedName
Definition: GeoParser.h:43
Marble::DownloadBulk
Bulk download, for example "File/Download region".
Definition: MarbleGlobal.h:165
usage
void usage(const QString &app)
Definition: merge_ts_po.cpp:16
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:38 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