Marble

GeoDataSchema.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2014 Abhinav Gangwar <abhgang@gmail.com>
4//
5
6#include "GeoDataSchema.h"
7
8// Qt
9#include <QDataStream>
10
11// Marble
12#include "GeoDataTypes.h"
13#include "GeoDataSimpleField.h"
14
15namespace Marble
16{
17
18class GeoDataSchemaPrivate
19{
20 public:
22 QString m_name;
23};
24
25GeoDataSchema::GeoDataSchema()
26 : d( new GeoDataSchemaPrivate )
27{
28}
29
30GeoDataSchema::GeoDataSchema( const QHash<QString, GeoDataSimpleField>& simplefields )
31 : d( new GeoDataSchemaPrivate )
32{
33 d->m_simpleField = simplefields;
34}
35
36GeoDataSchema::GeoDataSchema( const GeoDataSchema& other )
37 : GeoDataObject( other ),
38 d( new GeoDataSchemaPrivate( *other.d ) )
39{
40}
41
42GeoDataSchema &GeoDataSchema::operator=(const GeoDataSchema &other)
43{
44 GeoDataObject::operator=( other );
45 *d = *other.d;
46 return *this;
47}
48
49bool GeoDataSchema::operator==(const GeoDataSchema& other) const
50{
51 return equals(other) &&
52 d->m_name == other.d->m_name &&
53 d->m_simpleField == other.d->m_simpleField;
54}
55
56bool GeoDataSchema::operator!=(const GeoDataSchema& other) const
57{
58 return !this->operator==( other );
59}
60
61GeoDataSchema::~GeoDataSchema()
62{
63 delete d;
64}
65
66QString GeoDataSchema::schemaName() const
67{
68 return d->m_name;
69}
70
71void GeoDataSchema::setSchemaName( const QString& name )
72{
73 d->m_name = name;
74}
75
76GeoDataSimpleField& GeoDataSchema::simpleField( const QString& name ) const
77{
78 return d->m_simpleField[ name ];
79}
80
81void GeoDataSchema::addSimpleField( const GeoDataSimpleField &value )
82{
83 d->m_simpleField.insert( value.name(), value );
84}
85
86QList<GeoDataSimpleField> GeoDataSchema::simpleFields() const
87{
88 return d->m_simpleField.values();
89}
90
91const char* GeoDataSchema::nodeType() const
92{
93 return GeoDataTypes::GeoDataSchemaType;
94}
95
96void GeoDataSchema::pack( QDataStream& stream ) const
97{
98 stream << d->m_simpleField.size();
99
100 QHash<QString, GeoDataSimpleField>::const_iterator begin = d->m_simpleField.constBegin();
101 QHash<QString, GeoDataSimpleField>::const_iterator end = d->m_simpleField.constEnd();
102
103 for( ; begin != end; ++begin ) {
104 begin.value().pack( stream );
105 }
106}
107
108void GeoDataSchema::unpack( QDataStream& stream )
109{
110 int size = 0;
111 stream >> size;
112 for( int i = 0; i < size; ++i ) {
113 GeoDataSimpleField simpleField;
114 simpleField.unpack( stream );
115 d->m_simpleField.insert( simpleField.name(), simpleField );
116 }
117}
118
119}
const QList< QKeySequence > & begin()
const QList< QKeySequence > & end()
QString name(StandardShortcut id)
bool equals(const QVariant &lhs, const QVariant &rhs)
Binds a QML item to a specific geodetic location in screen coordinates.
QString & insert(qsizetype position, QChar ch)
bool operator==(const QGraphicsApiFilter &reference, const QGraphicsApiFilter &sample)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:18:17 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.