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

marble

  • sources
  • kde-4.12
  • 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 
20 namespace Marble
21 {
22 
23 static GeoTagWriterRegistrar s_writerBallonStyle( GeoTagWriter::QualifiedName(GeoDataTypes::GeoDataBalloonStyleType,
24  kml::kmlTag_nameSpace22),
25  new KmlBalloonStyleTagWriter() );
26 
27 bool KmlBalloonStyleTagWriter::write( const GeoNode *node,
28  GeoWriter& writer ) const
29 {
30  const GeoDataBalloonStyle *balloonStyle = static_cast<const GeoDataBalloonStyle*>( node );
31  writer.writeStartElement( kml::kmlTag_BalloonStyle );
32 
33  QString const textColor = KmlColorStyleTagWriter::formatColor( balloonStyle->textColor() );
34  writer.writeOptionalElement( kml::kmlTag_textColor, textColor, "ff000000" );
35  QString const backgroundColor = KmlColorStyleTagWriter::formatColor( balloonStyle->backgroundColor() );
36  writer.writeOptionalElement( kml::kmlTag_bgColor, backgroundColor, "ffffffff" );
37 
38  QString const textString = balloonStyle->text();
39  if ( textString.contains( QRegExp( "[<>&]" ) ) ) {
40  writer.writeStartElement( kml::kmlTag_text );
41  writer.writeCDATA( textString );
42  writer.writeEndElement();
43  } else {
44  writer.writeOptionalElement( kml::kmlTag_text, textString );
45  }
46 
47  QString const displayMode = balloonStyle->displayMode() == GeoDataBalloonStyle::Hide ? "hide" : "default";
48  writer.writeOptionalElement( kml::kmlTag_displayMode, displayMode );
49 
50  writer.writeEndElement();
51  return true;
52 }
53 
54 }
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
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:27
Marble::kml::kmlTag_displayMode
const char * kmlTag_displayMode
Definition: KmlElementDictionary.cpp:59
Marble::kml::kmlTag_nameSpace22
const char * kmlTag_nameSpace22
Definition: KmlElementDictionary.cpp:33
Marble::GeoDataBalloonStyle::backgroundColor
QColor backgroundColor() const
Definition: GeoDataBalloonStyle.cpp:63
GeoWriter.h
Marble::kml::kmlTag_BalloonStyle
const char * kmlTag_BalloonStyle
Definition: KmlElementDictionary.cpp:42
KmlColorStyleTagWriter.h
Marble::s_writerBallonStyle
static GeoTagWriterRegistrar s_writerBallonStyle(GeoTagWriter::QualifiedName(GeoDataTypes::GeoDataBalloonStyleType, kml::kmlTag_nameSpace22), new KmlBalloonStyleTagWriter())
Marble::KmlColorStyleTagWriter::formatColor
static QString formatColor(const QColor &color)
Definition: KmlColorStyleTagWriter.cpp:41
Marble::kml::kmlTag_bgColor
const char * kmlTag_bgColor
Definition: KmlElementDictionary.cpp:44
Marble::GeoDataBalloonStyle::Hide
Definition: GeoDataBalloonStyle.h:39
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:28
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::GeoDataBalloonStyle
Definition: GeoDataBalloonStyle.h:23
Marble::GeoDataBalloonStyle::textColor
QColor textColor() const
Definition: GeoDataBalloonStyle.cpp:73
KmlBalloonStyleTagWriter.h
Marble::kml::kmlTag_text
const char * kmlTag_text
Definition: KmlElementDictionary.cpp:182
Marble::GeoDataTypes::GeoDataBalloonStyleType
const char * GeoDataBalloonStyleType
Definition: GeoDataTypes.cpp:80
Marble::GeoDataBalloonStyle::displayMode
DisplayMode displayMode() const
Definition: GeoDataBalloonStyle.cpp:93
GeoDataTypes.h
Marble::GeoDataBalloonStyle::text
QString text() const
Definition: GeoDataBalloonStyle.cpp:83
GeoDataBalloonStyle.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:50 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
  • kstars
  • libkdeedu
  •   keduvocdocument
  • 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