Marble

KmlLinkTagWriter.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2013 Adrian Draghici <draghici.adrian.b@gmail.com>
4//
5
6#include "KmlLinkTagWriter.h"
7
8#include "GeoDataTypes.h"
9#include "GeoWriter.h"
10#include "KmlElementDictionary.h"
11#include "KmlObjectTagWriter.h"
12
13namespace Marble
14{
15
16static GeoTagWriterRegistrar s_writerLink(GeoTagWriter::QualifiedName(QString::fromLatin1(GeoDataTypes::GeoDataLinkType),
17 QString::fromLatin1(kml::kmlTag_nameSpaceOgc22)),
18 new KmlLinkTagWriter);
19
20bool KmlLinkTagWriter::write(const GeoNode *node, GeoWriter &writer) const
21{
22 const auto link = static_cast<const GeoDataLink *>(node);
23
24 writer.writeStartElement(QString::fromUtf8(kml::kmlTag_Link));
25 KmlObjectTagWriter::writeIdentifiers(writer, link);
26
27 writer.writeElement(QString::fromLatin1(kml::kmlTag_href), link->href());
28
29 QString const refreshMode = refreshModeToString(link->refreshMode());
30 writer.writeOptionalElement(QLatin1String(kml::kmlTag_refreshMode), refreshMode, QStringLiteral("onChange"));
31
32 writer.writeElement(QString::fromLatin1(kml::kmlTag_refreshInterval), QString::number(link->refreshInterval()));
33
34 QString const viewRefreshMode = viewRefreshModeToString(link->viewRefreshMode());
35 writer.writeOptionalElement(QLatin1String(kml::kmlTag_viewRefreshMode), viewRefreshMode, QStringLiteral("never"));
36
37 writer.writeElement(QString::fromLatin1(kml::kmlTag_viewRefreshTime), QString::number(link->viewRefreshTime()));
38
39 writer.writeElement(QString::fromLatin1(kml::kmlTag_viewBoundScale), QString::number(link->viewBoundScale()));
40
41 writer.writeOptionalElement(QLatin1String(kml::kmlTag_viewFormat), link->viewFormat());
42
43 writer.writeOptionalElement(QLatin1String(kml::kmlTag_httpQuery), link->httpQuery());
44
45 writer.writeEndElement();
46
47 return true;
48}
49
50QString KmlLinkTagWriter::refreshModeToString(GeoDataLink::RefreshMode refreshMode)
51{
52 switch (refreshMode) {
53 case GeoDataLink::OnInterval:
54 return QStringLiteral("onInterval");
55 case GeoDataLink::OnExpire:
56 return QStringLiteral("onExpire");
57 default:
58 return QStringLiteral("onChange");
59 }
60}
61
62QString KmlLinkTagWriter::viewRefreshModeToString(GeoDataLink::ViewRefreshMode viewRefreshMode)
63{
64 switch (viewRefreshMode) {
65 case GeoDataLink::OnStop:
66 return QStringLiteral("onStop");
67 case GeoDataLink::OnRequest:
68 return QStringLiteral("onRequest");
69 case GeoDataLink::OnRegion:
70 return QStringLiteral("onRegion");
71 default:
72 return QStringLiteral("never");
73 }
74}
75
76}
QPair< QString, QString > QualifiedName
Object Name and Namespace Pair This type is intended to be used in a similar way to.
KIOCORE_EXPORT CopyJob * link(const QList< QUrl > &src, const QUrl &destDir, JobFlags flags=DefaultFlags)
Binds a QML item to a specific geodetic location in screen coordinates.
QString fromLatin1(QByteArrayView str)
QString fromUtf8(QByteArrayView str)
QString number(double n, char format, int precision)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:52:13 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.