Marble

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

KDE's Doxygen guidelines are available online.