8#include "GeoDataDocument.h"
9#include "GeoDataDocument_p.h"
11#include "GeoDataNetworkLinkControl.h"
12#include "GeoDataSchema.h"
13#include "GeoDataStyleMap.h"
15#include "MarbleDebug.h"
22GeoDataDocument::GeoDataDocument()
23 : GeoDataContainer(new GeoDataDocumentPrivate)
27GeoDataDocument::GeoDataDocument(
const GeoDataDocument &other)
29 , GeoDataContainer(other, new GeoDataDocumentPrivate(*other.d_func()))
33GeoDataDocument::~GeoDataDocument() =
default;
35GeoDataDocument &GeoDataDocument::operator=(
const GeoDataDocument &other)
45bool GeoDataDocument::operator==(
const GeoDataDocument &other)
const
47 if (!GeoDataContainer::equals(other)) {
51 Q_D(
const GeoDataDocument);
52 const GeoDataDocumentPrivate *
const other_d = other.d_func();
53 if (!(d->m_styleHash.size() == other_d->m_styleHash.size() && d->m_styleMapHash == other_d->m_styleMapHash && d->m_schemaHash == other_d->m_schemaHash
54 && d->m_filename == other_d->m_filename && d->m_baseUri == other_d->m_baseUri && d->m_networkLinkControl == other_d->m_networkLinkControl
55 && d->m_property == other_d->m_property && d->m_documentRole == other_d->m_documentRole)) {
59 auto iter = d->m_styleHash.constBegin();
60 auto const end = d->m_styleHash.constEnd();
61 for (; iter !=
end; ++iter) {
62 if (!other_d->m_styleHash.contains(iter.key())) {
66 if (*iter.value() != *other_d->m_styleHash[iter.key()]) {
74bool GeoDataDocument::operator!=(
const GeoDataDocument &other)
const
79const char *GeoDataDocument::nodeType()
const
81 return GeoDataTypes::GeoDataDocumentType;
89DocumentRole GeoDataDocument::documentRole()
const
92 return d->m_documentRole;
95void GeoDataDocument::setDocumentRole(DocumentRole role)
98 d->m_documentRole = role;
101QString GeoDataDocument::property()
const
103 Q_D(
const GeoDataDocument);
104 return d->m_property;
107void GeoDataDocument::setProperty(
const QString &property)
109 Q_D(GeoDataDocument);
110 d->m_property = property;
116 return d->m_filename;
119void GeoDataDocument::setFileName(
const QString &value)
122 d->m_filename = value;
131void GeoDataDocument::setBaseUri(
const QString &baseUrl)
134 d->m_baseUri = baseUrl;
137GeoDataNetworkLinkControl GeoDataDocument::networkLinkControl()
const
140 return d->m_networkLinkControl;
143void GeoDataDocument::setNetworkLinkControl(
const GeoDataNetworkLinkControl &networkLinkControl)
146 d->m_networkLinkControl = networkLinkControl;
152 d->m_styleHash.insert(style->id(), style);
153 d->m_styleHash[style->id()]->setParent(
this);
156void GeoDataDocument::removeStyle(
const QString &styleId)
159 d->m_styleHash.remove(styleId);
169 return d->m_styleHash[styleId];
175 return d->m_styleHash.value(styleId);
180 Q_D(
const GeoDataDocument);
182 for (
auto const &style : d->m_styleHash.values()) {
192 return d->m_styleHash.values();
198 d->m_styleMapHash.insert(map.id(), map);
199 d->m_styleMapHash[map.id()].setParent(
this);
202void GeoDataDocument::removeStyleMap(
const QString &mapId)
205 d->m_styleMapHash.remove(mapId);
211 return d->m_styleMapHash[styleId];
217 return d->m_styleMapHash.value(styleId);
223 return d->m_styleMapHash.values();
226void GeoDataDocument::addSchema(
const GeoDataSchema &schema)
229 d->m_schemaHash.insert(schema.
id(), schema);
230 d->m_schemaHash[schema.
id()].setParent(
this);
233void GeoDataDocument::removeSchema(
const QString &schemaId)
236 GeoDataSchema schema = d->m_schemaHash.take(schemaId);
240GeoDataSchema GeoDataDocument::schema(
const QString &schemaId)
const
243 return d->m_schemaHash.value(schemaId);
246GeoDataSchema &GeoDataDocument::schema(
const QString &schemaId)
249 return d->m_schemaHash[schemaId];
255 return d->m_schemaHash.values();
258void GeoDataDocument::pack(
QDataStream &stream)
const
261 GeoDataContainer::pack(stream);
263 stream << d->m_styleHash.size();
266 iterator.value()->pack(stream);
272 Q_D(GeoDataDocument);
273 GeoDataContainer::unpack(stream);
278 for (
int i = 0; i < size; i++) {
279 GeoDataStyle::Ptr style(
new GeoDataStyle);
280 style->unpack(stream);
281 d->m_styleHash.insert(style->id(), style);
A container for Features, Styles and in the future Schemas.
A base class for all geodata features.
void setParent(GeoDataObject *parent)
Sets the parent of the object.
QString id() const
Get the id of the object.
a class to map different styles to one style
QAction * end(const QObject *recvr, const char *slot, QObject *parent)
bool operator==(const StyleDelim &l, const StyleDelim &r)
Binds a QML item to a specific geodetic location in screen coordinates.