Marble

KmlPlaylistTagWriter.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 "KmlPlaylistTagWriter.h"
7
8#include "GeoDataAnimatedUpdate.h"
9#include "GeoDataFlyTo.h"
10#include "GeoDataPlaylist.h"
11#include "GeoDataTypes.h"
12#include "GeoDataSoundCue.h"
13#include "GeoDataWait.h"
14#include "GeoWriter.h"
15#include "KmlElementDictionary.h"
16#include "KmlObjectTagWriter.h"
17
18namespace Marble
19{
20
21static GeoTagWriterRegistrar s_writerPlaylist(
22 GeoTagWriter::QualifiedName( GeoDataTypes::GeoDataPlaylistType,
23 kml::kmlTag_nameSpaceOgc22 ),
24 new KmlPlaylistTagWriter );
25
26bool KmlPlaylistTagWriter::write( const GeoNode *node, GeoWriter& writer ) const
27{
28 const GeoDataPlaylist *playlist = static_cast<const GeoDataPlaylist*>( node );
29
30 writer.writeStartElement( kml::kmlTag_nameSpaceGx22, kml::kmlTag_Playlist );
31
32 for ( int i = 0; i < playlist->size(); i++ ) {
33 writeTourPrimitive( playlist->primitive( i ), writer );
34 }
35
36 writer.writeEndElement();
37
38 return true;
39}
40
41void KmlPlaylistTagWriter::writeTourPrimitive(const GeoDataTourPrimitive *primitive, GeoWriter &writer)
42{
43
44 if (const auto tourControl = geodata_cast<GeoDataTourControl>(primitive)) {
45 writeTourControl(*tourControl, writer);
46 }
47 else if (const auto wait = geodata_cast<GeoDataWait>(primitive)) {
48 writeWait(*wait, writer);
49 }
50 else if (const auto flyTo = geodata_cast<GeoDataFlyTo>(primitive)) {
51 writeElement(flyTo, writer);
52 }
53 else if (const auto soundCue = geodata_cast<GeoDataSoundCue>(primitive)) {
54 writeSoundCue(*soundCue, writer);
55 }
56 else if (const auto animatedUpdate = geodata_cast<GeoDataAnimatedUpdate>(primitive)) {
57 writeElement(animatedUpdate, writer);
58 }
59}
60
61void KmlPlaylistTagWriter::writeTourControl(const GeoDataTourControl &tourControl, GeoWriter &writer)
62{
63 writer.writeStartElement( kml::kmlTag_nameSpaceGx22, kml::kmlTag_TourControl );
64 KmlObjectTagWriter::writeIdentifiers(writer, &tourControl);
65
66 writer.writeElement(kml::kmlTag_nameSpaceGx22, kml::kmlTag_playMode, playModeToString(tourControl.playMode()));
67
68 writer.writeEndElement();
69}
70
71void KmlPlaylistTagWriter::writeWait(const GeoDataWait &wait, GeoWriter &writer)
72{
73 writer.writeStartElement( kml::kmlTag_nameSpaceGx22, kml::kmlTag_Wait );
74 KmlObjectTagWriter::writeIdentifiers(writer, &wait);
75
76 writer.writeElement(kml::kmlTag_nameSpaceGx22, kml::kmlTag_duration, QString::number(wait.duration()));
77
78 writer.writeEndElement();
79}
80
81void KmlPlaylistTagWriter::writeSoundCue(const GeoDataSoundCue &cue, GeoWriter &writer)
82{
83 writer.writeStartElement( kml::kmlTag_nameSpaceGx22, kml::kmlTag_SoundCue );
84 KmlObjectTagWriter::writeIdentifiers(writer, &cue);
85
86 writer.writeElement(kml::kmlTag_href, cue.href());
87 writer.writeElement( kml::kmlTag_nameSpaceGx22, kml::kmlTag_delayedStart,
88 QString::number(cue.delayedStart()));
89
90 writer.writeEndElement();
91}
92
93QString KmlPlaylistTagWriter::playModeToString( GeoDataTourControl::PlayMode playMode )
94{
95 switch (playMode)
96 {
97 case GeoDataTourControl::Play: return "play";
98 case GeoDataTourControl::Pause: return "pause";
99 default: return "";
100 }
101}
102
103}
QPair< QString, QString > QualifiedName
Object Name and Namespace Pair This type is intended to be used in a similar way to.
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 14 2024 11:54:17 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.