File indexing completed on 2025-01-05 03:59:01

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 /*
0065          PORT_QT6
0066          || QMap<QString, QString>::operator!=( other )
0067 */
0068        )
0069     {
0070         return false;
0071     }
0072 
0073     return d->lastKey == other.d->lastKey;
0074 }
0075 
0076 bool GeoDataStyleMap::operator!=( const GeoDataStyleMap &other ) const
0077 {
0078     return !this->operator==( other );
0079 }
0080 
0081 void GeoDataStyleMap::pack( QDataStream& stream ) const
0082 {
0083     GeoDataStyleSelector::pack( stream );
0084     // lastKey doesn't need to be stored as it is needed at runtime only
0085     stream << *this;
0086 }
0087 
0088 void GeoDataStyleMap::unpack( QDataStream& stream )
0089 {
0090     GeoDataStyleSelector::unpack( stream );
0091 
0092     stream >> *this;
0093 }
0094 
0095 }