Marble

GeoDataListStyle.cpp
1 // SPDX-License-Identifier: LGPL-2.1-or-later
2 //
3 // SPDX-FileCopyrightText: 2012 Mohammed Nafees <[email protected]>
4 //
5 
6 #include "GeoDataListStyle.h"
7 #include "GeoDataTypes.h"
8 #include "GeoDataItemIcon.h"
9 #include "MarbleDirs.h"
10 
11 #include <QDataStream>
12 
13 namespace Marble
14 {
15 
16 class GeoDataListStylePrivate
17 {
18 public:
19  GeoDataListStylePrivate();
20 
21  GeoDataListStyle::ListItemType m_listItemType;
22  QColor m_bgColor;
23 
25 };
26 
27 GeoDataListStylePrivate::GeoDataListStylePrivate() :
28  m_listItemType( GeoDataListStyle::Check ),
29  m_bgColor( Qt::white )
30 {
31 }
32 
33 GeoDataListStyle::GeoDataListStyle() :
34  d( new GeoDataListStylePrivate )
35 {
36 }
37 
38 GeoDataListStyle::GeoDataListStyle( const Marble::GeoDataListStyle &other ) :
39  GeoDataObject( other ), d( new GeoDataListStylePrivate( *other.d ) )
40 {
41 }
42 
43 GeoDataListStyle &GeoDataListStyle::operator=( const GeoDataListStyle &other )
44 {
45  GeoDataObject::operator=(other);
46  *d = *other.d;
47  return *this;
48 }
49 
50 bool GeoDataListStyle::operator==( const GeoDataListStyle &other ) const
51 {
52  if ( !GeoDataObject::equals( other ) ||
53  d->m_bgColor != other.d->m_bgColor ||
54  d->m_listItemType != other.d->m_listItemType ||
55  d->m_vector.size() != other.d->m_vector.size() )
56  {
57  return false;
58  }
59 
60  QVector<GeoDataItemIcon*>::const_iterator begin = d->m_vector.constBegin();
61  QVector<GeoDataItemIcon*>::const_iterator end = d->m_vector.constEnd();
62  QVector<GeoDataItemIcon*>::const_iterator otherBegin = other.d->m_vector.constBegin();
63 
64  for( ; begin != end; ++begin, ++otherBegin ) {
65  if ( **begin != **otherBegin ) {
66  return false;
67  }
68  }
69 
70  return true;
71 }
72 
73 bool GeoDataListStyle::operator!=( const GeoDataListStyle &other ) const
74 {
75  return !this->operator==( other );
76 }
77 
78 GeoDataListStyle::~GeoDataListStyle()
79 {
80  delete d;
81 }
82 
83 const char *GeoDataListStyle::nodeType() const
84 {
85  return GeoDataTypes::GeoDataListStyleType;
86 }
87 
88 GeoDataListStyle::ListItemType GeoDataListStyle::listItemType() const
89 {
90  return d->m_listItemType;
91 }
92 
93 void GeoDataListStyle::setListItemType(ListItemType type)
94 {
95  d->m_listItemType = type;
96 }
97 
98 QColor GeoDataListStyle::backgroundColor() const
99 {
100  return d->m_bgColor;
101 }
102 
103 void GeoDataListStyle::setBackgroundColor( const QColor &color )
104 {
105  d->m_bgColor = color;
106 }
107 
108 QVector<GeoDataItemIcon*> GeoDataListStyle::itemIconList() const
109 {
110  return d->m_vector;
111 }
112 
113 GeoDataItemIcon* GeoDataListStyle::child( int i )
114 {
115  return d->m_vector.at(i);
116 }
117 
118 const GeoDataItemIcon* GeoDataListStyle::child( int i ) const
119 {
120  return d->m_vector.at(i);
121 }
122 
123 int GeoDataListStyle::childPosition( const GeoDataItemIcon* object ) const
124 {
125  return d->m_vector.indexOf( const_cast<GeoDataItemIcon *>( object ) );
126 }
127 
128 void GeoDataListStyle::append( GeoDataItemIcon *other )
129 {
130  other->setParent( this );
131  d->m_vector.append( other );
132 }
133 
134 
135 void GeoDataListStyle::remove( int index )
136 {
137  d->m_vector.remove( index );
138 }
139 
140 int GeoDataListStyle::size() const
141 {
142  return d->m_vector.size();
143 }
144 
145 GeoDataItemIcon& GeoDataListStyle::at( int pos )
146 {
147  return *(d->m_vector[ pos ]);
148 }
149 
150 const GeoDataItemIcon& GeoDataListStyle::at( int pos ) const
151 {
152  return *(d->m_vector.at( pos ));
153 }
154 
155 GeoDataItemIcon& GeoDataListStyle::last()
156 {
157  return *(d->m_vector.last());
158 }
159 
160 const GeoDataItemIcon& GeoDataListStyle::last() const
161 {
162  return *(d->m_vector.last());
163 }
164 
165 GeoDataItemIcon& GeoDataListStyle::first()
166 {
167  return *(d->m_vector.first());
168 }
169 
170 const GeoDataItemIcon& GeoDataListStyle::first() const
171 {
172  return *(d->m_vector.first());
173 }
174 
175 void GeoDataListStyle::clear()
176 {
177  qDeleteAll(d->m_vector);
178  d->m_vector.clear();
179 }
180 
181 QVector<GeoDataItemIcon*>::Iterator GeoDataListStyle::begin()
182 {
183  return d->m_vector.begin();
184 }
185 
186 QVector<GeoDataItemIcon*>::Iterator GeoDataListStyle::end()
187 {
188  return d->m_vector.end();
189 }
190 
191 QVector<GeoDataItemIcon*>::ConstIterator GeoDataListStyle::constBegin() const
192 {
193  return d->m_vector.constBegin();
194 }
195 
196 QVector<GeoDataItemIcon*>::ConstIterator GeoDataListStyle::constEnd() const
197 {
198  return d->m_vector.constEnd();
199 }
200 
201 void GeoDataListStyle::pack( QDataStream& stream ) const
202 {
203  GeoDataObject::pack( stream );
204  stream << d->m_vector.count();
205 
206  for ( QVector <GeoDataItemIcon*>::const_iterator iterator = d->m_vector.constBegin();
207  iterator != d->m_vector.constEnd();
208  ++iterator )
209  {
210  const GeoDataItemIcon *itemIcon = *iterator;
211  itemIcon->pack( stream );
212  }
213 }
214 
215 void GeoDataListStyle::unpack( QDataStream& stream )
216 {
217  GeoDataObject::unpack( stream );
218 
219  int count;
220  stream >> count;
221 
222  int featureId;
223  stream >> featureId;
224 
225  GeoDataItemIcon *itemIcon = new GeoDataItemIcon;
226  itemIcon->unpack( stream );
227  d->m_vector.append( itemIcon );
228 }
229 
230 }
Type type(const QSqlDatabase &db)
QVector::iterator begin()
QVector::const_iterator constEnd() const const
const QList< QKeySequence > & begin()
bool operator==(const Qt3DRender::QGraphicsApiFilter &reference, const Qt3DRender::QGraphicsApiFilter &sample)
const T & at(int i) const const
void pack(QDataStream &stream) const override
Reimplemented from Serializable.
Binds a QML item to a specific geodetic location in screen coordinates.
virtual bool equals(const GeoDataObject &other) const
Compares the value of id and targetId of the two objects.
QVector::iterator end()
QVector::const_iterator constBegin() const const
void unpack(QDataStream &steam) override
Reimplemented from Serializable.
const QList< QKeySequence > & end()
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Oct 2 2023 03:52:08 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.