File indexing completed on 2025-01-05 03:59:01
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2013 Mohammed Nafees <nafees.technocool@gmail.com> 0004 // 0005 0006 #include "GeoDataUpdate.h" 0007 0008 #include "GeoDataCreate.h" 0009 #include "GeoDataDelete.h" 0010 #include "GeoDataChange.h" 0011 #include "GeoDataTypes.h" 0012 0013 #include <QString> 0014 0015 namespace Marble 0016 { 0017 0018 class GeoDataUpdatePrivate 0019 { 0020 public: 0021 GeoDataUpdatePrivate(); 0022 GeoDataCreate* m_create; 0023 GeoDataDelete* m_delete; 0024 GeoDataChange* m_change; 0025 QString m_targetHref; 0026 }; 0027 0028 GeoDataUpdatePrivate::GeoDataUpdatePrivate() : 0029 m_create( nullptr ), m_delete( nullptr ), m_change( nullptr ) 0030 { 0031 } 0032 0033 GeoDataUpdate::GeoDataUpdate() : 0034 d( new GeoDataUpdatePrivate ) 0035 { 0036 } 0037 0038 GeoDataUpdate::GeoDataUpdate( const Marble::GeoDataUpdate &other ) : 0039 GeoDataObject(), d( new GeoDataUpdatePrivate( *other.d ) ) 0040 { 0041 } 0042 0043 GeoDataUpdate &GeoDataUpdate::operator=( const GeoDataUpdate &other ) 0044 { 0045 GeoDataObject::operator =( other ); 0046 *d = *other.d; 0047 return *this; 0048 } 0049 0050 bool GeoDataUpdate::operator==(const GeoDataUpdate& other) const 0051 { 0052 bool const changeEmpty = !d->m_change || d->m_change->size() == 0; 0053 bool const otherChangeEmpty = !other.d->m_change || other.d->m_change->size() == 0; 0054 0055 if( changeEmpty != otherChangeEmpty ) { 0056 return false; 0057 } else if( d->m_change && other.d->m_change && *d->m_change != *other.d->m_change ) { 0058 return false; 0059 } 0060 0061 return d->m_targetHref == other.d->m_targetHref; 0062 } 0063 0064 bool GeoDataUpdate::operator!=(const GeoDataUpdate& other) const 0065 { 0066 return !this->operator==(other); 0067 } 0068 0069 GeoDataUpdate::~GeoDataUpdate() 0070 { 0071 delete d; 0072 } 0073 0074 const char *GeoDataUpdate::nodeType() const 0075 { 0076 return GeoDataTypes::GeoDataUpdateType; 0077 } 0078 0079 QString GeoDataUpdate::targetHref() const 0080 { 0081 return d->m_targetHref; 0082 } 0083 0084 void GeoDataUpdate::setTargetHref( const QString &targetHref ) 0085 { 0086 d->m_targetHref = targetHref; 0087 } 0088 0089 const GeoDataChange *GeoDataUpdate::change() const 0090 { 0091 return d->m_change; 0092 } 0093 0094 GeoDataChange *GeoDataUpdate::change() 0095 { 0096 return d->m_change; 0097 } 0098 0099 void GeoDataUpdate::setChange( GeoDataChange* change ) 0100 { 0101 delete d->m_change; 0102 d->m_change = change; 0103 if ( d->m_change ) { 0104 d->m_change->setParent( this ); 0105 } 0106 } 0107 0108 const GeoDataCreate *GeoDataUpdate::create() const 0109 { 0110 return d->m_create; 0111 } 0112 0113 GeoDataCreate *GeoDataUpdate::create() 0114 { 0115 return d->m_create; 0116 } 0117 0118 void GeoDataUpdate::setCreate( GeoDataCreate* create ) 0119 { 0120 delete d->m_create; 0121 d->m_create = create; 0122 if ( d->m_create ) { 0123 d->m_create->setParent( this ); 0124 } 0125 } 0126 0127 const GeoDataDelete *GeoDataUpdate::getDelete() const 0128 { 0129 return d->m_delete; 0130 } 0131 0132 GeoDataDelete *GeoDataUpdate::getDelete() 0133 { 0134 return d->m_delete; 0135 } 0136 0137 void GeoDataUpdate::setDelete( GeoDataDelete* dataDelete ) 0138 { 0139 delete d->m_delete; 0140 d->m_delete = dataDelete; 0141 if ( d->m_delete ) { 0142 d->m_delete->setParent( this ); 0143 } 0144 } 0145 0146 }