• 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
  • kml
KmlSimpleFieldTagHandler.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 Patrick Spendrin <ps_ml@gmx.de>
3 
4  This file is part of the KDE project
5 
6  This library is free software you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  aint with this library see the file COPYING.LIB. If not, write to
18  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 */
21 
22 #include "KmlSimpleFieldTagHandler.h"
23 
24 #include "MarbleDebug.h"
25 
26 #include "KmlElementDictionary.h"
27 #include "GeoDataSchema.h"
28 
29 #include "GeoParser.h"
30 
31 namespace Marble
32 {
33 namespace kml
34 {
35 KML_DEFINE_TAG_HANDLER( SimpleField )
36 
37 GeoNode* KmlSimpleFieldTagHandler::parse( GeoParser& parser ) const
38 {
39  Q_ASSERT( parser.isStartElement() && parser.isValidElement( kmlTag_SimpleField ) );
40 
41  GeoStackItem parentItem = parser.parentElement();
42 
43  if( parentItem.represents( kmlTag_Schema ) ) {
44  GeoDataSimpleField simpleField;
45  QString name = parser.attribute( "name" ).trimmed();
46  QString type = parser.attribute( "type" ).trimmed();
47  simpleField.setName( name );
48  GeoDataSimpleField::SimpleFieldType fieldType = resolveType( type );
49  simpleField.setType( fieldType );
50  parentItem.nodeAs<GeoDataSchema>()->addSimpleField( simpleField );
51  return &parentItem.nodeAs<GeoDataSchema>()->simpleField( name );
52  }
53 
54  return 0;
55 }
56 
57 GeoDataSimpleField::SimpleFieldType KmlSimpleFieldTagHandler::resolveType( const QString& type )
58 {
59  GeoDataSimpleField::SimpleFieldType fieldType;
60  if ( type == QString("string") ) {
61  fieldType = GeoDataSimpleField::String;
62  }
63  else if ( type == QString("int") ) {
64  fieldType = GeoDataSimpleField::Int;
65  }
66  else if ( type == QString("unit") ) {
67  fieldType = GeoDataSimpleField::UInt;
68  }
69  else if ( type == QString("short") ) {
70  fieldType = GeoDataSimpleField::Short;
71  }
72  else if ( type == QString("ushort") ) {
73  fieldType = GeoDataSimpleField::UShort;
74  }
75  else if ( type == QString("float") ) {
76  fieldType = GeoDataSimpleField::Float;
77  }
78  else if ( type == QString("double") ) {
79  fieldType = GeoDataSimpleField::Double;
80  }
81  else {
82  fieldType = GeoDataSimpleField::Bool;
83  }
84  return fieldType;
85 }
86 
87 }
88 }
Marble::GeoDataSimpleField::Float
Definition: GeoDataSimpleField.h:43
Marble::GeoDataSimpleField::String
Definition: GeoDataSimpleField.h:38
Marble::GeoDataSimpleField::UInt
Definition: GeoDataSimpleField.h:40
KmlSimpleFieldTagHandler.h
Marble::GeoNode
A shared base class for all classes that are mapped to a specific tag (ie.
Definition: GeoDocument.h:60
GeoParser.h
Marble::GeoDataSimpleField
Definition: GeoDataSimpleField.h:25
Marble::GeoDataSimpleField::Int
Definition: GeoDataSimpleField.h:39
Marble::GeoDataSimpleField::Bool
Definition: GeoDataSimpleField.h:45
MarbleDebug.h
Marble::GeoParser
Definition: GeoParser.h:40
Marble::GeoDataSimpleField::setType
void setType(const SimpleFieldType &type)
Definition: GeoDataSimpleField.cpp:65
Marble::kml::KmlSimpleFieldTagHandler
Definition: KmlSimpleFieldTagHandler.h:36
KmlElementDictionary.h
Marble::GeoDataSimpleField::Double
Definition: GeoDataSimpleField.h:44
Marble::GeoDataSimpleField::Short
Definition: GeoDataSimpleField.h:41
Marble::GeoDataSimpleField::SimpleFieldType
SimpleFieldType
Definition: GeoDataSimpleField.h:37
QString::trimmed
QString trimmed() const
Marble::GeoStackItem
Definition: GeoParser.h:97
KML_DEFINE_TAG_HANDLER
#define KML_DEFINE_TAG_HANDLER(Name)
Definition: KmlElementDictionary.h:242
GeoDataSchema.h
QString
Marble::kml::kmlTag_Schema
const char * kmlTag_Schema
Definition: KmlElementDictionary.cpp:161
Marble::GeoDataSimpleField::setName
void setName(const QString &value)
Definition: GeoDataSimpleField.cpp:75
Marble::kml::kmlTag_SimpleField
const char * kmlTag_SimpleField
Definition: KmlElementDictionary.cpp:169
Marble::GeoDataSchema
Definition: GeoDataSchema.h:30
Marble::GeoDataSimpleField::UShort
Definition: GeoDataSimpleField.h:42
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:40 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