Marble

GeoDataStyle.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2007 Murad Tagirov <tmurad@gmail.com>
4//
5
6#include "GeoDataStyle.h"
7
8#include "GeoDataBalloonStyle.h"
9#include "GeoDataIconStyle.h"
10#include "GeoDataLabelStyle.h"
11#include "GeoDataLineStyle.h"
12#include "GeoDataListStyle.h"
13#include "GeoDataPolyStyle.h"
14#include "GeoDataTypes.h"
15
16namespace Marble
17{
18
19class GeoDataStylePrivate
20{
21public:
22 GeoDataStylePrivate() = default;
23
24 GeoDataStylePrivate(const QString &iconPath, const QFont &font, const QColor &color)
25 : m_iconStyle(iconPath)
26 , m_labelStyle(font, color)
27 , m_lineStyle(color)
28 , m_polyStyle(color)
29 , m_balloonStyle()
30 {
31 }
32
33 GeoDataIconStyle m_iconStyle;
34 GeoDataLabelStyle m_labelStyle;
35 GeoDataLineStyle m_lineStyle;
36 GeoDataPolyStyle m_polyStyle;
37 GeoDataBalloonStyle m_balloonStyle;
38 GeoDataListStyle m_listStyle;
39};
40
42 : d(new GeoDataStylePrivate)
43{
44}
45
48 , d(new GeoDataStylePrivate(*other.d))
49{
50}
51
52GeoDataStyle::GeoDataStyle(const QString &iconPath, const QFont &font, const QColor &color)
53 : d(new GeoDataStylePrivate(iconPath, font, color))
54{
55}
56
57GeoDataStyle::~GeoDataStyle()
58{
59 delete d;
60}
61
63{
65 *d = *other.d;
66 return *this;
67}
68
69bool GeoDataStyle::operator==(const GeoDataStyle &other) const
70{
71 if (GeoDataStyleSelector::operator!=(other)) {
72 return false;
73 }
74
75 return d->m_iconStyle == other.d->m_iconStyle && d->m_labelStyle == other.d->m_labelStyle && d->m_lineStyle == other.d->m_lineStyle
76 && d->m_polyStyle == other.d->m_polyStyle && d->m_balloonStyle == other.d->m_balloonStyle && d->m_listStyle == other.d->m_listStyle;
77}
78
79bool GeoDataStyle::operator!=(const GeoDataStyle &other) const
80{
81 return !this->operator==(other);
82}
83
84const char *GeoDataStyle::nodeType() const
85{
86 return GeoDataTypes::GeoDataStyleType;
87}
88
89void GeoDataStyle::setIconStyle(const GeoDataIconStyle &style)
90{
91 d->m_iconStyle = style;
92 d->m_iconStyle.setParent(this);
93}
94
96{
97 d->m_lineStyle = style;
98}
99
101{
102 d->m_labelStyle = style;
103}
104
106{
107 d->m_polyStyle = style;
108}
109
110void GeoDataStyle::setBalloonStyle(const GeoDataBalloonStyle &style)
111{
112 d->m_balloonStyle = style;
113}
114
115void GeoDataStyle::setListStyle(const GeoDataListStyle &style)
116{
117 d->m_listStyle = style;
118 d->m_listStyle.setParent(this);
119}
120
121GeoDataIconStyle &GeoDataStyle::iconStyle()
122{
123 return d->m_iconStyle;
124}
125
126const GeoDataIconStyle &GeoDataStyle::iconStyle() const
127{
128 return d->m_iconStyle;
129}
130
132{
133 return d->m_lineStyle;
134}
135
137{
138 return d->m_lineStyle;
139}
140
142{
143 return d->m_polyStyle;
144}
145
147{
148 return d->m_polyStyle;
149}
150
152{
153 return d->m_labelStyle;
154}
155
157{
158 return d->m_labelStyle;
159}
160
161GeoDataBalloonStyle &GeoDataStyle::balloonStyle()
162{
163 return d->m_balloonStyle;
164}
165
166const GeoDataBalloonStyle &GeoDataStyle::balloonStyle() const
167{
168 return d->m_balloonStyle;
169}
170
171GeoDataListStyle &GeoDataStyle::listStyle()
172{
173 return d->m_listStyle;
174}
175
176const GeoDataListStyle &GeoDataStyle::listStyle() const
177{
178 return d->m_listStyle;
179}
180
182{
184
185 d->m_iconStyle.pack(stream);
186 d->m_labelStyle.pack(stream);
187 d->m_polyStyle.pack(stream);
188 d->m_lineStyle.pack(stream);
189 d->m_balloonStyle.pack(stream);
190 d->m_listStyle.pack(stream);
191}
192
194{
196
197 d->m_iconStyle.unpack(stream);
198 d->m_labelStyle.unpack(stream);
199 d->m_lineStyle.unpack(stream);
200 d->m_polyStyle.unpack(stream);
201 d->m_balloonStyle.unpack(stream);
202 d->m_listStyle.unpack(stream);
203}
204
205}
specifies how the name of a GeoDataFeature is drawn
void pack(QDataStream &stream) const override
Serialize the style to a stream.
void unpack(QDataStream &stream) override
Unserialize the style from a stream.
specifies the style how lines are drawn
void unpack(QDataStream &stream) override
Unserialize the style from a stream.
void pack(QDataStream &stream) const override
Serialize the style to a stream.
void setParent(GeoDataObject *parent)
Sets the parent of the object.
specifies the style how polygons are drawn
void unpack(QDataStream &stream) override
Unserialize the style from a stream.
void pack(QDataStream &stream) const override
Serialize the style to a stream.
an abstract base class for the style classes
GeoDataStyleSelector & operator=(const GeoDataStyleSelector &other)
assignment operator
void unpack(QDataStream &stream) override
Unserialize the styleselector from a stream.
void pack(QDataStream &stream) const override
Serialize the styleselector to a stream.
an addressable style group
void setPolyStyle(const GeoDataPolyStyle &style)
set the poly style
void setBalloonStyle(const GeoDataBalloonStyle &style)
set the balloon style
void setIconStyle(const GeoDataIconStyle &style)
set the icon style
GeoDataLineStyle & lineStyle()
Return the label style of this style.
void pack(QDataStream &stream) const override
Serialize the style to a stream.
GeoDataLabelStyle & labelStyle()
Return the label style of this style.
void unpack(QDataStream &stream) override
Unserialize the style from a stream.
GeoDataListStyle & listStyle()
Return the list style of this style.
void setLabelStyle(const GeoDataLabelStyle &style)
set the label style
GeoDataIconStyle & iconStyle()
Return the icon style of this style.
GeoDataStyle & operator=(const GeoDataStyle &other)
assignment operator
void setListStyle(const GeoDataListStyle &style)
set the list style
const char * nodeType() const override
Provides type information for downcasting a GeoNode.
GeoDataPolyStyle & polyStyle()
Return the label style of this style.
void setLineStyle(const GeoDataLineStyle &style)
set the line style
GeoDataStyle()
Construct a default style.
GeoDataBalloonStyle & balloonStyle()
Return the balloon style of this style.
Binds a QML item to a specific geodetic location in screen coordinates.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 8 2024 12:02:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.