Marble

GeoDataExtendedData.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2010 Harshit Jain <hjain.itbhu@gmail.com>
4// SPDX-FileCopyrightText: 2011 Niko Sams <niko.sams@gmail.com>
5//
6
7#include "GeoDataExtendedData.h"
8#include "GeoDataExtendedData_p.h"
9#include <QDataStream>
10
11#include "GeoDataTypes.h"
12
13namespace Marble
14{
15
16GeoDataExtendedData::GeoDataExtendedData()
17 : GeoNode()
18 , Serializable()
19 , d(new GeoDataExtendedDataPrivate)
20{
21}
22
23GeoDataExtendedData::GeoDataExtendedData(const GeoDataExtendedData &other)
24 : GeoNode(other)
25 , Serializable()
26 , d(new GeoDataExtendedDataPrivate(*other.d))
27{
28}
29
30bool GeoDataExtendedData::operator==(const GeoDataExtendedData &other) const
31{
32 return d->hash == other.d->hash && d->arrayHash == other.d->arrayHash;
33}
34
35GeoDataExtendedData::~GeoDataExtendedData()
36{
37 qDeleteAll(d->arrayHash);
38 delete d;
39}
40
41GeoDataExtendedData &GeoDataExtendedData::operator=(const GeoDataExtendedData &other)
42{
43 GeoNode::operator=(other);
44 *d = *other.d;
45 return *this;
46}
47
48bool GeoDataExtendedData::operator!=(const GeoDataExtendedData &other) const
49{
50 return !this->operator==(other);
51}
52
53const char *GeoDataExtendedData::nodeType() const
54{
55 return GeoDataTypes::GeoDataExtendedDataType;
56}
57
58GeoDataData &GeoDataExtendedData::valueRef(const QString &key) const
59{
60 return d->hash[key];
61}
62
63GeoDataData GeoDataExtendedData::value(const QString &key) const
64{
65 return d->hash.value(key);
66}
67
68void GeoDataExtendedData::addValue(const GeoDataData &data)
69{
70 d->hash.insert(data.name(), data);
71}
72
73void GeoDataExtendedData::removeKey(const QString &key)
74{
75 d->hash.remove(key);
76}
77
78QHash<QString, GeoDataData>::const_iterator GeoDataExtendedData::constBegin() const
79{
80 return d->hash.constBegin();
81}
82
83QHash<QString, GeoDataData>::const_iterator GeoDataExtendedData::constEnd() const
84{
85 return d->hash.constEnd();
86}
87
88int GeoDataExtendedData::size() const
89{
90 return d->hash.size();
91}
92
93bool GeoDataExtendedData::isEmpty() const
94{
95 return d->hash.empty() && d->schemaDataHash.empty();
96}
97
98bool GeoDataExtendedData::contains(const QString &key) const
99{
100 return d->hash.contains(key);
101}
102
103void GeoDataExtendedData::setSimpleArrayData(const QString &key, GeoDataSimpleArrayData *values)
104{
105 d->arrayHash[key] = values;
106}
107
108GeoDataSimpleArrayData *GeoDataExtendedData::simpleArrayData(const QString &key) const
109{
110 if (!d->arrayHash.contains(key))
111 return nullptr;
112 return d->arrayHash[key];
113}
114
115GeoDataSchemaData &GeoDataExtendedData::schemaData(const QString &schemaUrl) const
116{
117 return d->schemaDataHash[schemaUrl];
118}
119
120void GeoDataExtendedData::addSchemaData(const GeoDataSchemaData &schemaData)
121{
122 d->schemaDataHash.insert(schemaData.schemaUrl(), schemaData);
123 d->schemaDataHash[schemaData.schemaUrl()].setParent(this);
124}
125
126void GeoDataExtendedData::removeSchemaData(const QString &schemaUrl)
127{
128 GeoDataSchemaData schemaData = d->schemaDataHash.take(schemaUrl);
129 schemaData.setParent(nullptr);
130}
131
132QList<GeoDataSchemaData> GeoDataExtendedData::schemaDataList() const
133{
134 return d->schemaDataHash.values();
135}
136
137void GeoDataExtendedData::pack(QDataStream &stream) const
138{
139 Q_UNUSED(stream)
140}
141
142void GeoDataExtendedData::unpack(QDataStream &stream)
143{
144 Q_UNUSED(stream)
145}
146
147}
a class which allows to add custom data to KML Feature.
void setParent(GeoDataObject *parent)
Sets the parent of the object.
Binds a QML item to a specific geodetic location in screen coordinates.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 8 2024 12:02:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.