• 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
KmlBalloonStyleTagWriter.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 2012 Mayank Madan <maddiemadan@gmail.com>
9 // Copyright 2013 Dennis Nienhüser <earthwings@gentoo.org>
10 //
11 
12 #include "KmlBalloonStyleTagWriter.h"
13 
14 #include "GeoDataBalloonStyle.h"
15 #include "GeoDataTypes.h"
16 #include "GeoWriter.h"
17 #include "KmlElementDictionary.h"
18 #include "KmlColorStyleTagWriter.h"
19 #include "KmlObjectTagWriter.h"
20 
21 namespace Marble
22 {
23 
24 static GeoTagWriterRegistrar s_writerBallonStyle( GeoTagWriter::QualifiedName(GeoDataTypes::GeoDataBalloonStyleType,
25  kml::kmlTag_nameSpaceOgc22),
26  new KmlBalloonStyleTagWriter() );
27 
28 bool KmlBalloonStyleTagWriter::write( const GeoNode *node,
29  GeoWriter& writer ) const
30 {
31  const GeoDataBalloonStyle *balloonStyle = static_cast<const GeoDataBalloonStyle*>( node );
32  writer.writeStartElement( kml::kmlTag_BalloonStyle );
33  KmlObjectTagWriter::writeIdentifiers( writer, balloonStyle );
34 
35  QString const backgroundColor = KmlColorStyleTagWriter::formatColor( balloonStyle->backgroundColor() );
36  writer.writeOptionalElement( kml::kmlTag_bgColor, backgroundColor, "ffffffff" );
37  QString const textColor = KmlColorStyleTagWriter::formatColor( balloonStyle->textColor() );
38  writer.writeOptionalElement( kml::kmlTag_textColor, textColor, "ff000000" );
39 
40  QString const textString = balloonStyle->text();
41  if ( textString.contains( QRegExp( "[<>&]" ) ) ) {
42  writer.writeStartElement( kml::kmlTag_text );
43  writer.writeCDATA( textString );
44  writer.writeEndElement();
45  } else {
46  writer.writeOptionalElement( kml::kmlTag_text, textString );
47  }
48 
49  QString const displayMode = balloonStyle->displayMode() == GeoDataBalloonStyle::Hide ? "hide" : "default";
50  writer.writeOptionalElement( kml::kmlTag_displayMode, displayMode );
51 
52  writer.writeEndElement();
53  return true;
54 }
55 
56 }
Marble::GeoWriter::writeOptionalElement
void writeOptionalElement(const QString &key, const QString &value, const QString &defaultValue=QString())
Convenience method to write value if value is not equal to defaultValue.
Definition: GeoWriter.cpp:98
Marble::kml::kmlTag_textColor
const char * kmlTag_textColor
Definition: KmlElementDictionary.cpp:183
KmlObjectTagWriter.h
Marble::GeoNode
A shared base class for all classes that are mapped to a specific tag (ie.
Definition: GeoDocument.h:60
Marble::KmlBalloonStyleTagWriter::write
virtual bool write(const GeoNode *node, GeoWriter &writer) const
Definition: KmlBalloonStyleTagWriter.cpp:28
Marble::kml::kmlTag_displayMode
const char * kmlTag_displayMode
Definition: KmlElementDictionary.cpp:59
Marble::GeoDataBalloonStyle::backgroundColor
QColor backgroundColor() const
Definition: GeoDataBalloonStyle.cpp:77
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
Marble::kml::kmlTag_BalloonStyle
const char * kmlTag_BalloonStyle
Definition: KmlElementDictionary.cpp:42
KmlColorStyleTagWriter.h
QRegExp
Marble::KmlColorStyleTagWriter::formatColor
static QString formatColor(const QColor &color)
Definition: KmlColorStyleTagWriter.cpp:43
Marble::kml::kmlTag_bgColor
const char * kmlTag_bgColor
Definition: KmlElementDictionary.cpp:44
Marble::GeoDataBalloonStyle::Hide
Definition: GeoDataBalloonStyle.h:42
KmlElementDictionary.h
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::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
QXmlStreamWriter::writeCDATA
void writeCDATA(const QString &text)
QString
Marble::s_writerBallonStyle
static GeoTagWriterRegistrar s_writerBallonStyle(GeoTagWriter::QualifiedName(GeoDataTypes::GeoDataBalloonStyleType, kml::kmlTag_nameSpaceOgc22), new KmlBalloonStyleTagWriter())
Marble::GeoDataBalloonStyle
Definition: GeoDataBalloonStyle.h:23
Marble::kml::kmlTag_nameSpaceOgc22
const char * kmlTag_nameSpaceOgc22
Definition: KmlElementDictionary.cpp:34
QString::contains
bool contains(QChar ch, Qt::CaseSensitivity cs) const
Marble::GeoDataBalloonStyle::textColor
QColor textColor() const
Definition: GeoDataBalloonStyle.cpp:87
KmlBalloonStyleTagWriter.h
Marble::kml::kmlTag_text
const char * kmlTag_text
Definition: KmlElementDictionary.cpp:182
Marble::GeoDataTypes::GeoDataBalloonStyleType
const char * GeoDataBalloonStyleType
Definition: GeoDataTypes.cpp:89
Marble::GeoDataBalloonStyle::displayMode
DisplayMode displayMode() const
Definition: GeoDataBalloonStyle.cpp:107
GeoDataTypes.h
Marble::GeoDataBalloonStyle::text
QString text() const
Definition: GeoDataBalloonStyle.cpp:97
GeoDataBalloonStyle.h
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