• 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
  • 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 #include "GeoDataSchema.h"
32 
33 #include "MarbleDebug.h"
34 
35 
36 namespace Marble
37 {
38 
39 GeoDataDocument::GeoDataDocument()
40  : GeoDataContainer( new GeoDataDocumentPrivate )
41 {
42 }
43 
44 GeoDataDocument::GeoDataDocument( const GeoDataDocument& other )
45  : GeoDocument(), GeoDataContainer( other )
46 {
47 }
48 
49 GeoDataDocument::~GeoDataDocument()
50 {
51 }
52 
53 GeoDataDocumentPrivate* GeoDataDocument::p()
54 {
55  return static_cast<GeoDataDocumentPrivate*>(d);
56 }
57 
58 const GeoDataDocumentPrivate* GeoDataDocument::p() const
59 {
60  return static_cast<GeoDataDocumentPrivate*>(d);
61 }
62 
63 bool GeoDataDocument::operator==( const GeoDataDocument &other ) const
64 {
65  return GeoDataContainer::equals(other) &&
66  p()->m_styleHash == other.p()->m_styleHash &&
67  p()->m_styleMapHash == other.p()->m_styleMapHash &&
68  p()->m_schemaHash == other.p()->m_schemaHash &&
69  p()->m_filename == other.p()->m_filename &&
70  p()->m_baseUri == other.p()->m_baseUri &&
71  p()->m_networkLinkControl == other.p()->m_networkLinkControl &&
72  p()->m_property == other.p()->m_property &&
73  p()->m_documentRole == other.p()->m_documentRole;
74 }
75 
76 bool GeoDataDocument::operator!=( const GeoDataDocument &other ) const
77 {
78  return !this->operator==( other );
79 }
80 
81 DocumentRole GeoDataDocument::documentRole() const
82 {
83  return p()->m_documentRole;
84 }
85 
86 void GeoDataDocument::setDocumentRole( DocumentRole role )
87 {
88  p()->m_documentRole = role;
89 }
90 
91 QString GeoDataDocument::property() const
92 {
93  return p()->m_property;
94 }
95 
96 void GeoDataDocument::setProperty( QString property )
97 {
98  p()->m_property = property;
99 }
100 
101 QString GeoDataDocument::fileName() const
102 {
103  return p()->m_filename;
104 }
105 
106 void GeoDataDocument::setFileName( const QString &value )
107 {
108  detach();
109  p()->m_filename = value;
110 }
111 
112 QString GeoDataDocument::baseUri() const
113 {
114  return p()->m_baseUri;
115 }
116 
117 void GeoDataDocument::setBaseUri( const QString &baseUrl )
118 {
119  detach();
120  p()->m_baseUri = baseUrl;
121 }
122 
123 GeoDataNetworkLinkControl GeoDataDocument::networkLinkControl() const
124 {
125  return p()->m_networkLinkControl;
126 }
127 
128 void GeoDataDocument::setNetworkLinkControl( const GeoDataNetworkLinkControl &networkLinkControl )
129 {
130  detach();
131  p()->m_networkLinkControl = networkLinkControl;
132 }
133 
134 void GeoDataDocument::addStyle( const GeoDataStyle& style )
135 {
136  detach();
137  p()->m_styleHash.insert( style.id(), style );
138  p()->m_styleHash[ style.id() ].setParent( this );
139 }
140 
141 void GeoDataDocument::removeStyle( const QString& styleId )
142 {
143  detach();
144  p()->m_styleHash.remove( styleId );
145 }
146 
147 GeoDataStyle& GeoDataDocument::style( const QString& styleId )
148 {
149  /*
150  * FIXME: m_styleHash always should contain at least default
151  * GeoDataStyle element
152  */
153  return p()->m_styleHash[ styleId ];
154 }
155 
156 GeoDataStyle GeoDataDocument::style( const QString &styleId ) const
157 {
158  return p()->m_styleHash.value( styleId );
159 }
160 
161 QList<GeoDataStyle> GeoDataDocument::styles() const
162 {
163  return p()->m_styleHash.values();
164 }
165 
166 void GeoDataDocument::addStyleMap( const GeoDataStyleMap& map )
167 {
168  detach();
169  p()->m_styleMapHash.insert( map.id(), map );
170  p()->m_styleMapHash[ map.id() ].setParent( this );
171 }
172 
173 void GeoDataDocument::removeStyleMap( const QString& mapId )
174 {
175  detach();
176  p()->m_styleMapHash.remove( mapId );
177 }
178 
179 GeoDataStyleMap& GeoDataDocument::styleMap( const QString& styleId )
180 {
181  return p()->m_styleMapHash[ styleId ];
182 }
183 
184 GeoDataStyleMap GeoDataDocument::styleMap( const QString &styleId ) const
185 {
186  return p()->m_styleMapHash.value( styleId );
187 }
188 
189 QList<GeoDataStyleMap> GeoDataDocument::styleMaps() const
190 {
191  return p()->m_styleMapHash.values();
192 }
193 
194 void GeoDataDocument::addSchema( const GeoDataSchema& schema )
195 {
196  detach();
197  p()->m_schemaHash.insert( schema.id(), schema );
198  p()->m_schemaHash[ schema.id() ].setParent( this );
199 }
200 
201 void GeoDataDocument::removeSchema( const QString& schemaId )
202 {
203  detach();
204  GeoDataSchema schema = p()->m_schemaHash.take( schemaId );
205  schema.setParent( 0 );
206 }
207 
208 GeoDataSchema GeoDataDocument::schema( const QString& schemaId ) const
209 {
210  return p()->m_schemaHash.value( schemaId );
211 }
212 
213 GeoDataSchema &GeoDataDocument::schema( const QString &schemaId )
214 {
215  return p()->m_schemaHash[ schemaId ];
216 }
217 
218 QList<GeoDataSchema> GeoDataDocument::schemas() const
219 {
220  return p()->m_schemaHash.values();
221 }
222 
223 void GeoDataDocument::pack( QDataStream& stream ) const
224 {
225  GeoDataContainer::pack( stream );
226 
227  stream << p()->m_styleHash.size();
228 
229 
230  for( QMap<QString, GeoDataStyle>::const_iterator iterator
231  = p()->m_styleHash.constBegin();
232  iterator != p()->m_styleHash.constEnd();
233  ++iterator ) {
234  iterator.value().pack( stream );
235  }
236 }
237 
238 
239 void GeoDataDocument::unpack( QDataStream& stream )
240 {
241  detach();
242  GeoDataContainer::unpack( stream );
243 
244  int size = 0;
245 
246  stream >> size;
247  for( int i = 0; i < size; i++ ) {
248  GeoDataStyle style;
249  style.unpack( stream );
250  p()->m_styleHash.insert( style.id(), style );
251  }
252 }
253 
254 }
GeoDataDocument.h
Marble::GeoDataDocument::removeSchema
void removeSchema(const QString &schemaId)
remove a schema from schema storage
Definition: GeoDataDocument.cpp:201
Marble::GeoDataDocument::property
QString property() const
Definition: GeoDataDocument.cpp:91
Marble::GeoDataDocumentPrivate::m_styleHash
QMap< QString, GeoDataStyle > m_styleHash
Definition: GeoDataDocument_p.h:50
Marble::GeoDataDocument::addStyleMap
void addStyleMap(const GeoDataStyleMap &map)
Add a stylemap to the stylemap storage.
Definition: GeoDataDocument.cpp:166
Marble::GeoDataDocument
A container for Features, Styles and in the future Schemas.
Definition: GeoDataDocument.h:65
Marble::GeoDataDocument::setNetworkLinkControl
void setNetworkLinkControl(const GeoDataNetworkLinkControl &networkLinkControl)
set the NetworkLinkControl of the file
Definition: GeoDataDocument.cpp:128
Marble::GeoDataDocument::setDocumentRole
void setDocumentRole(DocumentRole role)
Definition: GeoDataDocument.cpp:86
Marble::GeoDataDocumentPrivate::m_documentRole
DocumentRole m_documentRole
Definition: GeoDataDocument_p.h:57
Marble::GeoDataDocument::removeStyle
void removeStyle(const QString &styleId)
Add a style to the style storage.
Definition: GeoDataDocument.cpp:141
Marble::GeoDataContainer::unpack
virtual void unpack(QDataStream &stream)
Unserialize the container from a stream.
Definition: GeoDataContainer.cpp:367
Marble::GeoDataFeature::role
const QString role() const
Return the role of the placemark.
Definition: GeoDataFeature.cpp:776
QDataStream
Marble::GeoDataDocument::operator==
bool operator==(const GeoDataDocument &other) const
Definition: GeoDataDocument.cpp:63
Marble::GeoDataDocument::unpack
virtual void unpack(QDataStream &stream)
Unserialize the container from a stream.
Definition: GeoDataDocument.cpp:239
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, or a default style if none has been set.
Definition: GeoDataFeature.cpp:709
Marble::GeoDataStyleMap
a class to map different styles to one style
Definition: GeoDataStyleMap.h:38
Marble::GeoDataDocumentPrivate
Definition: GeoDataDocument_p.h:25
MarbleDebug.h
Marble::GeoDataDocumentPrivate::m_networkLinkControl
GeoDataNetworkLinkControl m_networkLinkControl
Definition: GeoDataDocument_p.h:55
Marble::GeoDataDocument::removeStyleMap
void removeStyleMap(const QString &mapId)
remove stylemap from storage
Definition: GeoDataDocument.cpp:173
Marble::GeoDataObject::setParent
virtual void setParent(GeoDataObject *parent)
Sets the parent of the object.
Definition: GeoDataObject.cpp:70
Marble::GeoDataDocumentPrivate::m_baseUri
QString m_baseUri
Definition: GeoDataDocument_p.h:54
Marble::GeoDataDocument::GeoDataDocument
GeoDataDocument()
Definition: GeoDataDocument.cpp:39
Marble::GeoDataDocumentPrivate::m_property
QString m_property
Definition: GeoDataDocument_p.h:56
Marble::GeoDataDocument::baseUri
QString baseUri() const
The URI relative paths should be resolved against.
Definition: GeoDataDocument.cpp:112
Marble::GeoDataFeature::styleMap
const GeoDataStyleMap * styleMap() const
Return a pointer to a GeoDataStyleMap object which represents the styleMap of this feature...
Definition: GeoDataFeature.cpp:787
Marble::GeoDataStyle
an addressable style group
Definition: GeoDataStyle.h:55
Marble::GeoDataDocumentPrivate::m_filename
QString m_filename
Definition: GeoDataDocument_p.h:53
Marble::GeoDataDocumentPrivate::m_schemaHash
QMap< QString, GeoDataSchema > m_schemaHash
Definition: GeoDataDocument_p.h:52
QMap::const_iterator
Marble::GeoDataDocument::documentRole
DocumentRole documentRole() const
Definition: GeoDataDocument.cpp:81
Marble::GeoDataDocument::addStyle
void addStyle(const GeoDataStyle &style)
Add a style to the style storage.
Definition: GeoDataDocument.cpp:134
Marble::GeoDataDocument::pack
virtual void pack(QDataStream &stream) const
Serialize the container to a stream.
Definition: GeoDataDocument.cpp:223
Marble::GeoDataFeature::d
GeoDataFeaturePrivate * d
Definition: GeoDataFeature.h:506
GeoDataDocument_p.h
GeoDataSchema.h
Marble::GeoDataContainer::size
int size() const
size of the container
Definition: GeoDataContainer.cpp:286
QString
QList
GeoDataPlacemark.h
Marble::GeoDataContainer::pack
virtual void pack(QDataStream &stream) const
Serialize the container to a stream.
Definition: GeoDataContainer.cpp:351
GeoDataStyleMap.h
GeoDataFolder.h
Marble::GeoDataDocument::~GeoDataDocument
~GeoDataDocument()
Definition: GeoDataDocument.cpp:49
Marble::GeoDataObject::id
QString id() const
Get the id of the object.
Definition: GeoDataObject.cpp:75
Marble::GeoDataDocument::setBaseUri
void setBaseUri(const QString &baseUri)
Change the URI for resolving relative paths.
Definition: GeoDataDocument.cpp:117
Marble::GeoDataDocument::setProperty
void setProperty(QString property)
Definition: GeoDataDocument.cpp:96
Marble::GeoDataSchema
Definition: GeoDataSchema.h:30
Marble::GeoDataDocument::setFileName
void setFileName(const QString &value)
Set a new file name for this document.
Definition: GeoDataDocument.cpp:106
Marble::GeoDataDocument::fileName
QString fileName() const
The filename of the document.
Definition: GeoDataDocument.cpp:101
Marble::GeoDataDocument::schema
GeoDataSchema schema(const QString &schemaId) const
Returns a schema with id = schemaId form schema storage.
Definition: GeoDataDocument.cpp:208
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:161
Marble::GeoDataDocumentPrivate::m_styleMapHash
QMap< QString, GeoDataStyleMap > m_styleMapHash
Definition: GeoDataDocument_p.h:51
Marble::GeoDataDocument::operator!=
bool operator!=(const GeoDataDocument &other) const
Definition: GeoDataDocument.cpp:76
GeoDataNetworkLinkControl.h
Marble::GeoDataDocument::networkLinkControl
GeoDataNetworkLinkControl networkLinkControl() const
the NetworkLinkControl of the file
Definition: GeoDataDocument.cpp:123
Marble::GeoDataStyle::unpack
virtual void unpack(QDataStream &stream)
Unserialize the style from a stream.
Definition: GeoDataStyle.cpp:205
Marble::GeoDataDocument::styleMaps
QList< GeoDataStyleMap > styleMaps() const
dump a Vector of all styles
Definition: GeoDataDocument.cpp:189
Marble::GeoDataNetworkLinkControl
Definition: GeoDataNetworkLinkControl.h:27
Marble::GeoDataContainer::equals
bool equals(const GeoDataContainer &other) const
Definition: GeoDataContainer.cpp:66
Marble::GeoDataDocument::addSchema
void addSchema(const GeoDataSchema &schema)
Add a schema to simplemap storage.
Definition: GeoDataDocument.cpp:194
Marble::DocumentRole
DocumentRole
Definition: GeoDataDocument.h:39
Marble::GeoDataFeature::detach
virtual void detach()
Definition: GeoDataFeature.cpp:824
Marble::GeoDataDocument::schemas
QList< GeoDataSchema > schemas() const
dump a vector of all schemas
Definition: GeoDataDocument.cpp:218
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:13:39 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