File indexing completed on 2024-05-12 03:50:18

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2007 Murad Tagirov <tmurad@gmail.com>
0004 //
0005 
0006 
0007 #include "GeoDataStyle.h"
0008 
0009 #include "GeoDataTypes.h"
0010 #include "GeoDataBalloonStyle.h"
0011 #include "GeoDataIconStyle.h"
0012 #include "GeoDataLabelStyle.h"
0013 #include "GeoDataLineStyle.h"
0014 #include "GeoDataListStyle.h"
0015 #include "GeoDataPolyStyle.h"
0016 
0017 namespace Marble
0018 {
0019 
0020 class GeoDataStylePrivate
0021 {
0022   public:
0023     GeoDataStylePrivate()
0024     {
0025     }
0026 
0027     GeoDataStylePrivate(const QString& iconPath,
0028                         const QFont &font, const QColor &color )
0029         : m_iconStyle( iconPath ),
0030           m_labelStyle( font, color ),
0031           m_lineStyle( color ),
0032           m_polyStyle( color ),
0033           m_balloonStyle()
0034     {
0035     }
0036 
0037     GeoDataIconStyle   m_iconStyle;
0038     GeoDataLabelStyle  m_labelStyle;
0039     GeoDataLineStyle   m_lineStyle;
0040     GeoDataPolyStyle   m_polyStyle;
0041     GeoDataBalloonStyle m_balloonStyle;
0042     GeoDataListStyle m_listStyle;
0043 };
0044 
0045 GeoDataStyle::GeoDataStyle()
0046     : d( new GeoDataStylePrivate )
0047 {
0048 }
0049 
0050 GeoDataStyle::GeoDataStyle( const GeoDataStyle& other )
0051     : GeoDataStyleSelector( other ), d( new GeoDataStylePrivate( *other.d ) )
0052 {
0053 }
0054 
0055 GeoDataStyle::GeoDataStyle( const QString& iconPath,
0056                             const QFont &font, const QColor &color  )
0057     : d( new GeoDataStylePrivate( iconPath, font, color ) )
0058 {
0059 }
0060 
0061 GeoDataStyle::~GeoDataStyle()
0062 {
0063     delete d;
0064 }
0065 
0066 GeoDataStyle& GeoDataStyle::operator=( const GeoDataStyle& other )
0067 {
0068     GeoDataStyleSelector::operator=( other );
0069     *d = *other.d;
0070     return *this;
0071 }
0072 
0073 bool GeoDataStyle::operator==( const GeoDataStyle &other ) const
0074 {
0075     if ( GeoDataStyleSelector::operator!=( other ) ) {
0076         return false;
0077     }
0078 
0079     return d->m_iconStyle == other.d->m_iconStyle &&
0080            d->m_labelStyle == other.d->m_labelStyle &&
0081            d->m_lineStyle == other.d->m_lineStyle &&
0082            d->m_polyStyle == other.d->m_polyStyle &&
0083            d->m_balloonStyle == other.d->m_balloonStyle &&
0084            d->m_listStyle == other.d->m_listStyle;
0085 }
0086 
0087 bool GeoDataStyle::operator!=( const GeoDataStyle &other ) const
0088 {
0089     return !this->operator==( other );
0090 }
0091 
0092 const char* GeoDataStyle::nodeType() const
0093 {
0094     return GeoDataTypes::GeoDataStyleType;
0095 }
0096 
0097 void GeoDataStyle::setIconStyle( const GeoDataIconStyle& style )
0098 {
0099     d->m_iconStyle = style;
0100     d->m_iconStyle.setParent( this );
0101 }
0102 
0103 void GeoDataStyle::setLineStyle( const GeoDataLineStyle& style )
0104 {
0105     d->m_lineStyle = style;
0106 }
0107 
0108 void GeoDataStyle::setLabelStyle( const GeoDataLabelStyle& style )
0109 {
0110     d->m_labelStyle = style;
0111 }
0112 
0113 void GeoDataStyle::setPolyStyle( const GeoDataPolyStyle& style )
0114 {
0115     d->m_polyStyle = style;
0116 }
0117 
0118 void GeoDataStyle::setBalloonStyle( const GeoDataBalloonStyle& style )
0119 {
0120     d->m_balloonStyle = style;
0121 }
0122 
0123 void GeoDataStyle::setListStyle( const GeoDataListStyle& style )
0124 {
0125     d->m_listStyle = style;
0126     d->m_listStyle.setParent( this );
0127 }
0128 
0129 GeoDataIconStyle& GeoDataStyle::iconStyle()
0130 {
0131     return d->m_iconStyle;
0132 }
0133 
0134 const GeoDataIconStyle& GeoDataStyle::iconStyle() const
0135 {
0136     return d->m_iconStyle;
0137 }
0138 
0139 GeoDataLineStyle& GeoDataStyle::lineStyle()
0140 {
0141     return d->m_lineStyle;
0142 }
0143 
0144 const GeoDataLineStyle& GeoDataStyle::lineStyle() const
0145 {
0146     return d->m_lineStyle;
0147 }
0148 
0149 GeoDataPolyStyle& GeoDataStyle::polyStyle()
0150 {
0151     return d->m_polyStyle;
0152 }
0153 
0154 const GeoDataPolyStyle& GeoDataStyle::polyStyle() const
0155 {
0156     return d->m_polyStyle;
0157 }
0158 
0159 GeoDataLabelStyle& GeoDataStyle::labelStyle()
0160 {
0161     return d->m_labelStyle;
0162 }
0163 
0164 const GeoDataLabelStyle& GeoDataStyle::labelStyle() const
0165 {
0166     return d->m_labelStyle;
0167 }
0168 
0169 GeoDataBalloonStyle& GeoDataStyle::balloonStyle()
0170 {
0171     return d->m_balloonStyle;
0172 }
0173 
0174 const GeoDataBalloonStyle& GeoDataStyle::balloonStyle() const
0175 {
0176     return d->m_balloonStyle;
0177 }
0178 
0179 GeoDataListStyle& GeoDataStyle::listStyle()
0180 {
0181     return d->m_listStyle;
0182 }
0183 
0184 const GeoDataListStyle& GeoDataStyle::listStyle() const
0185 {
0186     return d->m_listStyle;
0187 }
0188 
0189 void GeoDataStyle::pack( QDataStream& stream ) const
0190 {
0191     GeoDataStyleSelector::pack( stream );
0192 
0193     d->m_iconStyle.pack( stream );
0194     d->m_labelStyle.pack( stream );
0195     d->m_polyStyle.pack( stream );
0196     d->m_lineStyle.pack( stream );
0197     d->m_balloonStyle.pack( stream );
0198     d->m_listStyle.pack( stream );
0199 }
0200 
0201 void GeoDataStyle::unpack( QDataStream& stream )
0202 {
0203     GeoDataStyleSelector::unpack( stream );
0204 
0205     d->m_iconStyle.unpack( stream );
0206     d->m_labelStyle.unpack( stream );
0207     d->m_lineStyle.unpack( stream );
0208     d->m_polyStyle.unpack( stream );
0209     d->m_balloonStyle.unpack( stream );
0210     d->m_listStyle.unpack( stream );
0211 }
0212 
0213 }