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(
17 GeoTagWriter::QualifiedName( GeoDataTypes::GeoDataLinkType,
18 kml::kmlTag_nameSpaceOgc22 ),
19 new KmlLinkTagWriter );
20
21bool KmlLinkTagWriter::write( const GeoNode *node, GeoWriter& writer ) const
22{
23 const GeoDataLink *link = static_cast<const GeoDataLink*>( node );
24
25 writer.writeStartElement( kml::kmlTag_Link );
26 KmlObjectTagWriter::writeIdentifiers( writer, link );
27
28 writer.writeElement( kml::kmlTag_href, link->href() );
29
30 QString const refreshMode = refreshModeToString( link->refreshMode() );
31 writer.writeOptionalElement( kml::kmlTag_refreshMode, refreshMode, "onChange" );
32
33 writer.writeElement( kml::kmlTag_refreshInterval, QString::number( link->refreshInterval() ) );
34
35 QString const viewRefreshMode = viewRefreshModeToString( link->viewRefreshMode() );
36 writer.writeOptionalElement( kml::kmlTag_viewRefreshMode, viewRefreshMode, "never" );
37
38 writer.writeElement( kml::kmlTag_viewRefreshTime, QString::number( link->viewRefreshTime() ) );
39
40 writer.writeElement( kml::kmlTag_viewBoundScale, QString::number( link->viewBoundScale() ) );
41
42 writer.writeOptionalElement( kml::kmlTag_viewFormat, link->viewFormat());
43
44 writer.writeOptionalElement( kml::kmlTag_httpQuery, link->httpQuery());
45
46 writer.writeEndElement();
47
48 return true;
49}
50
51QString KmlLinkTagWriter::refreshModeToString( GeoDataLink::RefreshMode refreshMode)
52{
53 switch (refreshMode)
54 {
55 case GeoDataLink::OnInterval: return "onInterval";
56 case GeoDataLink::OnExpire: return "onExpire";
57 default: return "onChange";
58 }
59}
60
61QString KmlLinkTagWriter::viewRefreshModeToString( GeoDataLink::ViewRefreshMode viewRefreshMode)
62{
63 switch (viewRefreshMode)
64 {
65 case GeoDataLink::OnStop: return "onStop";
66 case GeoDataLink::OnRequest: return "onRequest";
67 case GeoDataLink::OnRegion: return "onRegion";
68 default: return "never";
69 }
70}
71
72}
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 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 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.