• 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
  • data
GeoDataDocument.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2007 Murad Tagirov <tmurad@gmail.com>
3  Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org>
4 
5  This file is part of the KDE project
6 
7  This library is free software you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  aint with this library see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 */
22 
23 #include "GeoDataDocument.h"
24 #include "GeoDataDocument_p.h"
25 
26 #include "GeoDataFolder.h"
27 #include "GeoDataPlacemark.h"
28 #include "GeoDataStyle.h"
29 #include "GeoDataStyleMap.h"
30 #include "GeoDataNetworkLinkControl.h"
31 
32 #include "MarbleDebug.h"
33 
34 
35 namespace Marble
36 {
37 
38 GeoDataDocument::GeoDataDocument()
39  : GeoDataContainer( new GeoDataDocumentPrivate )
40 {
41 }
42 
43 GeoDataDocument::GeoDataDocument( const GeoDataDocument& other )
44  : GeoDocument(), GeoDataContainer( other )
45 {
46 }
47 
48 GeoDataDocument::~GeoDataDocument()
49 {
50 }
51 
52 GeoDataDocumentPrivate* GeoDataDocument::p() const
53 {
54  return static_cast<GeoDataDocumentPrivate*>(d);
55 }
56 
57 DocumentRole GeoDataDocument::documentRole() const
58 {
59  return p()->m_documentRole;
60 }
61 
62 void GeoDataDocument::setDocumentRole( DocumentRole role )
63 {
64  p()->m_documentRole = role;
65 }
66 
67 QString GeoDataDocument::property() const
68 {
69  return p()->m_property;
70 }
71 
72 void GeoDataDocument::setProperty( QString property )
73 {
74  p()->m_property = property;
75 }
76 
77 QString GeoDataDocument::fileName() const
78 {
79  return p()->m_filename;
80 }
81 
82 void GeoDataDocument::setFileName( const QString &value )
83 {
84  detach();
85  p()->m_filename = value;
86 }
87 
88 QString GeoDataDocument::baseUri() const
89 {
90  return p()->m_baseUri;
91 }
92 
93 void GeoDataDocument::setBaseUri( const QString &baseUrl )
94 {
95  detach();
96  p()->m_baseUri = baseUrl;
97 }
98 
99 GeoDataNetworkLinkControl GeoDataDocument::networkLinkControl() const
100 {
101  return p()->m_networkLinkControl;
102 }
103 
104 void GeoDataDocument::setNetworkLinkControl( const GeoDataNetworkLinkControl &networkLinkControl )
105 {
106  detach();
107  p()->m_networkLinkControl = networkLinkControl;
108 }
109 
110 void GeoDataDocument::addStyle( const GeoDataStyle& style )
111 {
112  detach();
113  p()->m_styleHash.insert( style.styleId(), style );
114  p()->m_styleHash[ style.styleId() ].setParent( this );
115 }
116 
117 void GeoDataDocument::removeStyle( const QString& styleId )
118 {
119  detach();
120  p()->m_styleHash.remove( styleId );
121 }
122 
123 GeoDataStyle& GeoDataDocument::style( const QString& styleId ) const
124 {
125  /*
126  * FIXME: m_styleHash always should contain at least default
127  * GeoDataStyle element
128  */
129  return p()->m_styleHash[ styleId ];
130 }
131 
132 QList<GeoDataStyle> GeoDataDocument::styles() const
133 {
134  return p()->m_styleHash.values();
135 }
136 
137 void GeoDataDocument::addStyleMap( const GeoDataStyleMap& map )
138 {
139  detach();
140  p()->m_styleMapHash.insert( map.styleId(), map );
141  p()->m_styleMapHash[ map.styleId() ].setParent( this );
142 }
143 
144 void GeoDataDocument::removeStyleMap( const QString& mapId )
145 {
146  detach();
147  p()->m_styleMapHash.remove( mapId );
148 }
149 
150 GeoDataStyleMap& GeoDataDocument::styleMap( const QString& styleId ) const
151 {
152  return p()->m_styleMapHash[ styleId ];
153 }
154 
155 QList<GeoDataStyleMap> GeoDataDocument::styleMaps() const
156 {
157  return p()->m_styleMapHash.values();
158 }
159 
160 void GeoDataDocument::pack( QDataStream& stream ) const
161 {
162  GeoDataContainer::pack( stream );
163 
164  stream << p()->m_styleHash.size();
165 
166 
167  for( QMap<QString, GeoDataStyle>::const_iterator iterator
168  = p()->m_styleHash.constBegin();
169  iterator != p()->m_styleHash.constEnd();
170  ++iterator ) {
171  iterator.value().pack( stream );
172  }
173 }
174 
175 
176 void GeoDataDocument::unpack( QDataStream& stream )
177 {
178  detach();
179  GeoDataContainer::unpack( stream );
180 
181  int size = 0;
182 
183  stream >> size;
184  for( int i = 0; i < size; i++ ) {
185  GeoDataStyle style;
186  style.unpack( stream );
187  p()->m_styleHash.insert( style.styleId(), style );
188  }
189 }
190 
191 }
GeoDataDocument.h
Marble::GeoDataDocument::property
QString property() const
Definition: GeoDataDocument.cpp:67
Marble::GeoDataDocumentPrivate::m_styleHash
QMap< QString, GeoDataStyle > m_styleHash
Definition: GeoDataDocument_p.h:49
Marble::GeoDataDocument::addStyleMap
void addStyleMap(const GeoDataStyleMap &map)
Add a stylemap to the stylemap storage.
Definition: GeoDataDocument.cpp:137
Marble::GeoDataDocument
A container for Features, Styles and in the future Schemas.
Definition: GeoDataDocument.h:64
Marble::GeoDataDocument::setNetworkLinkControl
void setNetworkLinkControl(const GeoDataNetworkLinkControl &networkLinkControl)
set the NetworkLinkControl of the file
Definition: GeoDataDocument.cpp:104
Marble::GeoDataDocument::setDocumentRole
void setDocumentRole(DocumentRole role)
Definition: GeoDataDocument.cpp:62
Marble::GeoDataDocumentPrivate::m_documentRole
DocumentRole m_documentRole
Definition: GeoDataDocument_p.h:55
Marble::GeoDataDocument::removeStyle
void removeStyle(const QString &styleId)
Add a style to the style storage.
Definition: GeoDataDocument.cpp:117
Marble::GeoDataContainer::unpack
virtual void unpack(QDataStream &stream)
Unserialize the container from a stream.
Definition: GeoDataContainer.cpp:260
Marble::GeoDataFeature::role
const QString role() const
Return the role of the placemark.
Definition: GeoDataFeature.cpp:686
Marble::GeoDataDocument::unpack
virtual void unpack(QDataStream &stream)
Unserialize the container from a stream.
Definition: GeoDataDocument.cpp:176
GeoDataStyle.h
Marble::GeoDataContainer
A base class that can hold GeoDataFeatures.
Definition: GeoDataContainer.h:47
Marble::GeoDataFeature::style
const GeoDataStyle * style() const
Return the style assigned to the placemark.
Definition: GeoDataFeature.cpp:624
Marble::GeoDataStyleMap
a class to map different styles to one style
Definition: GeoDataStyleMap.h:38
Marble::GeoDataDocumentPrivate
Definition: GeoDataDocument_p.h:24
MarbleDebug.h
Marble::GeoDataDocumentPrivate::m_networkLinkControl
GeoDataNetworkLinkControl m_networkLinkControl
Definition: GeoDataDocument_p.h:53
Marble::GeoDataDocument::removeStyleMap
void removeStyleMap(const QString &mapId)
remove stylemap from storage
Definition: GeoDataDocument.cpp:144
Marble::GeoDataDocumentPrivate::m_baseUri
QString m_baseUri
Definition: GeoDataDocument_p.h:52
Marble::GeoDataDocument::GeoDataDocument
GeoDataDocument()
Definition: GeoDataDocument.cpp:38
Marble::GeoDataDocumentPrivate::m_property
QString m_property
Definition: GeoDataDocument_p.h:54
Marble::GeoDataDocument::baseUri
QString baseUri() const
The URI relative paths should be resolved against.
Definition: GeoDataDocument.cpp:88
Marble::GeoDataFeature::styleMap
const GeoDataStyleMap * styleMap() const
Return a pointer to a GeoDataStyleMap object which represents the styleMap of this feature...
Definition: GeoDataFeature.cpp:697
Marble::GeoDataStyle
an addressable style group
Definition: GeoDataStyle.h:55
Marble::GeoDataDocumentPrivate::m_filename
QString m_filename
Definition: GeoDataDocument_p.h:51
Marble::GeoDataDocument::documentRole
DocumentRole documentRole() const
Definition: GeoDataDocument.cpp:57
Marble::GeoDataDocument::addStyle
void addStyle(const GeoDataStyle &style)
Add a style to the style storage.
Definition: GeoDataDocument.cpp:110
Marble::GeoDataDocument::pack
virtual void pack(QDataStream &stream) const
Serialize the container to a stream.
Definition: GeoDataDocument.cpp:160
Marble::GeoDataFeature::d
GeoDataFeaturePrivate * d
Definition: GeoDataFeature.h:484
GeoDataDocument_p.h
Marble::GeoDataContainer::size
int size() const
size of the container
Definition: GeoDataContainer.cpp:179
GeoDataPlacemark.h
Marble::GeoDataContainer::pack
virtual void pack(QDataStream &stream) const
Serialize the container to a stream.
Definition: GeoDataContainer.cpp:244
GeoDataStyleMap.h
GeoDataFolder.h
Marble::GeoDataDocument::~GeoDataDocument
~GeoDataDocument()
Definition: GeoDataDocument.cpp:48
Marble::GeoDataDocument::setBaseUri
void setBaseUri(const QString &baseUri)
Change the URI for resolving relative paths.
Definition: GeoDataDocument.cpp:93
Marble::GeoDataDocument::setProperty
void setProperty(QString property)
Definition: GeoDataDocument.cpp:72
Marble::GeoDataDocument::setFileName
void setFileName(const QString &value)
Set a new file name for this document.
Definition: GeoDataDocument.cpp:82
Marble::GeoDataDocument::fileName
QString fileName() const
The filename of the document.
Definition: GeoDataDocument.cpp:77
Marble::GeoDocument
A shared base class between GeoDataDocument/GeoSourceDocument.
Definition: GeoDocument.h:42
Marble::GeoDataDocument::styles
QList< GeoDataStyle > styles() const
dump a Vector of all styles
Definition: GeoDataDocument.cpp:132
Marble::GeoDataDocumentPrivate::m_styleMapHash
QMap< QString, GeoDataStyleMap > m_styleMapHash
Definition: GeoDataDocument_p.h:50
Marble::GeoDataStyleSelector::styleId
QString styleId() const
Return the style id.
Definition: GeoDataStyleSelector.cpp:65
GeoDataNetworkLinkControl.h
Marble::GeoDataDocument::networkLinkControl
GeoDataNetworkLinkControl networkLinkControl() const
the NetworkLinkControl of the file
Definition: GeoDataDocument.cpp:99
Marble::GeoDataStyle::unpack
virtual void unpack(QDataStream &stream)
Unserialize the style from a stream.
Definition: GeoDataStyle.cpp:165
Marble::GeoDataDocument::styleMaps
QList< GeoDataStyleMap > styleMaps() const
dump a Vector of all styles
Definition: GeoDataDocument.cpp:155
Marble::GeoDataNetworkLinkControl
Definition: GeoDataNetworkLinkControl.h:27
Marble::DocumentRole
DocumentRole
Definition: GeoDataDocument.h:39
Marble::GeoDataFeature::detach
virtual void detach()
Definition: GeoDataFeature.cpp:734
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:38:49 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