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 "GeoDataItemIcon.h"
8#include "GeoDataTypes.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)
40 , d(new GeoDataListStylePrivate(*other.d))
41{
42}
43
44GeoDataListStyle &GeoDataListStyle::operator=(const GeoDataListStyle &other)
45{
46 GeoDataObject::operator=(other);
47 *d = *other.d;
48 return *this;
49}
50
51bool GeoDataListStyle::operator==(const GeoDataListStyle &other) const
52{
53 if (!GeoDataObject::equals(other) || d->m_bgColor != other.d->m_bgColor || d->m_listItemType != other.d->m_listItemType
54 || d->m_vector.size() != other.d->m_vector.size()) {
55 return false;
56 }
57
58 QList<GeoDataItemIcon *>::const_iterator begin = d->m_vector.constBegin();
59 QList<GeoDataItemIcon *>::const_iterator end = d->m_vector.constEnd();
60 QList<GeoDataItemIcon *>::const_iterator otherBegin = other.d->m_vector.constBegin();
61
62 for (; begin != end; ++begin, ++otherBegin) {
63 if (**begin != **otherBegin) {
64 return false;
65 }
66 }
67
68 return true;
69}
70
71bool GeoDataListStyle::operator!=(const GeoDataListStyle &other) const
72{
73 return !this->operator==(other);
74}
75
76GeoDataListStyle::~GeoDataListStyle()
77{
78 delete d;
79}
80
81const char *GeoDataListStyle::nodeType() const
82{
83 return GeoDataTypes::GeoDataListStyleType;
84}
85
86GeoDataListStyle::ListItemType GeoDataListStyle::listItemType() const
87{
88 return d->m_listItemType;
89}
90
91void GeoDataListStyle::setListItemType(ListItemType type)
92{
93 d->m_listItemType = type;
94}
95
96QColor GeoDataListStyle::backgroundColor() const
97{
98 return d->m_bgColor;
99}
100
101void GeoDataListStyle::setBackgroundColor(const QColor &color)
102{
103 d->m_bgColor = color;
104}
105
106QList<GeoDataItemIcon *> GeoDataListStyle::itemIconList() const
107{
108 return d->m_vector;
109}
110
111GeoDataItemIcon *GeoDataListStyle::child(int i)
112{
113 return d->m_vector.at(i);
114}
115
116const GeoDataItemIcon *GeoDataListStyle::child(int i) const
117{
118 return d->m_vector.at(i);
119}
120
121int GeoDataListStyle::childPosition(const GeoDataItemIcon *object) const
122{
123 return d->m_vector.indexOf(const_cast<GeoDataItemIcon *>(object));
124}
125
126void GeoDataListStyle::append(GeoDataItemIcon *other)
127{
128 other->setParent(this);
129 d->m_vector.append(other);
130}
131
132void GeoDataListStyle::remove(int index)
133{
134 d->m_vector.remove(index);
135}
136
137int GeoDataListStyle::size() const
138{
139 return d->m_vector.size();
140}
141
142GeoDataItemIcon &GeoDataListStyle::at(int pos)
143{
144 return *(d->m_vector[pos]);
145}
146
147const GeoDataItemIcon &GeoDataListStyle::at(int pos) const
148{
149 return *(d->m_vector.at(pos));
150}
151
152GeoDataItemIcon &GeoDataListStyle::last()
153{
154 return *(d->m_vector.last());
155}
156
157const GeoDataItemIcon &GeoDataListStyle::last() const
158{
159 return *(d->m_vector.last());
160}
161
162GeoDataItemIcon &GeoDataListStyle::first()
163{
164 return *(d->m_vector.first());
165}
166
167const GeoDataItemIcon &GeoDataListStyle::first() const
168{
169 return *(d->m_vector.first());
170}
171
172void GeoDataListStyle::clear()
173{
174 qDeleteAll(d->m_vector);
175 d->m_vector.clear();
176}
177
178QList<GeoDataItemIcon *>::Iterator GeoDataListStyle::begin()
179{
180 return d->m_vector.begin();
181}
182
183QList<GeoDataItemIcon *>::Iterator GeoDataListStyle::end()
184{
185 return d->m_vector.end();
186}
187
188QList<GeoDataItemIcon *>::ConstIterator GeoDataListStyle::constBegin() const
189{
190 return d->m_vector.constBegin();
191}
192
193QList<GeoDataItemIcon *>::ConstIterator GeoDataListStyle::constEnd() const
194{
195 return d->m_vector.constEnd();
196}
197
198void GeoDataListStyle::pack(QDataStream &stream) const
199{
200 GeoDataObject::pack(stream);
201 stream << d->m_vector.count();
202
203 for (QList<GeoDataItemIcon *>::const_iterator iterator = d->m_vector.constBegin(); iterator != d->m_vector.constEnd(); ++iterator) {
204 const GeoDataItemIcon *itemIcon = *iterator;
205 itemIcon->pack(stream);
206 }
207}
208
209void GeoDataListStyle::unpack(QDataStream &stream)
210{
211 GeoDataObject::unpack(stream);
212
213 int count;
214 stream >> count;
215
216 int featureId;
217 stream >> featureId;
218
219 auto itemIcon = new GeoDataItemIcon;
220 itemIcon->unpack(stream);
221 d->m_vector.append(itemIcon);
222}
223
224}
KIOCORE_EXPORT bool operator==(const UDSEntry &entry, const UDSEntry &other)
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
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 20 2024 11:52:12 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.