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

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2012 Mohammed Nafees <nafees.technocool@gmail.com>
0004 //
0005 
0006 #include "GeoDataBalloonStyle.h"
0007 #include "GeoDataTypes.h"
0008 
0009 #include <QDataStream>
0010 
0011 namespace Marble
0012 {
0013 
0014 class GeoDataBalloonStylePrivate
0015 {
0016 public:
0017     GeoDataBalloonStylePrivate();
0018 
0019     QColor m_bgColor;
0020     QColor m_textColor;
0021     QString m_text;
0022     GeoDataBalloonStyle::DisplayMode m_mode;
0023 };
0024 
0025 GeoDataBalloonStylePrivate::GeoDataBalloonStylePrivate() :
0026     m_bgColor( Qt::white ),
0027     m_textColor( Qt::black ),
0028     m_mode( GeoDataBalloonStyle::Default )
0029 {
0030 }
0031 
0032 GeoDataBalloonStyle::GeoDataBalloonStyle() :
0033     d( new GeoDataBalloonStylePrivate )
0034 {
0035 }
0036 
0037 GeoDataBalloonStyle::GeoDataBalloonStyle( const Marble::GeoDataBalloonStyle &other ) :
0038     GeoDataColorStyle( other ), d( new GeoDataBalloonStylePrivate( *other.d ) )
0039 {
0040 }
0041 
0042 GeoDataBalloonStyle &GeoDataBalloonStyle::operator=( const GeoDataBalloonStyle &other )
0043 {
0044     GeoDataColorStyle::operator=(other);
0045     *d = *other.d;
0046     return *this;
0047 }
0048 
0049 bool GeoDataBalloonStyle::operator==( const GeoDataBalloonStyle &other ) const
0050 {
0051     return equals(other) &&
0052            d->m_bgColor == other.d->m_bgColor &&
0053            d->m_mode == other.d->m_mode &&
0054            d->m_text == other.d->m_text &&
0055            d->m_textColor == other.d->m_textColor;
0056 }
0057 
0058 bool GeoDataBalloonStyle::operator!=( const GeoDataBalloonStyle &other ) const
0059 {
0060     return !this->operator==(other);
0061 }
0062 
0063 GeoDataBalloonStyle::~GeoDataBalloonStyle()
0064 {
0065     delete d;
0066 }
0067 
0068 const char *GeoDataBalloonStyle::nodeType() const
0069 {
0070     return GeoDataTypes::GeoDataBalloonStyleType;
0071 }
0072 
0073 QColor GeoDataBalloonStyle::backgroundColor() const
0074 {
0075     return d->m_bgColor;
0076 }
0077 
0078 void GeoDataBalloonStyle::setBackgroundColor( const QColor &color )
0079 {
0080     d->m_bgColor = color;
0081 }
0082 
0083 QColor GeoDataBalloonStyle::textColor() const
0084 {
0085     return d->m_textColor;
0086 }
0087 
0088 void GeoDataBalloonStyle::setTextColor( const QColor &color )
0089 {
0090     d->m_textColor = color;
0091 }
0092 
0093 QString GeoDataBalloonStyle::text() const
0094 {
0095     return d->m_text;
0096 }
0097 
0098 void GeoDataBalloonStyle::setText( const QString &text )
0099 {
0100     d->m_text = text;
0101 }
0102 
0103 GeoDataBalloonStyle::DisplayMode GeoDataBalloonStyle::displayMode() const
0104 {
0105     return d->m_mode;
0106 }
0107 
0108 void GeoDataBalloonStyle::setDisplayMode(DisplayMode mode)
0109 {
0110     d->m_mode = mode;
0111 }
0112 
0113 void GeoDataBalloonStyle::pack( QDataStream& stream ) const
0114 {
0115     GeoDataColorStyle::pack( stream );
0116 
0117     stream << d->m_bgColor.name();
0118     stream << d->m_textColor.name();
0119     stream << d->m_text;
0120 }
0121 
0122 void GeoDataBalloonStyle::unpack( QDataStream& stream )
0123 {
0124     GeoDataColorStyle::unpack( stream );
0125 
0126     stream >> d->m_bgColor;
0127     stream >> d->m_textColor;
0128     stream >> d->m_text;
0129 }
0130 
0131 }