Marble

GeoDataExtendedData.cpp
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2010 Harshit Jain <[email protected]>
4 // SPDX-FileCopyrightText: 2011 Niko Sams <[email protected]>
5 //
6 
7 #include "GeoDataExtendedData.h"
8 #include "GeoDataExtendedData_p.h"
9 #include <QDataStream>
10 
11 #include "GeoDataTypes.h"
12 
13 namespace Marble
14 {
15 
16 GeoDataExtendedData::GeoDataExtendedData() :
17  GeoNode(),
18  Serializable(),
19  d(new GeoDataExtendedDataPrivate)
20 {
21 }
22 
23 GeoDataExtendedData::GeoDataExtendedData(const GeoDataExtendedData &other) :
24  GeoNode(other),
25  Serializable(),
26  d(new GeoDataExtendedDataPrivate(*other.d))
27 {
28 }
29 
30 bool GeoDataExtendedData::operator==( const GeoDataExtendedData& other ) const
31 {
32  return d->hash == other.d->hash &&
33  d->arrayHash == other.d->arrayHash;
34 }
35 
36 GeoDataExtendedData::~GeoDataExtendedData()
37 {
38  qDeleteAll( d->arrayHash );
39  delete d;
40 }
41 
43 {
44  GeoNode::operator=(other);
45  *d = *other.d;
46  return *this;
47 }
48 
49 bool GeoDataExtendedData::operator!=( const GeoDataExtendedData &other ) const
50 {
51  return !this->operator==(other);
52 }
53 
54 const char* GeoDataExtendedData::nodeType() const
55 {
56  return GeoDataTypes::GeoDataExtendedDataType;
57 }
58 
59 GeoDataData& GeoDataExtendedData::valueRef( const QString& key ) const
60 {
61  return d->hash[ key ];
62 }
63 
64 GeoDataData GeoDataExtendedData::value( const QString& key ) const
65 {
66  return d->hash.value( key );
67 }
68 
69 void GeoDataExtendedData::addValue( const GeoDataData& data )
70 {
71  d->hash.insert( data.name(), data );
72 }
73 
75 {
76  d->hash.remove(key);
77 }
78 
80 {
81  return d->hash.constBegin();
82 }
83 
85 {
86  return d->hash.constEnd();
87 }
88 
90 {
91  return d->hash.size();
92 }
93 
95 {
96  return d->hash.empty() && d->schemaDataHash.empty();
97 }
98 
99 bool GeoDataExtendedData::contains( const QString &key ) const
100 {
101  return d->hash.contains( key );
102 }
103 
104 void GeoDataExtendedData::setSimpleArrayData( const QString& key, GeoDataSimpleArrayData *values )
105 {
106  d->arrayHash[ key ] = values;
107 }
108 
109 GeoDataSimpleArrayData* GeoDataExtendedData::simpleArrayData( const QString& key ) const
110 {
111  if ( !d->arrayHash.contains( key ) ) return nullptr;
112  return d->arrayHash[ key ];
113 }
114 
115 GeoDataSchemaData& GeoDataExtendedData::schemaData( const QString& schemaUrl ) const
116 {
117  return d->schemaDataHash[ schemaUrl ];
118 }
119 
120 void GeoDataExtendedData::addSchemaData( const GeoDataSchemaData& schemaData )
121 {
122  d->schemaDataHash.insert( schemaData.schemaUrl(), schemaData );
123  d->schemaDataHash[schemaData.schemaUrl()].setParent( this );
124 }
125 
127 {
128  GeoDataSchemaData schemaData = d->schemaDataHash.take( schemaUrl );
129  schemaData.setParent( nullptr );
130 }
131 
133 {
134  return d->schemaDataHash.values();
135 }
136 
138 {
139  Q_UNUSED(stream)
140 }
141 
143 {
144  Q_UNUSED(stream)
145 }
146 
147 }
GeoDataSchemaData & schemaData(const QString &schemaUrl) const
Adds a SchemaData schemaData element to schemaDataHash.
Binds a QML item to a specific geodetic location in screen coordinates.
GeoDataData & valueRef(const QString &key) const
return value of GeoDataExtendedData object associated with the given key as a modifiable reference ...
void addSchemaData(const GeoDataSchemaData &schemaData)
Adds a SchemaData schemaData element to schemaDataHash.
QHash< QString, GeoDataData >::const_iterator constEnd() const
return const End iterator for QHash
a class which allows to add custom data to KML Feature.
bool isEmpty() const
return whether QHash is empty or not
GeoDataExtendedData & operator=(const GeoDataExtendedData &other)
assignment operator
const char * nodeType() const override
Provides type information for downcasting a GeoNode.
int size() const
return size of QHash
GeoDataData value(const QString &key) const
return the value of GeoDataExtendedData associated with the given key
GeoDataSimpleArrayData * simpleArrayData(const QString &key) const
return SimpleArrayData for given key, 0 pointer if none is set
void pack(QDataStream &stream) const override
Serialize the ExtendedData to a stream.
void unpack(QDataStream &stream) override
Unserialize the ExtendedData from a stream.
void addValue(const GeoDataData &data)
add a data object to the GeoDataExtendedData with the key
bool contains(const QString &key) const
Returns true if there exists a value for the given key.
QList< GeoDataSchemaData > schemaDataList() const
Dump a vector containing all SchemaData element.
void setSimpleArrayData(const QString &key, GeoDataSimpleArrayData *values)
set SimpleArrayData for given key
void removeKey(const QString &key)
void removeSchemaData(const QString &schemaUrl)
Removes a SchemaData element with schema url schemaUrl from schemaDataHash.
QHash< QString, GeoDataData >::const_iterator constBegin() const
return const Begin iterator for QHash
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Tue Dec 7 2021 23:10:58 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.