File indexing completed on 2025-01-05 03:58:55
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2007 Murad Tagirov <tmurad@gmail.com> 0004 // SPDX-FileCopyrightText: 2008 Inge Wallin <inge@lysator.liu.se> 0005 // 0006 0007 0008 #include "GeoDataHotSpot.h" 0009 0010 #include <QDataStream> 0011 0012 #include "GeoDataTypes.h" 0013 0014 namespace Marble 0015 { 0016 0017 class GeoDataHotSpotPrivate 0018 { 0019 public: 0020 GeoDataHotSpotPrivate() 0021 { 0022 } 0023 0024 GeoDataHotSpotPrivate( const QPointF& hotSpot, GeoDataHotSpot::Units xunits, GeoDataHotSpot::Units yunits ) 0025 : m_hotSpot( hotSpot ), 0026 m_xunits( xunits ), 0027 m_yunits( yunits ) 0028 { 0029 } 0030 0031 QPointF m_hotSpot; 0032 GeoDataHotSpot::Units m_xunits; 0033 GeoDataHotSpot::Units m_yunits; 0034 }; 0035 0036 GeoDataHotSpot::GeoDataHotSpot( const QPointF& hotSpot, Units xunits, Units yunits ) 0037 : d( new GeoDataHotSpotPrivate( hotSpot, xunits, yunits ) ) 0038 { 0039 } 0040 0041 GeoDataHotSpot::GeoDataHotSpot( const GeoDataHotSpot& other ) 0042 : GeoDataObject(other), d( new GeoDataHotSpotPrivate( *other.d ) ) 0043 { 0044 } 0045 0046 GeoDataHotSpot::~GeoDataHotSpot() 0047 { 0048 delete d; 0049 } 0050 0051 GeoDataHotSpot& GeoDataHotSpot::operator=( const GeoDataHotSpot& other ) 0052 { 0053 GeoDataObject::operator=( other ); 0054 0055 *d = *other.d; 0056 return *this; 0057 } 0058 0059 bool GeoDataHotSpot::operator==( const GeoDataHotSpot& other ) const 0060 { 0061 return equals(other) && 0062 d->m_hotSpot == other.d->m_hotSpot && 0063 d->m_xunits == other.d->m_xunits && 0064 d->m_yunits == other.d->m_yunits; 0065 } 0066 0067 bool GeoDataHotSpot::operator!=( const GeoDataHotSpot& other ) const 0068 { 0069 return !this->operator==(other); 0070 } 0071 0072 const QPointF& GeoDataHotSpot::hotSpot( Units& xunits, Units& yunits ) const 0073 { 0074 xunits = d->m_xunits; 0075 yunits = d->m_yunits; 0076 0077 return d->m_hotSpot; 0078 } 0079 0080 0081 void GeoDataHotSpot::setHotSpot( const QPointF& hotSpot, Units xunits, Units yunits ) 0082 { 0083 d->m_hotSpot = hotSpot; 0084 d->m_xunits = xunits; 0085 d->m_yunits = yunits; 0086 } 0087 0088 const char* GeoDataHotSpot::nodeType() const 0089 { 0090 return GeoDataTypes::GeoDataHotspotType; 0091 } 0092 0093 void GeoDataHotSpot::pack( QDataStream& stream ) const 0094 { 0095 GeoDataObject::pack( stream ); 0096 0097 stream << d->m_xunits << d->m_yunits; 0098 stream << d->m_hotSpot; 0099 } 0100 0101 void GeoDataHotSpot::unpack( QDataStream& stream ) 0102 { 0103 GeoDataObject::unpack( stream ); 0104 int xu, yu; 0105 stream >> xu >> yu; 0106 d->m_xunits = static_cast<Units>(xu); 0107 d->m_yunits = static_cast<Units>(yu); 0108 stream >> d->m_hotSpot; 0109 } 0110 0111 }