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(GeoTagWriter::QualifiedName(QString::fromLatin1(GeoDataTypes::GeoDataSimpleFieldType),
18 QString::fromLatin1(kml::kmlTag_nameSpaceOgc22)),
19 new KmlSimpleFieldTagWriter);
20
21bool KmlSimpleFieldTagWriter::write(const GeoNode *node, GeoWriter &writer) const
22{
23 const auto simpleField = static_cast<const GeoDataSimpleField *>(node);
24 writer.writeStartElement(QString::fromUtf8(kml::kmlTag_SimpleField));
25 writer.writeAttribute(QStringLiteral("name"), simpleField->name());
26 GeoDataSimpleField::SimpleFieldType simpleFieldType = simpleField->type();
27 QString type = resolveType(simpleFieldType);
28 writer.writeAttribute("type", type);
29
30 QString displayName = simpleField->displayName();
31 writer.writeElement(QStringLiteral("displayName"), displayName);
32
33 writer.writeEndElement();
34
35 return true;
36}
37
38QString KmlSimpleFieldTagWriter::resolveType(GeoDataSimpleField::SimpleFieldType type)
39{
40 switch (type) {
41 case GeoDataSimpleField::String:
42 return QStringLiteral("string");
43 case GeoDataSimpleField::Int:
44 return QStringLiteral("int");
45 case GeoDataSimpleField::UInt:
46 return QStringLiteral("uint");
47 case GeoDataSimpleField::Short:
48 return QStringLiteral("short");
49 case GeoDataSimpleField::UShort:
50 return QStringLiteral("ushort");
51 case GeoDataSimpleField::Float:
52 return QStringLiteral("float");
53 case GeoDataSimpleField::Double:
54 return QStringLiteral("double");
55 case GeoDataSimpleField::Bool:
56 return QStringLiteral("bool");
57 }
58
59 Q_ASSERT(false);
60 return QStringLiteral("string");
61}
62
63}
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.
QString fromLatin1(QByteArrayView str)
QString fromUtf8(QByteArrayView str)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:55:53 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.