Marble

GeoDataListStyle.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2012 Mohammed Nafees <nafees.technocool@gmail.com>
4//
5
6#include "GeoDataListStyle.h"
7#include "GeoDataTypes.h"
8#include "GeoDataItemIcon.h"
9#include "MarbleDirs.h"
10
11#include <QDataStream>
12
13namespace Marble
14{
15
16class GeoDataListStylePrivate
17{
18public:
19 GeoDataListStylePrivate();
20
21 GeoDataListStyle::ListItemType m_listItemType;
22 QColor m_bgColor;
23
25};
26
27GeoDataListStylePrivate::GeoDataListStylePrivate() :
28 m_listItemType( GeoDataListStyle::Check ),
29 m_bgColor( Qt::white )
30{
31}
32
33GeoDataListStyle::GeoDataListStyle() :
34 d( new GeoDataListStylePrivate )
35{
36}
37
38GeoDataListStyle::GeoDataListStyle( const Marble::GeoDataListStyle &other ) :
39 GeoDataObject( other ), d( new GeoDataListStylePrivate( *other.d ) )
40{
41}
42
43GeoDataListStyle &GeoDataListStyle::operator=( const GeoDataListStyle &other )
44{
45 GeoDataObject::operator=(other);
46 *d = *other.d;
47 return *this;
48}
49
50bool 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
73bool GeoDataListStyle::operator!=( const GeoDataListStyle &other ) const
74{
75 return !this->operator==( other );
76}
77
78GeoDataListStyle::~GeoDataListStyle()
79{
80 delete d;
81}
82
83const char *GeoDataListStyle::nodeType() const
84{
85 return GeoDataTypes::GeoDataListStyleType;
86}
87
88GeoDataListStyle::ListItemType GeoDataListStyle::listItemType() const
89{
90 return d->m_listItemType;
91}
92
93void GeoDataListStyle::setListItemType(ListItemType type)
94{
95 d->m_listItemType = type;
96}
97
98QColor GeoDataListStyle::backgroundColor() const
99{
100 return d->m_bgColor;
101}
102
103void GeoDataListStyle::setBackgroundColor( const QColor &color )
104{
105 d->m_bgColor = color;
106}
107
108QVector<GeoDataItemIcon*> GeoDataListStyle::itemIconList() const
109{
110 return d->m_vector;
111}
112
113GeoDataItemIcon* GeoDataListStyle::child( int i )
114{
115 return d->m_vector.at(i);
116}
117
118const GeoDataItemIcon* GeoDataListStyle::child( int i ) const
119{
120 return d->m_vector.at(i);
121}
122
123int GeoDataListStyle::childPosition( const GeoDataItemIcon* object ) const
124{
125 return d->m_vector.indexOf( const_cast<GeoDataItemIcon *>( object ) );
126}
127
128void GeoDataListStyle::append( GeoDataItemIcon *other )
129{
130 other->setParent( this );
131 d->m_vector.append( other );
132}
133
134
135void GeoDataListStyle::remove( int index )
136{
137 d->m_vector.remove( index );
138}
139
140int GeoDataListStyle::size() const
141{
142 return d->m_vector.size();
143}
144
145GeoDataItemIcon& GeoDataListStyle::at( int pos )
146{
147 return *(d->m_vector[ pos ]);
148}
149
150const GeoDataItemIcon& GeoDataListStyle::at( int pos ) const
151{
152 return *(d->m_vector.at( pos ));
153}
154
155GeoDataItemIcon& GeoDataListStyle::last()
156{
157 return *(d->m_vector.last());
158}
159
160const GeoDataItemIcon& GeoDataListStyle::last() const
161{
162 return *(d->m_vector.last());
163}
164
165GeoDataItemIcon& GeoDataListStyle::first()
166{
167 return *(d->m_vector.first());
168}
169
170const GeoDataItemIcon& GeoDataListStyle::first() const
171{
172 return *(d->m_vector.first());
173}
174
175void GeoDataListStyle::clear()
176{
177 qDeleteAll(d->m_vector);
178 d->m_vector.clear();
179}
180
181QVector<GeoDataItemIcon*>::Iterator GeoDataListStyle::begin()
182{
183 return d->m_vector.begin();
184}
185
186QVector<GeoDataItemIcon*>::Iterator GeoDataListStyle::end()
187{
188 return d->m_vector.end();
189}
190
191QVector<GeoDataItemIcon*>::ConstIterator GeoDataListStyle::constBegin() const
192{
193 return d->m_vector.constBegin();
194}
195
196QVector<GeoDataItemIcon*>::ConstIterator GeoDataListStyle::constEnd() const
197{
198 return d->m_vector.constEnd();
199}
200
201void 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
215void 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}
VehicleSection::Type type(QStringView coachNumber, QStringView coachClassification)
const QList< QKeySequence > & begin()
const QList< QKeySequence > & end()
Binds a QML item to a specific geodetic location in screen coordinates.
const_reference at(qsizetype i) const const
iterator begin()
const_iterator constBegin() const const
const_iterator constEnd() const const
iterator end()
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 Fri Jun 14 2024 11:54:16 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.