Marble

KmlSimpleFieldTagWriter.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2014 Abhinav Gangwar <abhgang@gmail.com>
4//
5
6#include "KmlSimpleFieldTagWriter.h"
7
8#include <QString>
9
10#include "GeoDataTypes.h"
11#include "GeoWriter.h"
12#include "KmlElementDictionary.h"
13
14namespace Marble
15{
16
17static GeoTagWriterRegistrar s_writerSimpleField(
18 GeoTagWriter::QualifiedName( GeoDataTypes::GeoDataSimpleFieldType,
19 kml::kmlTag_nameSpaceOgc22 ),
20 new KmlSimpleFieldTagWriter );
21
22bool KmlSimpleFieldTagWriter::write( const GeoNode *node, GeoWriter& writer ) const
23{
24 const GeoDataSimpleField *simpleField = static_cast<const GeoDataSimpleField*>( node );
25 writer.writeStartElement( kml::kmlTag_SimpleField );
26 writer.writeAttribute( "name", simpleField->name() );
27 GeoDataSimpleField::SimpleFieldType simpleFieldType = simpleField->type();
28 QString type = resolveType( simpleFieldType );
29 writer.writeAttribute( "type", type );
30
31 QString displayName = simpleField->displayName();
32 writer.writeElement( "displayName", displayName );
33
34 writer.writeEndElement();
35
36 return true;
37}
38
39QString KmlSimpleFieldTagWriter::resolveType( GeoDataSimpleField::SimpleFieldType type )
40{
41 switch (type)
42 {
43 case GeoDataSimpleField::String: return "string";
44 case GeoDataSimpleField::Int: return "int";
45 case GeoDataSimpleField::UInt: return "uint";
46 case GeoDataSimpleField::Short: return "short";
47 case GeoDataSimpleField::UShort: return "ushort";
48 case GeoDataSimpleField::Float: return "float";
49 case GeoDataSimpleField::Double: return "double";
50 case GeoDataSimpleField::Bool: return "bool";
51 }
52
53 Q_ASSERT(false);
54 return "string";
55}
56
57}
QPair< QString, QString > QualifiedName
Object Name and Namespace Pair This type is intended to be used in a similar way to.
AKONADI_CALENDAR_EXPORT QString displayName(Akonadi::ETMCalendar *calendar, const Akonadi::Collection &collection)
VehicleSection::Type type(QStringView coachNumber, QStringView coachClassification)
Binds a QML item to a specific geodetic location in screen coordinates.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jun 21 2024 12:00:07 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.