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

0001 // SPDX-License-Identifier: LGPL-2.1-or-later
0002 //
0003 // SPDX-FileCopyrightText: 2008 Patrick Spendrin <ps_ml@gmx.de>
0004 //
0005 
0006 
0007 #include "GeoDataStyleMap.h"
0008 #include <QDataStream>
0009 
0010 #include "GeoDataTypes.h"
0011 
0012 namespace Marble
0013 {
0014 
0015 class GeoDataStyleMapPrivate
0016 {
0017   public:
0018     QString lastKey;
0019 };
0020 
0021 
0022 GeoDataStyleMap::GeoDataStyleMap()
0023     : d( new GeoDataStyleMapPrivate )
0024 {
0025 }
0026 
0027 GeoDataStyleMap::GeoDataStyleMap( const GeoDataStyleMap& other )
0028     : GeoDataStyleSelector( other ) , QMap<QString,QString>(other), d( new GeoDataStyleMapPrivate( *other.d ) )
0029 
0030 {
0031 }
0032 
0033 GeoDataStyleMap::~GeoDataStyleMap()
0034 {
0035     delete d;
0036 }
0037 
0038 const char* GeoDataStyleMap::nodeType() const
0039 {
0040     return GeoDataTypes::GeoDataStyleMapType;
0041 }
0042 
0043 QString GeoDataStyleMap::lastKey() const
0044 {
0045     return d->lastKey;
0046 }
0047 
0048 void GeoDataStyleMap::setLastKey( const QString& key )
0049 {
0050     d->lastKey = key;
0051 }
0052 
0053 GeoDataStyleMap& GeoDataStyleMap::operator=( const GeoDataStyleMap& other )
0054 {
0055     QMap<QString, QString>::operator=( other );
0056     GeoDataStyleSelector::operator=( other );
0057     *d = *other.d;
0058     return *this;
0059 }
0060 
0061 bool GeoDataStyleMap::operator==( const GeoDataStyleMap &other ) const
0062 {
0063     if ( GeoDataStyleSelector::operator!=( other ) ||
0064          QMap<QString, QString>::operator!=( other ) )
0065     {
0066         return false;
0067     }
0068 
0069     return d->lastKey == other.d->lastKey;
0070 }
0071 
0072 bool GeoDataStyleMap::operator!=( const GeoDataStyleMap &other ) const
0073 {
0074     return !this->operator==( other );
0075 }
0076 
0077 void GeoDataStyleMap::pack( QDataStream& stream ) const
0078 {
0079     GeoDataStyleSelector::pack( stream );
0080     // lastKey doesn't need to be stored as it is needed at runtime only
0081     stream << *this;
0082 }
0083 
0084 void GeoDataStyleMap::unpack( QDataStream& stream )
0085 {
0086     GeoDataStyleSelector::unpack( stream );
0087     
0088     stream >> *this;
0089 }
0090 
0091 }