Marble

GeoDataSchema.cpp
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2014 Abhinav Gangwar <[email protected]>
4 //
5 
6 #include "GeoDataSchema.h"
7 
8 // Qt
9 #include <QDataStream>
10 
11 // Marble
12 #include "GeoDataTypes.h"
13 #include "GeoDataSimpleField.h"
14 
15 namespace Marble
16 {
17 
18 class GeoDataSchemaPrivate
19 {
20  public:
22  QString m_name;
23 };
24 
25 GeoDataSchema::GeoDataSchema()
26  : d( new GeoDataSchemaPrivate )
27 {
28 }
29 
30 GeoDataSchema::GeoDataSchema( const QHash<QString, GeoDataSimpleField>& simplefields )
31  : d( new GeoDataSchemaPrivate )
32 {
33  d->m_simpleField = simplefields;
34 }
35 
36 GeoDataSchema::GeoDataSchema( const GeoDataSchema& other )
37  : GeoDataObject( other ),
38  d( new GeoDataSchemaPrivate( *other.d ) )
39 {
40 }
41 
42 GeoDataSchema &GeoDataSchema::operator=(const GeoDataSchema &other)
43 {
44  GeoDataObject::operator=( other );
45  *d = *other.d;
46  return *this;
47 }
48 
49 bool 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 
56 bool GeoDataSchema::operator!=(const GeoDataSchema& other) const
57 {
58  return !this->operator==( other );
59 }
60 
61 GeoDataSchema::~GeoDataSchema()
62 {
63  delete d;
64 }
65 
66 QString GeoDataSchema::schemaName() const
67 {
68  return d->m_name;
69 }
70 
71 void GeoDataSchema::setSchemaName( const QString& name )
72 {
73  d->m_name = name;
74 }
75 
76 GeoDataSimpleField& GeoDataSchema::simpleField( const QString& name ) const
77 {
78  return d->m_simpleField[ name ];
79 }
80 
81 void GeoDataSchema::addSimpleField( const GeoDataSimpleField &value )
82 {
83  d->m_simpleField.insert( value.name(), value );
84 }
85 
86 QList<GeoDataSimpleField> GeoDataSchema::simpleFields() const
87 {
88  return d->m_simpleField.values();
89 }
90 
91 const char* GeoDataSchema::nodeType() const
92 {
93  return GeoDataTypes::GeoDataSchemaType;
94 }
95 
96 void 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 
108 void 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()
bool operator==(const Qt3DRender::QGraphicsApiFilter &reference, const Qt3DRender::QGraphicsApiFilter &sample)
Binds a QML item to a specific geodetic location in screen coordinates.
const char * name(StandardAction id)
const QList< QKeySequence > & end()
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Wed Oct 4 2023 04:09:41 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.