• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdeedu API Reference
  • KDE Home
  • Contact Us
 

marble

  • sources
  • kde-4.14
  • kdeedu
  • marble
  • src
  • lib
  • marble
  • geodata
  • writers
  • kml
KmlPlaylistTagWriter.cpp
Go to the documentation of this file.
1 //
2 // This file is part of the Marble Virtual Globe.
3 //
4 // This program is free software licensed under the GNU LGPL. You can
5 // find a copy of this license in LICENSE.txt in the top directory of
6 // the source code.
7 //
8 // Copyright 2013 Adrian Draghici <draghici.adrian.b@gmail.com>
9 //
10 
11 #include "KmlPlaylistTagWriter.h"
12 
13 #include "GeoDataPlaylist.h"
14 #include "GeoDataTypes.h"
15 #include "GeoWriter.h"
16 #include "KmlElementDictionary.h"
17 #include "KmlObjectTagWriter.h"
18 
19 namespace Marble
20 {
21 
22 static GeoTagWriterRegistrar s_writerPlaylist(
23  GeoTagWriter::QualifiedName( GeoDataTypes::GeoDataPlaylistType,
24  kml::kmlTag_nameSpaceOgc22 ),
25  new KmlPlaylistTagWriter );
26 
27 bool KmlPlaylistTagWriter::write( const GeoNode *node, GeoWriter& writer ) const
28 {
29  const GeoDataPlaylist *playlist = static_cast<const GeoDataPlaylist*>( node );
30 
31  writer.writeStartElement( kml::kmlTag_nameSpaceGx22, kml::kmlTag_Playlist );
32 
33  for ( int i = 0; i < playlist->size(); i++ ) {
34  writeTourPrimitive( playlist->primitive( i ), writer );
35  }
36 
37  writer.writeEndElement();
38 
39  return true;
40 }
41 
42 void KmlPlaylistTagWriter::writeTourPrimitive( const GeoNode *primitive, GeoWriter& writer ) const
43 {
44 
45  if ( primitive->nodeType() == GeoDataTypes::GeoDataTourControlType ) {
46  writeTourControl( static_cast<const GeoDataTourControl*>( primitive ), writer );
47  }
48  else if ( primitive->nodeType() == GeoDataTypes::GeoDataWaitType ) {
49  writeWait( static_cast<const GeoDataWait*>( primitive ), writer );
50  }
51  else if ( primitive->nodeType() == GeoDataTypes::GeoDataFlyToType ) {
52  writeElement( primitive, writer );
53  }
54  else if ( primitive->nodeType() == GeoDataTypes::GeoDataSoundCueType ) {
55  writeSoundCue( static_cast<const GeoDataSoundCue*>(primitive), writer );
56  }
57  else if ( primitive->nodeType() == GeoDataTypes::GeoDataAnimatedUpdateType ) {
58  writeElement( primitive, writer );
59  }
60 }
61 
62 void KmlPlaylistTagWriter::writeTourControl( const GeoDataTourControl* tourControl, GeoWriter& writer )
63 {
64  writer.writeStartElement( kml::kmlTag_nameSpaceGx22, kml::kmlTag_TourControl );
65  KmlObjectTagWriter::writeIdentifiers( writer, tourControl );
66 
67  writer.writeElement( kml::kmlTag_nameSpaceGx22, kml::kmlTag_playMode, playModeToString( tourControl->playMode() ) );
68 
69  writer.writeEndElement();
70 }
71 
72 void KmlPlaylistTagWriter::writeWait( const GeoDataWait* wait, GeoWriter& writer )
73 {
74  writer.writeStartElement( kml::kmlTag_nameSpaceGx22, kml::kmlTag_Wait );
75  KmlObjectTagWriter::writeIdentifiers( writer, wait );
76 
77  writer.writeElement( kml::kmlTag_nameSpaceGx22, kml::kmlTag_duration, QString::number( wait->duration() ) );
78 
79  writer.writeEndElement();
80 }
81 
82 void KmlPlaylistTagWriter::writeSoundCue(const GeoDataSoundCue *cue, GeoWriter &writer)
83 {
84  writer.writeStartElement( kml::kmlTag_nameSpaceGx22, kml::kmlTag_SoundCue );
85  KmlObjectTagWriter::writeIdentifiers( writer, cue );
86 
87  writer.writeElement( kml::kmlTag_href, cue->href() );
88  writer.writeElement( kml::kmlTag_nameSpaceGx22, kml::kmlTag_delayedStart,
89  QString::number(cue->delayedStart()) );
90 
91  writer.writeEndElement();
92 }
93 
94 QString KmlPlaylistTagWriter::playModeToString( GeoDataTourControl::PlayMode playMode )
95 {
96  switch (playMode)
97  {
98  case GeoDataTourControl::Play: return "play";
99  case GeoDataTourControl::Pause: return "pause";
100  default: return "";
101  }
102 }
103 
104 }
Marble::kml::kmlTag_nameSpaceGx22
const char * kmlTag_nameSpaceGx22
Definition: KmlElementDictionary.cpp:35
Marble::GeoDataTourControl::PlayMode
PlayMode
Definition: GeoDataTourControl.h:22
Marble::GeoDataPlaylist::primitive
GeoDataTourPrimitive * primitive(int index)
Definition: GeoDataPlaylist.cpp:87
KmlObjectTagWriter.h
Marble::GeoNode::nodeType
virtual const char * nodeType() const
Definition: GeoDocument.cpp:74
Marble::kml::kmlTag_href
const char * kmlTag_href
Definition: KmlElementDictionary.cpp:82
Marble::GeoNode
A shared base class for all classes that are mapped to a specific tag (ie.
Definition: GeoDocument.h:60
Marble::kml::kmlTag_TourControl
const char * kmlTag_TourControl
Definition: KmlElementDictionary.cpp:214
Marble::kml::kmlTag_Wait
const char * kmlTag_Wait
Definition: KmlElementDictionary.cpp:215
Marble::KmlObjectTagWriter::writeIdentifiers
static void writeIdentifiers(GeoWriter &writer, const GeoDataObject *object)
Parses the id and targetId attributes and assign their values to the given object.
Definition: KmlObjectTagWriter.cpp:15
GeoWriter.h
QString::number
QString number(int n, int base)
Marble::KmlPlaylistTagWriter::write
virtual bool write(const GeoNode *node, GeoWriter &writer) const
Definition: KmlPlaylistTagWriter.cpp:27
KmlElementDictionary.h
Marble::kml::kmlTag_Playlist
const char * kmlTag_Playlist
Definition: KmlElementDictionary.cpp:216
Marble::GeoWriter
Standard Marble way of writing XML This class is intended to be a standardised way of writing XML for...
Definition: GeoWriter.h:29
Marble::kml::kmlTag_playMode
const char * kmlTag_playMode
Definition: KmlElementDictionary.cpp:217
Marble::GeoDataTypes::GeoDataFlyToType
const char * GeoDataFlyToType
Definition: GeoDataTypes.cpp:41
Marble::GeoDataPlaylist
Definition: GeoDataPlaylist.h:22
Marble::GeoTagWriter::QualifiedName
QPair< QString, QString > QualifiedName
Object Name and Namespace Pair This type is intended to be used in a similar way to.
Definition: GeoTagWriter.h:48
Marble::GeoDataTypes::GeoDataSoundCueType
const char * GeoDataSoundCueType
Definition: GeoDataTypes.cpp:79
Marble::GeoDataTypes::GeoDataTourControlType
const char * GeoDataTourControlType
Definition: GeoDataTypes.cpp:84
QString
Marble::GeoDataTypes::GeoDataPlaylistType
const char * GeoDataPlaylistType
Definition: GeoDataTypes.cpp:67
Marble::s_writerPlaylist
static GeoTagWriterRegistrar s_writerPlaylist(GeoTagWriter::QualifiedName(GeoDataTypes::GeoDataPlaylistType, kml::kmlTag_nameSpaceOgc22), new KmlPlaylistTagWriter)
KmlPlaylistTagWriter.h
GeoDataPlaylist.h
Marble::kml::kmlTag_nameSpaceOgc22
const char * kmlTag_nameSpaceOgc22
Definition: KmlElementDictionary.cpp:34
Marble::GeoTagWriter::writeElement
bool writeElement(const GeoNode *object, GeoWriter &writer) const
Definition: GeoTagWriter.cpp:29
Marble::kml::kmlTag_SoundCue
const char * kmlTag_SoundCue
Definition: KmlElementDictionary.cpp:212
Marble::kml::kmlTag_duration
const char * kmlTag_duration
Definition: KmlElementDictionary.cpp:63
Marble::GeoDataTypes::GeoDataWaitType
const char * GeoDataWaitType
Definition: GeoDataTypes.cpp:85
Marble::kml::kmlTag_delayedStart
const char * kmlTag_delayedStart
Definition: KmlElementDictionary.cpp:211
Marble::GeoDataTourControl::Pause
Definition: GeoDataTourControl.h:24
Marble::GeoDataPlaylist::size
int size() const
Definition: GeoDataPlaylist.cpp:128
Marble::GeoDataTypes::GeoDataAnimatedUpdateType
const char * GeoDataAnimatedUpdateType
Definition: GeoDataTypes.cpp:29
GeoDataTypes.h
Marble::GeoDataTourControl::Play
Definition: GeoDataTourControl.h:23
QXmlStreamWriter::writeEndElement
void writeEndElement()
QXmlStreamWriter::writeStartElement
void writeStartElement(const QString &qualifiedName)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:40 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

marble

Skip menu "marble"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal