summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedrich W. H. Kossebau <kossebau@kde.org>2016-11-10 17:37:57 (GMT)
committerFriedrich W. H. Kossebau <kossebau@kde.org>2016-11-10 19:27:16 (GMT)
commit7bcd0676d2853375d630c8e42df35458923c4a5b (patch)
treec5dcf95d3ac354a2b8bad6c1737cdac148192089
parent426b984468b6e5514a1180e75ad1d06a54cfb52f (diff)
Remove implicit sharing from GeoDataFeature & subclasses
Summary: Also integrate pimpl classes of more subclasses by subclassing from GeoDataFeaturePrivate Implict sharing conflicts with parentship properties on members of some subclasses Reviewers: nienhueser, rahn, #marble Reviewed By: rahn, #marble Differential Revision: https://phabricator.kde.org/D3316
-rw-r--r--src/lib/marble/geodata/data/GeoDataChange.cpp30
-rw-r--r--src/lib/marble/geodata/data/GeoDataChange.h6
-rw-r--r--src/lib/marble/geodata/data/GeoDataContainer.cpp66
-rw-r--r--src/lib/marble/geodata/data/GeoDataContainer.h6
-rw-r--r--src/lib/marble/geodata/data/GeoDataContainer_p.h27
-rw-r--r--src/lib/marble/geodata/data/GeoDataCreate.cpp30
-rw-r--r--src/lib/marble/geodata/data/GeoDataCreate.h6
-rw-r--r--src/lib/marble/geodata/data/GeoDataDelete.cpp30
-rw-r--r--src/lib/marble/geodata/data/GeoDataDelete.h6
-rw-r--r--src/lib/marble/geodata/data/GeoDataDocument.cpp49
-rw-r--r--src/lib/marble/geodata/data/GeoDataDocument.h4
-rw-r--r--src/lib/marble/geodata/data/GeoDataDocument_p.h18
-rw-r--r--src/lib/marble/geodata/data/GeoDataFeature.cpp112
-rw-r--r--src/lib/marble/geodata/data/GeoDataFeature.h9
-rw-r--r--src/lib/marble/geodata/data/GeoDataFeature_p.h16
-rw-r--r--src/lib/marble/geodata/data/GeoDataFolder.cpp28
-rw-r--r--src/lib/marble/geodata/data/GeoDataFolder.h4
-rw-r--r--src/lib/marble/geodata/data/GeoDataGroundOverlay.cpp70
-rw-r--r--src/lib/marble/geodata/data/GeoDataGroundOverlay.h11
-rw-r--r--src/lib/marble/geodata/data/GeoDataGroundOverlay_p.h43
-rw-r--r--src/lib/marble/geodata/data/GeoDataNetworkLink.cpp6
-rw-r--r--src/lib/marble/geodata/data/GeoDataNetworkLink.h2
-rw-r--r--src/lib/marble/geodata/data/GeoDataNetworkLinkControl.cpp133
-rw-r--r--src/lib/marble/geodata/data/GeoDataNetworkLinkControl.h6
-rw-r--r--src/lib/marble/geodata/data/GeoDataNetworkLinkControl_p.h97
-rw-r--r--src/lib/marble/geodata/data/GeoDataOverlay.cpp68
-rw-r--r--src/lib/marble/geodata/data/GeoDataOverlay.h11
-rw-r--r--src/lib/marble/geodata/data/GeoDataOverlay_p.h48
-rw-r--r--src/lib/marble/geodata/data/GeoDataPhotoOverlay.cpp70
-rw-r--r--src/lib/marble/geodata/data/GeoDataPhotoOverlay.h7
-rw-r--r--src/lib/marble/geodata/data/GeoDataPhotoOverlay_p.h58
-rw-r--r--src/lib/marble/geodata/data/GeoDataPlacemark.cpp75
-rw-r--r--src/lib/marble/geodata/data/GeoDataPlacemark.h2
-rw-r--r--src/lib/marble/geodata/data/GeoDataPlacemark_p.h91
-rw-r--r--src/lib/marble/geodata/data/GeoDataScreenOverlay.cpp61
-rw-r--r--src/lib/marble/geodata/data/GeoDataScreenOverlay.h7
-rw-r--r--src/lib/marble/geodata/data/GeoDataScreenOverlay_p.h37
-rw-r--r--src/lib/marble/geodata/data/GeoDataTour.cpp26
-rw-r--r--src/lib/marble/geodata/data/GeoDataTour.h5
-rw-r--r--src/lib/marble/geodata/data/GeoDataTour_p.h15
-rw-r--r--tests/TestGeoDataCopy.cpp5
41 files changed, 850 insertions, 551 deletions
diff --git a/src/lib/marble/geodata/data/GeoDataChange.cpp b/src/lib/marble/geodata/data/GeoDataChange.cpp
index d572ab2..4c590d5 100644
--- a/src/lib/marble/geodata/data/GeoDataChange.cpp
+++ b/src/lib/marble/geodata/data/GeoDataChange.cpp
@@ -9,35 +9,35 @@
//
#include "GeoDataChange.h"
+
+#include "GeoDataContainer_p.h"
#include "GeoDataTypes.h"
namespace Marble
{
-class GeoDataChangePrivate
+class GeoDataChangePrivate : public GeoDataContainerPrivate
{
-public:
- GeoDataChangePrivate();
};
-GeoDataChangePrivate::GeoDataChangePrivate()
-{
-}
-GeoDataChange::GeoDataChange() :
- d( new GeoDataChangePrivate )
+GeoDataChange::GeoDataChange()
+ : GeoDataContainer(new GeoDataChangePrivate)
{
}
-GeoDataChange::GeoDataChange( const Marble::GeoDataChange &other ) :
- GeoDataContainer(), d( new GeoDataChangePrivate( *other.d ) )
+GeoDataChange::GeoDataChange(const GeoDataChange &other)
+ : GeoDataContainer(other, new GeoDataChangePrivate(*other.d_func()))
{
}
GeoDataChange &GeoDataChange::operator=( const GeoDataChange &other )
{
- GeoDataContainer::operator =( other );
- *d = *other.d;
+ if (this != &other) {
+ Q_D(GeoDataChange);
+ *d = *other.d_func();
+ }
+
return *this;
}
@@ -56,7 +56,11 @@ bool GeoDataChange::operator!=( const GeoDataChange &other ) const
GeoDataChange::~GeoDataChange()
{
- delete d;
+}
+
+GeoDataFeature * GeoDataChange::clone() const
+{
+ return new GeoDataChange(*this);
}
const char *GeoDataChange::nodeType() const
diff --git a/src/lib/marble/geodata/data/GeoDataChange.h b/src/lib/marble/geodata/data/GeoDataChange.h
index d6fcfdf..b2ed781 100644
--- a/src/lib/marble/geodata/data/GeoDataChange.h
+++ b/src/lib/marble/geodata/data/GeoDataChange.h
@@ -28,18 +28,20 @@ public:
GeoDataChange( const GeoDataChange &other );
+ ~GeoDataChange();
+
GeoDataChange& operator=( const GeoDataChange &other );
bool operator==( const GeoDataChange &other ) const;
bool operator!=( const GeoDataChange &other ) const;
- ~GeoDataChange();
+ GeoDataFeature * clone() const override;
/** Provides type information for downcasting a GeoNode */
virtual const char* nodeType() const;
private:
- GeoDataChangePrivate* const d;
+ Q_DECLARE_PRIVATE(GeoDataChange)
};
}
diff --git a/src/lib/marble/geodata/data/GeoDataContainer.cpp b/src/lib/marble/geodata/data/GeoDataContainer.cpp
index 8c2c207..7d3f031 100644
--- a/src/lib/marble/geodata/data/GeoDataContainer.cpp
+++ b/src/lib/marble/geodata/data/GeoDataContainer.cpp
@@ -39,20 +39,41 @@ GeoDataContainer::GeoDataContainer()
{
}
-GeoDataContainer::GeoDataContainer( GeoDataContainerPrivate *priv )
- : GeoDataFeature( priv )
+GeoDataContainer::GeoDataContainer(GeoDataContainerPrivate *priv)
+ : GeoDataFeature(priv)
{
+ Q_D(GeoDataContainer);
+ d->setParent(this);
+}
+
+GeoDataContainer::GeoDataContainer(const GeoDataContainer& other, GeoDataContainerPrivate *priv)
+ : GeoDataFeature(other, priv)
+{
+ Q_D(GeoDataContainer);
+ d->setParent(this);
}
GeoDataContainer::GeoDataContainer( const GeoDataContainer& other )
- : GeoDataFeature( other )
+ : GeoDataFeature(other, new GeoDataContainerPrivate(*other.d_func()))
{
+ Q_D(GeoDataContainer);
+ d->setParent(this);
}
GeoDataContainer::~GeoDataContainer()
{
}
+GeoDataContainer& GeoDataContainer::operator=(const GeoDataContainer& other)
+{
+ if (this != &other) {
+ Q_D(GeoDataContainer);
+ *d = *other.d_func();
+ }
+
+ return *this;
+}
+
bool GeoDataContainer::equals( const GeoDataContainer &other ) const
{
if ( !GeoDataFeature::equals(other) ) {
@@ -149,6 +170,11 @@ bool GeoDataContainer::equals( const GeoDataContainer &other ) const
return thisBegin == thisEnd && otherBegin == otherEnd;
}
+GeoDataFeature * GeoDataContainer::clone() const
+{
+ return new GeoDataContainer(*this);
+}
+
GeoDataLatLonAltBox GeoDataContainer::latLonAltBox() const
{
Q_D(const GeoDataContainer);
@@ -228,8 +254,6 @@ QVector<GeoDataFeature*> GeoDataContainer::featureList() const
*/
GeoDataFeature* GeoDataContainer::child( int i )
{
- detach();
-
Q_D(GeoDataContainer);
return d->m_vector.at(i);
}
@@ -262,8 +286,6 @@ void GeoDataContainer::insert( GeoDataFeature *other, int index )
void GeoDataContainer::insert( int index, GeoDataFeature *feature )
{
- detach();
-
Q_D(GeoDataContainer);
feature->setParent(this);
d->m_vector.insert( index, feature );
@@ -271,8 +293,6 @@ void GeoDataContainer::insert( int index, GeoDataFeature *feature )
void GeoDataContainer::append( GeoDataFeature *other )
{
- detach();
-
Q_D(GeoDataContainer);
other->setParent(this);
d->m_vector.append( other );
@@ -281,24 +301,18 @@ void GeoDataContainer::append( GeoDataFeature *other )
void GeoDataContainer::remove( int index )
{
- detach();
-
Q_D(GeoDataContainer);
d->m_vector.remove( index );
}
void GeoDataContainer::remove(int index, int count)
{
- detach();
-
Q_D(GeoDataContainer);
d->m_vector.remove( index, count );
}
int GeoDataContainer::removeAll(GeoDataFeature *feature)
{
- detach();
-
Q_D(GeoDataContainer);
#if QT_VERSION >= 0x050400
return d->m_vector.removeAll(feature);
@@ -323,32 +337,24 @@ int GeoDataContainer::removeAll(GeoDataFeature *feature)
void GeoDataContainer::removeAt(int index)
{
- detach();
-
Q_D(GeoDataContainer);
d->m_vector.removeAt( index );
}
void GeoDataContainer::removeFirst()
{
- detach();
-
Q_D(GeoDataContainer);
d->m_vector.removeFirst();
}
void GeoDataContainer::removeLast()
{
- detach();
-
Q_D(GeoDataContainer);
d->m_vector.removeLast();
}
bool GeoDataContainer::removeOne( GeoDataFeature *feature )
{
- detach();
-
Q_D(GeoDataContainer);
#if QT_VERSION >= 0x050400
return d->m_vector.removeOne( feature );
@@ -374,8 +380,6 @@ int GeoDataContainer::size() const
GeoDataFeature& GeoDataContainer::at( int pos )
{
- detach();
-
Q_D(GeoDataContainer);
return *(d->m_vector[pos]);
}
@@ -388,8 +392,6 @@ const GeoDataFeature& GeoDataContainer::at( int pos ) const
GeoDataFeature& GeoDataContainer::last()
{
- detach();
-
Q_D(GeoDataContainer);
return *(d->m_vector.last());
}
@@ -402,8 +404,6 @@ const GeoDataFeature& GeoDataContainer::last() const
GeoDataFeature& GeoDataContainer::first()
{
- detach();
-
Q_D(GeoDataContainer);
return *(d->m_vector.first());
}
@@ -416,8 +416,6 @@ const GeoDataFeature& GeoDataContainer::first() const
void GeoDataContainer::clear()
{
- GeoDataContainer::detach();
-
Q_D(GeoDataContainer);
qDeleteAll(d->m_vector);
d->m_vector.clear();
@@ -425,16 +423,12 @@ void GeoDataContainer::clear()
QVector<GeoDataFeature*>::Iterator GeoDataContainer::begin()
{
- detach();
-
Q_D(GeoDataContainer);
return d->m_vector.begin();
}
QVector<GeoDataFeature*>::Iterator GeoDataContainer::end()
{
- detach();
-
Q_D(GeoDataContainer);
return d->m_vector.end();
}
@@ -470,8 +464,6 @@ void GeoDataContainer::pack( QDataStream& stream ) const
void GeoDataContainer::unpack( QDataStream& stream )
{
- detach();
-
Q_D(GeoDataContainer);
GeoDataFeature::unpack( stream );
diff --git a/src/lib/marble/geodata/data/GeoDataContainer.h b/src/lib/marble/geodata/data/GeoDataContainer.h
index e03cb43..91aad78 100644
--- a/src/lib/marble/geodata/data/GeoDataContainer.h
+++ b/src/lib/marble/geodata/data/GeoDataContainer.h
@@ -53,6 +53,9 @@ class GEODATA_EXPORT GeoDataContainer : public GeoDataFeature
/// Destruct the GeoDataContainer
virtual ~GeoDataContainer();
+ GeoDataContainer& operator=(const GeoDataContainer& other);
+
+ GeoDataFeature * clone() const override;
/**
* @brief A convenience function that returns the LatLonAltBox of all
@@ -168,7 +171,8 @@ class GEODATA_EXPORT GeoDataContainer : public GeoDataFeature
virtual void unpack( QDataStream& stream );
protected:
- explicit GeoDataContainer( GeoDataContainerPrivate *priv );
+ explicit GeoDataContainer(GeoDataContainerPrivate *priv);
+ GeoDataContainer(const GeoDataContainer& other, GeoDataContainerPrivate *priv);
bool equals( const GeoDataContainer &other ) const;
using GeoDataFeature::equals;
diff --git a/src/lib/marble/geodata/data/GeoDataContainer_p.h b/src/lib/marble/geodata/data/GeoDataContainer_p.h
index ec0a27f..9e8de85 100644
--- a/src/lib/marble/geodata/data/GeoDataContainer_p.h
+++ b/src/lib/marble/geodata/data/GeoDataContainer_p.h
@@ -24,7 +24,16 @@ class GeoDataContainerPrivate : public GeoDataFeaturePrivate
GeoDataContainerPrivate()
{
}
-
+
+ GeoDataContainerPrivate(const GeoDataContainerPrivate& other)
+ : GeoDataFeaturePrivate(other)
+ {
+ m_vector.reserve(other.m_vector.size());
+ foreach (GeoDataFeature *feature, other.m_vector) {
+ m_vector.append(feature->clone());
+ }
+ }
+
~GeoDataContainerPrivate()
{
qDeleteAll( m_vector );
@@ -38,18 +47,11 @@ class GeoDataContainerPrivate : public GeoDataFeaturePrivate
m_vector.reserve(other.m_vector.size());
foreach( GeoDataFeature *feature, other.m_vector )
{
- m_vector.append( new GeoDataFeature( *feature ) );
+ m_vector.append(feature->clone());
}
return *this;
}
- virtual GeoDataFeaturePrivate* copy()
- {
- GeoDataContainerPrivate* copy = new GeoDataContainerPrivate;
- *copy = *this;
- return copy;
- }
-
virtual const char* nodeType() const
{
return GeoDataTypes::GeoDataContainerType;
@@ -60,6 +62,13 @@ class GeoDataContainerPrivate : public GeoDataFeaturePrivate
return GeoDataFolderId;
}
+ void setParent(GeoDataObject *parent)
+ {
+ foreach (GeoDataFeature *feature, m_vector) {
+ feature->setParent(parent);
+ }
+ }
+
QVector<GeoDataFeature*> m_vector;
};
diff --git a/src/lib/marble/geodata/data/GeoDataCreate.cpp b/src/lib/marble/geodata/data/GeoDataCreate.cpp
index 0aee9a1..9e9fc6a 100644
--- a/src/lib/marble/geodata/data/GeoDataCreate.cpp
+++ b/src/lib/marble/geodata/data/GeoDataCreate.cpp
@@ -9,35 +9,35 @@
//
#include "GeoDataCreate.h"
+
+#include "GeoDataContainer_p.h"
#include "GeoDataTypes.h"
namespace Marble
{
-class GeoDataCreatePrivate
+class GeoDataCreatePrivate : public GeoDataContainerPrivate
{
-public:
- GeoDataCreatePrivate();
};
-GeoDataCreatePrivate::GeoDataCreatePrivate()
-{
-}
-GeoDataCreate::GeoDataCreate() :
- d( new GeoDataCreatePrivate )
+GeoDataCreate::GeoDataCreate()
+ : GeoDataContainer(new GeoDataCreatePrivate)
{
}
-GeoDataCreate::GeoDataCreate( const Marble::GeoDataCreate &other ) :
- GeoDataContainer(), d( new GeoDataCreatePrivate( *other.d ) )
+GeoDataCreate::GeoDataCreate(const GeoDataCreate &other)
+ : GeoDataContainer(other, new GeoDataCreatePrivate(*other.d_func()))
{
}
GeoDataCreate &GeoDataCreate::operator=( const GeoDataCreate &other )
{
- GeoDataContainer::operator =( other );
- *d = *other.d;
+ if (this != &other) {
+ Q_D(GeoDataCreate);
+ *d = *other.d_func();
+ }
+
return *this;
}
@@ -56,7 +56,11 @@ bool GeoDataCreate::operator!=( const GeoDataCreate &other ) const
GeoDataCreate::~GeoDataCreate()
{
- delete d;
+}
+
+GeoDataFeature * GeoDataCreate::clone() const
+{
+ return new GeoDataCreate(*this);
}
const char *GeoDataCreate::nodeType() const
diff --git a/src/lib/marble/geodata/data/GeoDataCreate.h b/src/lib/marble/geodata/data/GeoDataCreate.h
index 558db57..7cf1019 100644
--- a/src/lib/marble/geodata/data/GeoDataCreate.h
+++ b/src/lib/marble/geodata/data/GeoDataCreate.h
@@ -28,18 +28,20 @@ public:
GeoDataCreate( const GeoDataCreate &other );
+ ~GeoDataCreate();
+
GeoDataCreate& operator=( const GeoDataCreate &other );
bool operator==( const GeoDataCreate &other ) const;
bool operator!=( const GeoDataCreate &other ) const;
- ~GeoDataCreate();
+ GeoDataFeature * clone() const override;
/** Provides type information for downcasting a GeoNode */
virtual const char* nodeType() const;
private:
- GeoDataCreatePrivate* const d;
+ Q_DECLARE_PRIVATE(GeoDataCreate)
};
}
diff --git a/src/lib/marble/geodata/data/GeoDataDelete.cpp b/src/lib/marble/geodata/data/GeoDataDelete.cpp
index c6564bd..ae4b350 100644
--- a/src/lib/marble/geodata/data/GeoDataDelete.cpp
+++ b/src/lib/marble/geodata/data/GeoDataDelete.cpp
@@ -9,35 +9,35 @@
//
#include "GeoDataDelete.h"
+
+#include "GeoDataContainer_p.h"
#include "GeoDataTypes.h"
namespace Marble
{
-class GeoDataDeletePrivate
+class GeoDataDeletePrivate : public GeoDataContainerPrivate
{
-public:
- GeoDataDeletePrivate();
};
-GeoDataDeletePrivate::GeoDataDeletePrivate()
-{
-}
-GeoDataDelete::GeoDataDelete() :
- d( new GeoDataDeletePrivate )
+GeoDataDelete::GeoDataDelete()
+ : GeoDataContainer(new GeoDataDeletePrivate)
{
}
-GeoDataDelete::GeoDataDelete( const Marble::GeoDataDelete &other ) :
- GeoDataContainer(), d( new GeoDataDeletePrivate( *other.d ) )
+GeoDataDelete::GeoDataDelete(const GeoDataDelete &other)
+ : GeoDataContainer(other, new GeoDataDeletePrivate(*other.d_func()))
{
}
GeoDataDelete &GeoDataDelete::operator=( const GeoDataDelete &other )
{
- GeoDataContainer::operator =( other );
- *d = *other.d;
+ if (this != &other) {
+ Q_D(GeoDataDelete);
+ *d = *other.d_func();
+ }
+
return *this;
}
@@ -56,7 +56,11 @@ bool GeoDataDelete::operator!=( const GeoDataDelete &other ) const
GeoDataDelete::~GeoDataDelete()
{
- delete d;
+}
+
+GeoDataFeature * GeoDataDelete::clone() const
+{
+ return new GeoDataDelete(*this);
}
const char *GeoDataDelete::nodeType() const
diff --git a/src/lib/marble/geodata/data/GeoDataDelete.h b/src/lib/marble/geodata/data/GeoDataDelete.h
index 76848cc..1e840e2 100644
--- a/src/lib/marble/geodata/data/GeoDataDelete.h
+++ b/src/lib/marble/geodata/data/GeoDataDelete.h
@@ -28,18 +28,20 @@ public:
GeoDataDelete( const GeoDataDelete &other );
+ ~GeoDataDelete();
+
GeoDataDelete& operator=( const GeoDataDelete &other );
bool operator==( const GeoDataDelete &other ) const;
bool operator!=( const GeoDataDelete &other ) const;
- ~GeoDataDelete();
+ GeoDataFeature * clone() const override;
/** Provides type information for downcasting a GeoNode */
virtual const char* nodeType() const;
private:
- GeoDataDeletePrivate* const d;
+ Q_DECLARE_PRIVATE(GeoDataDelete)
};
}
diff --git a/src/lib/marble/geodata/data/GeoDataDocument.cpp b/src/lib/marble/geodata/data/GeoDataDocument.cpp
index a6f9035..a6c5f6f 100644
--- a/src/lib/marble/geodata/data/GeoDataDocument.cpp
+++ b/src/lib/marble/geodata/data/GeoDataDocument.cpp
@@ -43,7 +43,8 @@ GeoDataDocument::GeoDataDocument()
}
GeoDataDocument::GeoDataDocument( const GeoDataDocument& other )
- : GeoDocument(), GeoDataContainer( other )
+ : GeoDocument(),
+ GeoDataContainer(other, new GeoDataDocumentPrivate(*other.d_func()))
{
}
@@ -51,6 +52,16 @@ GeoDataDocument::~GeoDataDocument()
{
}
+GeoDataDocument& GeoDataDocument::operator=(const GeoDataDocument& other)
+{
+ if (this != &other) {
+ Q_D(GeoDataDocument);
+ *d = *other.d_func();
+ }
+
+ return *this;
+}
+
bool GeoDataDocument::operator==( const GeoDataDocument &other ) const
{
if (!GeoDataContainer::equals(other)) {
@@ -90,6 +101,11 @@ bool GeoDataDocument::operator!=( const GeoDataDocument &other ) const
return !this->operator==( other );
}
+GeoDataFeature * GeoDataDocument::clone() const
+{
+ return new GeoDataDocument(*this);
+}
+
DocumentRole GeoDataDocument::documentRole() const
{
Q_D(const GeoDataDocument);
@@ -98,8 +114,6 @@ DocumentRole GeoDataDocument::documentRole() const
void GeoDataDocument::setDocumentRole( DocumentRole role )
{
- detach();
-
Q_D(GeoDataDocument);
d->m_documentRole = role;
}
@@ -112,8 +126,6 @@ QString GeoDataDocument::property() const
void GeoDataDocument::setProperty( const QString& property )
{
- detach();
-
Q_D(GeoDataDocument);
d->m_property = property;
}
@@ -126,8 +138,6 @@ QString GeoDataDocument::fileName() const
void GeoDataDocument::setFileName( const QString &value )
{
- detach();
-
Q_D(GeoDataDocument);
d->m_filename = value;
}
@@ -140,8 +150,6 @@ QString GeoDataDocument::baseUri() const
void GeoDataDocument::setBaseUri( const QString &baseUrl )
{
- detach();
-
Q_D(GeoDataDocument);
d->m_baseUri = baseUrl;
}
@@ -154,16 +162,12 @@ GeoDataNetworkLinkControl GeoDataDocument::networkLinkControl() const
void GeoDataDocument::setNetworkLinkControl( const GeoDataNetworkLinkControl &networkLinkControl )
{
- detach();
-
Q_D(GeoDataDocument);
d->m_networkLinkControl = networkLinkControl;
}
void GeoDataDocument::addStyle( const GeoDataStyle::Ptr &style )
{
- detach();
-
Q_D(GeoDataDocument);
d->m_styleHash.insert(style->id(), style);
d->m_styleHash[style->id()]->setParent(this);
@@ -171,15 +175,12 @@ void GeoDataDocument::addStyle( const GeoDataStyle::Ptr &style )
void GeoDataDocument::removeStyle( const QString& styleId )
{
- detach();
-
Q_D(GeoDataDocument);
d->m_styleHash.remove(styleId);
}
GeoDataStyle::Ptr GeoDataDocument::style( const QString& styleId )
{
- detach();
/*
* FIXME: m_styleHash always should contain at least default
* GeoDataStyle element
@@ -207,16 +208,12 @@ QList<GeoDataStyle::ConstPtr> GeoDataDocument::styles() const
QList<GeoDataStyle::Ptr> GeoDataDocument::styles()
{
- detach();
-
Q_D(GeoDataDocument);
return d->m_styleHash.values();
}
void GeoDataDocument::addStyleMap( const GeoDataStyleMap& map )
{
- detach();
-
Q_D(GeoDataDocument);
d->m_styleMapHash.insert(map.id(), map);
d->m_styleMapHash[map.id()].setParent(this);
@@ -224,16 +221,12 @@ void GeoDataDocument::addStyleMap( const GeoDataStyleMap& map )
void GeoDataDocument::removeStyleMap( const QString& mapId )
{
- detach();
-
Q_D(GeoDataDocument);
d->m_styleMapHash.remove(mapId);
}
GeoDataStyleMap& GeoDataDocument::styleMap( const QString& styleId )
{
- detach();
-
Q_D(GeoDataDocument);
return d->m_styleMapHash[styleId];
}
@@ -252,8 +245,6 @@ QList<GeoDataStyleMap> GeoDataDocument::styleMaps() const
void GeoDataDocument::addSchema( const GeoDataSchema& schema )
{
- detach();
-
Q_D(GeoDataDocument);
d->m_schemaHash.insert(schema.id(), schema);
d->m_schemaHash[schema.id()].setParent(this);
@@ -261,8 +252,6 @@ void GeoDataDocument::addSchema( const GeoDataSchema& schema )
void GeoDataDocument::removeSchema( const QString& schemaId )
{
- detach();
-
Q_D(GeoDataDocument);
GeoDataSchema schema = d->m_schemaHash.take(schemaId);
schema.setParent( 0 );
@@ -276,8 +265,6 @@ GeoDataSchema GeoDataDocument::schema( const QString& schemaId ) const
GeoDataSchema &GeoDataDocument::schema( const QString &schemaId )
{
- detach();
-
Q_D(GeoDataDocument);
return d->m_schemaHash[schemaId];
}
@@ -306,8 +293,6 @@ void GeoDataDocument::pack( QDataStream& stream ) const
void GeoDataDocument::unpack( QDataStream& stream )
{
- detach();
-
Q_D(GeoDataDocument);
GeoDataContainer::unpack( stream );
diff --git a/src/lib/marble/geodata/data/GeoDataDocument.h b/src/lib/marble/geodata/data/GeoDataDocument.h
index bfb890c..36d14cc 100644
--- a/src/lib/marble/geodata/data/GeoDataDocument.h
+++ b/src/lib/marble/geodata/data/GeoDataDocument.h
@@ -68,9 +68,13 @@ public:
GeoDataDocument( const GeoDataDocument& other );
~GeoDataDocument();
+ GeoDataDocument& operator=(const GeoDataDocument& other);
+
bool operator==( const GeoDataDocument &other ) const;
bool operator!=( const GeoDataDocument &other ) const;
+ GeoDataFeature * clone() const override;
+
/// Provides type information for downcasting a GeoData
virtual bool isGeoDataDocument() const { return true; }
diff --git a/src/lib/marble/geodata/data/GeoDataDocument_p.h b/src/lib/marble/geodata/data/GeoDataDocument_p.h
index 678ef20..746306b 100644
--- a/src/lib/marble/geodata/data/GeoDataDocument_p.h
+++ b/src/lib/marble/geodata/data/GeoDataDocument_p.h
@@ -29,12 +29,18 @@ class GeoDataDocumentPrivate : public GeoDataContainerPrivate
: m_documentRole( UnknownDocument )
{
}
-
- virtual GeoDataFeaturePrivate* copy()
- {
- GeoDataDocumentPrivate* copy = new GeoDataDocumentPrivate;
- *copy = *this;
- return copy;
+
+ GeoDataDocumentPrivate(const GeoDataDocumentPrivate& other)
+ : GeoDataContainerPrivate(other),
+ m_styleHash(other.m_styleHash),
+ m_styleMapHash(other.m_styleMapHash),
+ m_schemaHash(other.m_schemaHash),
+ m_filename(other.m_filename),
+ m_baseUri(other.m_baseUri),
+ m_networkLinkControl(other.m_networkLinkControl),
+ m_property(other.m_property),
+ m_documentRole(other.m_documentRole)
+ {
}
virtual const char* nodeType() const
diff --git a/src/lib/marble/geodata/data/GeoDataFeature.cpp b/src/lib/marble/geodata/data/GeoDataFeature.cpp
index 955bd2d..dd06732 100644
--- a/src/lib/marble/geodata/data/GeoDataFeature.cpp
+++ b/src/lib/marble/geodata/data/GeoDataFeature.cpp
@@ -37,45 +37,45 @@ const QSharedPointer<const GeoDataStyle> GeoDataFeaturePrivate::s_defaultStyle(n
GeoDataFeature::GeoDataFeature()
: d_ptr(new GeoDataFeaturePrivate())
{
- d_ptr->ref.ref();
}
GeoDataFeature::GeoDataFeature( const GeoDataFeature& other )
: GeoDataObject(),
- d_ptr( other.d_ptr )
+ d_ptr(new GeoDataFeaturePrivate(*other.d_ptr))
{
- d_ptr->ref.ref();
}
GeoDataFeature::GeoDataFeature( const QString& name )
: d_ptr(new GeoDataFeaturePrivate())
{
- d_ptr->ref.ref();
d_ptr->m_name = name;
}
GeoDataFeature::GeoDataFeature(GeoDataFeaturePrivate *dd)
- : d_ptr(dd)
+ : GeoDataObject(),
+ d_ptr(dd)
{
- d_ptr->ref.ref();
+}
+
+GeoDataFeature::GeoDataFeature(const GeoDataFeature& other, GeoDataFeaturePrivate *dd)
+ : GeoDataObject(),
+ d_ptr(dd)
+{
+ Q_UNUSED(other);
+ // TODO: some classes pass "other" on and thus get duplicated id, also in operator=. Align behaviour
}
GeoDataFeature::~GeoDataFeature()
{
- if (!d_ptr->ref.deref()) {
- delete d_ptr;
- }
+ delete d_ptr;
}
GeoDataFeature& GeoDataFeature::operator=( const GeoDataFeature& other )
{
- if (!d_ptr->ref.deref()) {
- delete d_ptr;
+ if (this != &other) {
+ *d_ptr = *other.d_ptr;
}
- d_ptr = other.d_ptr;
- d_ptr->ref.ref();
-
return *this;
}
@@ -119,6 +119,11 @@ bool GeoDataFeature::equals( const GeoDataFeature &other ) const
return true;
}
+GeoDataFeature * GeoDataFeature::clone() const
+{
+ return new GeoDataFeature(*this);
+}
+
const char* GeoDataFeature::nodeType() const
{
Q_D(const GeoDataFeature);
@@ -139,8 +144,6 @@ QString GeoDataFeature::name() const
void GeoDataFeature::setName( const QString &value )
{
- detach();
-
Q_D(GeoDataFeature);
d->m_name = value;
}
@@ -153,8 +156,6 @@ GeoDataSnippet GeoDataFeature::snippet() const
void GeoDataFeature::setSnippet( const GeoDataSnippet &snippet )
{
- detach();
-
Q_D(GeoDataFeature);
d->featureExtendedData().m_snippet = snippet;
}
@@ -171,13 +172,11 @@ QString GeoDataFeature::address() const
void GeoDataFeature::setAddress( const QString &value)
{
- if (value.isEmpty() && !d_func()->m_featureExtendedData) {
+ Q_D(GeoDataFeature);
+ if (value.isEmpty() && !d->m_featureExtendedData) {
return; // nothing to change
}
- detach();
-
- Q_D(GeoDataFeature);
d->featureExtendedData().m_address = value;
}
@@ -193,13 +192,11 @@ QString GeoDataFeature::phoneNumber() const
void GeoDataFeature::setPhoneNumber( const QString &value)
{
- if (value.isEmpty() && !d_func()->m_featureExtendedData) {
+ Q_D(GeoDataFeature);
+ if (value.isEmpty() && !d->m_featureExtendedData) {
return; // nothing to change
}
- detach();
-
- Q_D(GeoDataFeature);
d->featureExtendedData().m_phoneNumber = value;
}
@@ -215,13 +212,11 @@ QString GeoDataFeature::description() const
void GeoDataFeature::setDescription( const QString &value)
{
- if (value.isEmpty() && !d_func()->m_featureExtendedData) {
+ Q_D(GeoDataFeature);
+ if (value.isEmpty() && !d->m_featureExtendedData) {
return; // nothing to change
}
- detach();
-
- Q_D(GeoDataFeature);
d->featureExtendedData().m_description = value;
}
@@ -237,8 +232,6 @@ bool GeoDataFeature::descriptionIsCDATA() const
void GeoDataFeature::setDescriptionCDATA( bool cdata )
{
- detach();
-
Q_D(GeoDataFeature);
d->featureExtendedData().m_descriptionCDATA = cdata;
}
@@ -265,13 +258,11 @@ GeoDataAbstractView *GeoDataFeature::abstractView()
void GeoDataFeature::setAbstractView( GeoDataAbstractView *abstractView )
{
- if (abstractView == nullptr && !d_func()->m_featureExtendedData) {
+ Q_D(GeoDataFeature);
+ if (abstractView == nullptr && !d->m_featureExtendedData) {
return; // nothing to change
}
- detach();
-
- Q_D(GeoDataFeature);
d->featureExtendedData().m_abstractView = abstractView;
}
@@ -283,8 +274,6 @@ QString GeoDataFeature::styleUrl() const
void GeoDataFeature::setStyleUrl( const QString &value )
{
- detach();
-
Q_D(GeoDataFeature);
d->m_styleUrl = value;
@@ -323,8 +312,6 @@ bool GeoDataFeature::isVisible() const
void GeoDataFeature::setVisible( bool value )
{
- detach();
-
Q_D(GeoDataFeature);
d->m_visible = value;
}
@@ -348,16 +335,12 @@ const GeoDataTimeSpan &GeoDataFeature::timeSpan() const
GeoDataTimeSpan &GeoDataFeature::timeSpan()
{
- detach();
-
Q_D(GeoDataFeature);
return d->featureExtendedData().m_timeSpan;
}
void GeoDataFeature::setTimeSpan( const GeoDataTimeSpan &timeSpan )
{
- detach();
-
Q_D(GeoDataFeature);
d->featureExtendedData().m_timeSpan = timeSpan;
}
@@ -370,16 +353,12 @@ const GeoDataTimeStamp &GeoDataFeature::timeStamp() const
GeoDataTimeStamp &GeoDataFeature::timeStamp()
{
- detach();
-
Q_D(GeoDataFeature);
return d->featureExtendedData().m_timeStamp;
}
void GeoDataFeature::setTimeStamp( const GeoDataTimeStamp &timeStamp )
{
- detach();
-
Q_D(GeoDataFeature);
d->featureExtendedData().m_timeStamp = timeStamp;
}
@@ -408,8 +387,6 @@ GeoDataStyle::ConstPtr GeoDataFeature::customStyle() const
void GeoDataFeature::setStyle( const GeoDataStyle::Ptr &style )
{
- detach();
-
Q_D(GeoDataFeature);
if (style)
style->setParent( this );
@@ -418,16 +395,12 @@ void GeoDataFeature::setStyle( const GeoDataStyle::Ptr &style )
GeoDataExtendedData& GeoDataFeature::extendedData()
{
- detach();
-
Q_D(GeoDataFeature);
return d->m_extendedData;
}
void GeoDataFeature::setExtendedData( const GeoDataExtendedData& extendedData )
{
- detach();
-
Q_D(GeoDataFeature);
d->m_extendedData = extendedData;
}
@@ -440,16 +413,12 @@ const GeoDataRegion& GeoDataFeature::region() const
GeoDataRegion& GeoDataFeature::region()
{
- detach();
-
Q_D(GeoDataFeature);
return d->featureExtendedData().m_region;
}
void GeoDataFeature::setRegion( const GeoDataRegion& region )
{
- detach();
-
Q_D(GeoDataFeature);
d->featureExtendedData().m_region = region;
}
@@ -462,8 +431,6 @@ const QString GeoDataFeature::role() const
void GeoDataFeature::setRole( const QString &role )
{
- detach();
-
Q_D(GeoDataFeature);
d->m_role = role;
}
@@ -476,8 +443,6 @@ const GeoDataStyleMap* GeoDataFeature::styleMap() const
void GeoDataFeature::setStyleMap( const GeoDataStyleMap* styleMap )
{
- detach();
-
Q_D(GeoDataFeature);
d->m_styleMap = styleMap;
}
@@ -490,8 +455,6 @@ int GeoDataFeature::zoomLevel() const
void GeoDataFeature::setZoomLevel( int zoomLevel )
{
- detach();
-
Q_D(GeoDataFeature);
d->m_zoomLevel = zoomLevel;
}
@@ -504,29 +467,10 @@ qint64 GeoDataFeature::popularity() const
void GeoDataFeature::setPopularity( qint64 popularity )
{
- detach();
-
Q_D(GeoDataFeature);
d->m_popularity = popularity;
}
-void GeoDataFeature::detach()
-{
- if (d_ptr->ref.load() == 1) {
- return;
- }
-
- GeoDataFeaturePrivate* new_d = d_ptr->copy();
-
- if (!d_ptr->ref.deref()) {
- delete d_ptr;
- }
-
- d_ptr = new_d;
-
- d_ptr->ref.ref();
-}
-
void GeoDataFeature::pack( QDataStream& stream ) const
{
Q_D(const GeoDataFeature);
@@ -546,8 +490,6 @@ void GeoDataFeature::pack( QDataStream& stream ) const
void GeoDataFeature::unpack( QDataStream& stream )
{
- detach();
-
Q_D(GeoDataFeature);
GeoDataObject::unpack( stream );
diff --git a/src/lib/marble/geodata/data/GeoDataFeature.h b/src/lib/marble/geodata/data/GeoDataFeature.h
index 9931956..14b61df 100644
--- a/src/lib/marble/geodata/data/GeoDataFeature.h
+++ b/src/lib/marble/geodata/data/GeoDataFeature.h
@@ -259,6 +259,10 @@ class GEODATA_EXPORT GeoDataFeature : public GeoDataObject
*/
void setStyleMap( const GeoDataStyleMap* map );
+ /// Duplicate into another equal instance
+ virtual GeoDataFeature * clone() const;
+
+
/// Serialize the contents of the feature to @p stream.
virtual void pack( QDataStream& stream ) const;
/// Unserialize the contents of the feature from @p stream.
@@ -266,10 +270,9 @@ class GEODATA_EXPORT GeoDataFeature : public GeoDataObject
protected:
// the d-pointer needs to be protected to be accessible from derived classes
- GeoDataFeaturePrivate* d_ptr;
+ GeoDataFeaturePrivate* const d_ptr;
explicit GeoDataFeature(GeoDataFeaturePrivate* dd);
-
- virtual void detach();
+ GeoDataFeature(const GeoDataFeature& other, GeoDataFeaturePrivate* dd);
bool equals( const GeoDataFeature &other ) const;
using GeoDataObject::equals;
diff --git a/src/lib/marble/geodata/data/GeoDataFeature_p.h b/src/lib/marble/geodata/data/GeoDataFeature_p.h
index 1b5bed8..a6c2d0b 100644
--- a/src/lib/marble/geodata/data/GeoDataFeature_p.h
+++ b/src/lib/marble/geodata/data/GeoDataFeature_p.h
@@ -12,7 +12,6 @@
#define MARBLE_GEODATAFEATUREPRIVATE_H
#include <QString>
-#include <QAtomicInt>
#include "GeoDataExtendedData.h"
#include "GeoDataAbstractView.h"
@@ -148,8 +147,7 @@ class GeoDataFeaturePrivate
m_style( 0 ),
m_styleMap( 0 ),
m_extendedData(),
- m_featureExtendedData(nullptr),
- ref( 0 )
+ m_featureExtendedData(nullptr)
{
}
@@ -163,8 +161,7 @@ class GeoDataFeaturePrivate
m_style( other.m_style ), //FIXME: both style and stylemap need to be reworked internally!!!!
m_styleMap( other.m_styleMap ),
m_extendedData( other.m_extendedData ),
- m_featureExtendedData(nullptr),
- ref( 0 )
+ m_featureExtendedData(nullptr)
{
if (other.m_featureExtendedData) {
m_featureExtendedData = new GeoDataFeatureExtendedData(*other.m_featureExtendedData);
@@ -189,13 +186,6 @@ class GeoDataFeaturePrivate
}
return *this;
}
-
- virtual GeoDataFeaturePrivate* copy()
- {
- GeoDataFeaturePrivate* copy = new GeoDataFeaturePrivate;
- *copy = *this;
- return copy;
- }
virtual EnumFeatureId featureId() const
{
@@ -242,8 +232,6 @@ class GeoDataFeaturePrivate
GeoDataExtendedData m_extendedData;
mutable GeoDataFeatureExtendedData* m_featureExtendedData;
- QAtomicInt ref;
-
// Static members
static const QSharedPointer<const GeoDataStyle> s_defaultStyle;
};
diff --git a/src/lib/marble/geodata/data/GeoDataFolder.cpp b/src/lib/marble/geodata/data/GeoDataFolder.cpp
index e197ef8..995a752 100644
--- a/src/lib/marble/geodata/data/GeoDataFolder.cpp
+++ b/src/lib/marble/geodata/data/GeoDataFolder.cpp
@@ -32,17 +32,6 @@ namespace Marble
class GeoDataFolderPrivate : public GeoDataContainerPrivate
{
public:
- GeoDataFolderPrivate()
- {
- }
-
- virtual GeoDataFeaturePrivate* copy()
- {
- GeoDataFolderPrivate* copy = new GeoDataFolderPrivate;
- *copy = *this;
- return copy;
- }
-
virtual const char* nodeType() const
{
return GeoDataTypes::GeoDataFolderType;
@@ -56,7 +45,7 @@ GeoDataFolder::GeoDataFolder()
}
GeoDataFolder::GeoDataFolder( const GeoDataFolder& other )
- : GeoDataContainer( other )
+ : GeoDataContainer(other, new GeoDataFolderPrivate(*other.d_func()))
{
}
@@ -64,6 +53,16 @@ GeoDataFolder::~GeoDataFolder()
{
}
+GeoDataFolder& GeoDataFolder::operator=(const GeoDataFolder& other)
+{
+ if (this != &other) {
+ Q_D(GeoDataFolder);
+ *d = *other.d_func();
+ }
+
+ return *this;
+}
+
bool GeoDataFolder::operator==( const GeoDataFolder &other ) const
{
return GeoDataContainer::equals( other );
@@ -74,4 +73,9 @@ bool GeoDataFolder::operator!=( const GeoDataFolder &other ) const
return !this->operator==( other );
}
+GeoDataFeature * GeoDataFolder::clone() const
+{
+ return new GeoDataFolder(*this);
+}
+
}
diff --git a/src/lib/marble/geodata/data/GeoDataFolder.h b/src/lib/marble/geodata/data/GeoDataFolder.h
index 9266c8e..68d827e 100644
--- a/src/lib/marble/geodata/data/GeoDataFolder.h
+++ b/src/lib/marble/geodata/data/GeoDataFolder.h
@@ -53,9 +53,13 @@ class GEODATA_EXPORT GeoDataFolder : public GeoDataContainer
GeoDataFolder( const GeoDataFolder& other );
~GeoDataFolder();
+ GeoDataFolder& operator=(const GeoDataFolder& other);
+
bool operator==( const GeoDataFolder &other ) const;
bool operator!=( const GeoDataFolder &other ) const;
+ GeoDataFeature * clone() const override;
+
private:
Q_DECLARE_PRIVATE(GeoDataFolder)
};
diff --git a/src/lib/marble/geodata/data/GeoDataGroundOverlay.cpp b/src/lib/marble/geodata/data/GeoDataGroundOverlay.cpp
index 007132e..ab9a1d3 100644
--- a/src/lib/marble/geodata/data/GeoDataGroundOverlay.cpp
+++ b/src/lib/marble/geodata/data/GeoDataGroundOverlay.cpp
@@ -9,56 +9,43 @@
//
#include "GeoDataGroundOverlay.h"
+#include "GeoDataGroundOverlay_p.h"
-#include "GeoDataTypes.h"
-#include "GeoDataLatLonQuad.h"
namespace Marble {
-class GeoDataGroundOverlayPrivate
-{
-public:
- double m_altitude;
-
- AltitudeMode m_altitudeMode;
-
- GeoDataLatLonBox m_latLonBox;
-
- GeoDataLatLonQuad m_latLonQuad;
-
- GeoDataGroundOverlayPrivate();
-};
-
-GeoDataGroundOverlayPrivate::GeoDataGroundOverlayPrivate() :
- m_altitude( 0.0 ), m_altitudeMode( ClampToGround )
-{
- // nothing to do
-}
-
-GeoDataGroundOverlay::GeoDataGroundOverlay() : d( new GeoDataGroundOverlayPrivate )
+GeoDataGroundOverlay::GeoDataGroundOverlay()
+ : GeoDataOverlay(new GeoDataGroundOverlayPrivate)
{
// nothing to do
}
-GeoDataGroundOverlay::GeoDataGroundOverlay( const Marble::GeoDataGroundOverlay &other ) :
- GeoDataOverlay( other ), d( new GeoDataGroundOverlayPrivate( *other.d ) )
+GeoDataGroundOverlay::GeoDataGroundOverlay(const GeoDataGroundOverlay &other)
+ : GeoDataOverlay(other, new GeoDataGroundOverlayPrivate(*other.d_func()))
{
// nothing to do
}
GeoDataGroundOverlay &GeoDataGroundOverlay::operator=( const GeoDataGroundOverlay &other )
{
- *d = *other.d;
+ if (this != &other) {
+ Q_D(GeoDataGroundOverlay);
+ *d = *other.d_func();
+ }
+
return *this;
}
bool GeoDataGroundOverlay::operator==(const GeoDataGroundOverlay& other) const
{
+ Q_D(const GeoDataGroundOverlay);
+ const GeoDataGroundOverlayPrivate* const other_d = other.d_func();
+
return equals(other) &&
- d->m_altitude == other.d->m_altitude &&
- d->m_altitudeMode == other.d->m_altitudeMode &&
- d->m_latLonBox == other.d->m_latLonBox &&
- d->m_latLonQuad == other.d->m_latLonQuad;
+ d->m_altitude == other_d->m_altitude &&
+ d->m_altitudeMode == other_d->m_altitudeMode &&
+ d->m_latLonBox == other_d->m_latLonBox &&
+ d->m_latLonQuad == other_d->m_latLonQuad;
}
bool GeoDataGroundOverlay::operator!=(const GeoDataGroundOverlay& other) const
@@ -68,7 +55,11 @@ bool GeoDataGroundOverlay::operator!=(const GeoDataGroundOverlay& other) const
GeoDataGroundOverlay::~GeoDataGroundOverlay()
{
- delete d;
+}
+
+GeoDataFeature * GeoDataGroundOverlay::clone() const
+{
+ return new GeoDataGroundOverlay(*this);
}
const char *GeoDataGroundOverlay::nodeType() const
@@ -78,46 +69,61 @@ const char *GeoDataGroundOverlay::nodeType() const
double GeoDataGroundOverlay::altitude() const
{
+ Q_D(const GeoDataGroundOverlay);
return d->m_altitude;
}
void GeoDataGroundOverlay::setAltitude( double altitude )
{
+ Q_D(GeoDataGroundOverlay);
d->m_altitude = altitude;
}
AltitudeMode GeoDataGroundOverlay::altitudeMode() const
{
+ Q_D(const GeoDataGroundOverlay);
return d->m_altitudeMode;
}
void GeoDataGroundOverlay::setAltitudeMode( const AltitudeMode altitudeMode )
{
+ Q_D(GeoDataGroundOverlay);
d->m_altitudeMode = altitudeMode;
}
-GeoDataLatLonBox &GeoDataGroundOverlay::latLonBox() const
+GeoDataLatLonBox &GeoDataGroundOverlay::latLonBox()
+{
+ Q_D(GeoDataGroundOverlay);
+ return d->m_latLonBox;
+}
+
+const GeoDataLatLonBox &GeoDataGroundOverlay::latLonBox() const
{
+ Q_D(const GeoDataGroundOverlay);
return d->m_latLonBox;
}
void GeoDataGroundOverlay::setLatLonBox( const GeoDataLatLonBox &box )
{
+ Q_D(GeoDataGroundOverlay);
d->m_latLonBox = box;
}
GeoDataLatLonQuad &GeoDataGroundOverlay::latLonQuad()
{
+ Q_D(GeoDataGroundOverlay);
return d->m_latLonQuad;
}
const GeoDataLatLonQuad &GeoDataGroundOverlay::latLonQuad() const
{
+ Q_D(const GeoDataGroundOverlay);
return d->m_latLonQuad;
}
void GeoDataGroundOverlay::setLatLonQuad(const GeoDataLatLonQuad& quad)
{
+ Q_D(GeoDataGroundOverlay);
d->m_latLonQuad = quad;
}
diff --git a/src/lib/marble/geodata/data/GeoDataGroundOverlay.h b/src/lib/marble/geodata/data/GeoDataGroundOverlay.h
index 8f466ec..5bc6283 100644
--- a/src/lib/marble/geodata/data/GeoDataGroundOverlay.h
+++ b/src/lib/marble/geodata/data/GeoDataGroundOverlay.h
@@ -30,10 +30,13 @@ public:
GeoDataGroundOverlay( const GeoDataGroundOverlay &other );
+ ~GeoDataGroundOverlay();
+
GeoDataGroundOverlay& operator=( const GeoDataGroundOverlay &other );
bool operator==( const GeoDataGroundOverlay &other ) const;
bool operator!=( const GeoDataGroundOverlay &other ) const;
- ~GeoDataGroundOverlay();
+
+ GeoDataFeature * clone() const override;
/** Provides type information for downcasting a GeoNode */
virtual const char* nodeType() const;
@@ -46,7 +49,9 @@ public:
void setAltitudeMode( const AltitudeMode altitudeMode );
- GeoDataLatLonBox& latLonBox() const;
+ const GeoDataLatLonBox& latLonBox() const;
+
+ GeoDataLatLonBox& latLonBox();
void setLatLonBox( const GeoDataLatLonBox &box );
@@ -57,7 +62,7 @@ public:
void setLatLonQuad( const GeoDataLatLonQuad &quad );
private:
- GeoDataGroundOverlayPrivate* const d;
+ Q_DECLARE_PRIVATE(GeoDataGroundOverlay)
};
}
diff --git a/src/lib/marble/geodata/data/GeoDataGroundOverlay_p.h b/src/lib/marble/geodata/data/GeoDataGroundOverlay_p.h
new file mode 100644
index 0000000..2f718ca
--- /dev/null
+++ b/src/lib/marble/geodata/data/GeoDataGroundOverlay_p.h
@@ -0,0 +1,43 @@
+//
+// This file is part of the Marble Virtual Globe.
+//
+// This program is free software licensed under the GNU LGPL. You can
+// find a copy of this license in LICENSE.txt in the top directory of
+// the source code.
+//
+// Copyright 2012 Dennis Nienhüser <nienhueser@kde.org>
+//
+
+#ifndef GEODATAGROUNDOVERLAY_P_H
+#define GEODATAGROUNDOVERLAY_P_H
+
+#include "GeoDataOverlay_p.h"
+
+#include "GeoDataTypes.h"
+#include "GeoDataLatLonQuad.h"
+
+namespace Marble {
+
+class GeoDataGroundOverlayPrivate : public GeoDataOverlayPrivate
+{
+public:
+ double m_altitude;
+
+ AltitudeMode m_altitudeMode;
+
+ GeoDataLatLonBox m_latLonBox;
+
+ GeoDataLatLonQuad m_latLonQuad;
+
+ GeoDataGroundOverlayPrivate();
+};
+
+GeoDataGroundOverlayPrivate::GeoDataGroundOverlayPrivate()
+ : m_altitude(0.0),
+ m_altitudeMode(ClampToGround)
+{
+}
+
+}
+
+#endif
diff --git a/src/lib/marble/geodata/data/GeoDataNetworkLink.cpp b/src/lib/marble/geodata/data/GeoDataNetworkLink.cpp
index 89c607c..3e86d51 100644
--- a/src/lib/marble/geodata/data/GeoDataNetworkLink.cpp
+++ b/src/lib/marble/geodata/data/GeoDataNetworkLink.cpp
@@ -69,6 +69,12 @@ GeoDataNetworkLink::~GeoDataNetworkLink()
delete d;
}
+GeoDataFeature * GeoDataNetworkLink::clone() const
+{
+ return new GeoDataNetworkLink(*this);
+}
+
+
const char *GeoDataNetworkLink::nodeType() const
{
return GeoDataTypes::GeoDataNetworkLinkType;
diff --git a/src/lib/marble/geodata/data/GeoDataNetworkLink.h b/src/lib/marble/geodata/data/GeoDataNetworkLink.h
index 8abd55b..93ce3b0 100644
--- a/src/lib/marble/geodata/data/GeoDataNetworkLink.h
+++ b/src/lib/marble/geodata/data/GeoDataNetworkLink.h
@@ -36,6 +36,8 @@ public:
~GeoDataNetworkLink();
+ GeoDataFeature * clone() const override;
+
/** Provides type information for downcasting a GeoNode */
virtual const char* nodeType() const;
diff --git a/src/lib/marble/geodata/data/GeoDataNetworkLinkControl.cpp b/src/lib/marble/geodata/data/GeoDataNetworkLinkControl.cpp
index 20ff266..558264c 100644
--- a/src/lib/marble/geodata/data/GeoDataNetworkLinkControl.cpp
+++ b/src/lib/marble/geodata/data/GeoDataNetworkLinkControl.cpp
@@ -9,111 +9,70 @@
//
#include "GeoDataNetworkLinkControl.h"
+#include "GeoDataNetworkLinkControl_p.h"
-#include "GeoDataTypes.h"
#include "GeoDataCamera.h"
#include "GeoDataLookAt.h"
-#include "GeoDataUpdate.h"
-#include <QDateTime>
namespace Marble
{
-class GeoDataNetworkLinkControlPrivate
-{
-public:
- GeoDataNetworkLinkControlPrivate();
-
- GeoDataNetworkLinkControlPrivate( const GeoDataNetworkLinkControlPrivate &other );
-
- qreal m_minRefreshPeriod;
- qreal m_maxSessionLength;
- QString m_cookie;
- QString m_message;
- QString m_linkName;
- QString m_linkDescription;
- QString m_linkSnippet;
- int m_maxLines;
- QDateTime m_expires;
- GeoDataUpdate m_update;
- GeoDataAbstractView *m_abstractView;
-};
-
-GeoDataNetworkLinkControlPrivate::GeoDataNetworkLinkControlPrivate() :
- m_minRefreshPeriod( 0.0 ),
- m_maxSessionLength( 0.0 ),
- m_maxLines( 2 ),
- m_expires(),
- m_update(),
- m_abstractView( 0 )
-{
-}
-
-GeoDataNetworkLinkControlPrivate::GeoDataNetworkLinkControlPrivate( const GeoDataNetworkLinkControlPrivate &other ) :
- m_minRefreshPeriod( other.m_minRefreshPeriod ),
- m_maxSessionLength( other.m_maxSessionLength ),
- m_cookie( other.m_cookie ),
- m_message( other.m_message ),
- m_linkName( other.m_linkName ),
- m_linkDescription( other.m_linkDescription ),
- m_linkSnippet( other.m_linkSnippet ),
- m_maxLines( other.m_maxLines ),
- m_expires( other.m_expires ),
- m_update( other.m_update ),
- m_abstractView( other.m_abstractView ? other.m_abstractView->copy() : 0 )
-{
-}
-
-GeoDataNetworkLinkControl::GeoDataNetworkLinkControl() :
- d( new GeoDataNetworkLinkControlPrivate )
+GeoDataNetworkLinkControl::GeoDataNetworkLinkControl()
+ : GeoDataContainer(new GeoDataNetworkLinkControlPrivate)
{
}
-GeoDataNetworkLinkControl::GeoDataNetworkLinkControl( const Marble::GeoDataNetworkLinkControl &other ) :
- GeoDataContainer(), d( new GeoDataNetworkLinkControlPrivate( *other.d ) )
+GeoDataNetworkLinkControl::GeoDataNetworkLinkControl(const GeoDataNetworkLinkControl &other)
+ : GeoDataContainer(other, new GeoDataNetworkLinkControlPrivate(*other.d_func()))
{
}
GeoDataNetworkLinkControl &GeoDataNetworkLinkControl::operator=( const GeoDataNetworkLinkControl &other )
{
- GeoDataContainer::operator =( other );
- *d = *other.d;
- d->m_abstractView = other.d->m_abstractView ? other.d->m_abstractView->copy() : 0;
+ if (this != &other) {
+ Q_D(GeoDataNetworkLinkControl);
+ *d = *other.d_func();
+ }
+
return *this;
}
bool GeoDataNetworkLinkControl::operator==( const GeoDataNetworkLinkControl &other ) const
{
+ Q_D(const GeoDataNetworkLinkControl);
+ const GeoDataNetworkLinkControlPrivate* const other_d = other.d_func();
+
if ( !GeoDataContainer::equals(other) ||
- d->m_minRefreshPeriod != other.d->m_minRefreshPeriod ||
- d->m_maxSessionLength != other.d->m_maxSessionLength ||
- d->m_cookie != other.d->m_cookie ||
- d->m_message != other.d->m_message ||
- d->m_linkName != other.d->m_linkName ||
- d->m_linkDescription != other.d->m_linkDescription ||
- d->m_linkSnippet != other.d->m_linkSnippet ||
- d->m_maxLines != other.d->m_maxLines ||
- d->m_expires != other.d->m_expires ||
- d->m_update != other.d->m_update ) {
+ d->m_minRefreshPeriod != other_d->m_minRefreshPeriod ||
+ d->m_maxSessionLength != other_d->m_maxSessionLength ||
+ d->m_cookie != other_d->m_cookie ||
+ d->m_message != other_d->m_message ||
+ d->m_linkName != other_d->m_linkName ||
+ d->m_linkDescription != other_d->m_linkDescription ||
+ d->m_linkSnippet != other_d->m_linkSnippet ||
+ d->m_maxLines != other_d->m_maxLines ||
+ d->m_expires != other_d->m_expires ||
+ d->m_update != other_d->m_update ) {
return false;
}
- if ( !d->m_abstractView && !other.d->m_abstractView ) {
+ if (!d->m_abstractView && !other_d->m_abstractView) {
return true;
- } else if ( (!d->m_abstractView && other.d->m_abstractView) ||
- (d->m_abstractView && !other.d->m_abstractView) ) {
+ }
+ if ((!d->m_abstractView && other_d->m_abstractView) ||
+ (d->m_abstractView && !other_d->m_abstractView)) {
return false;
}
- if ( d->m_abstractView->nodeType() != other.d->m_abstractView->nodeType() ) {
+ if (d->m_abstractView->nodeType() != other_d->m_abstractView->nodeType()) {
return false;
}
if ( d->m_abstractView->nodeType() == GeoDataTypes::GeoDataCameraType ) {
GeoDataCamera *thisCam = dynamic_cast<GeoDataCamera*>( d->m_abstractView );
- GeoDataCamera *otherCam = dynamic_cast<GeoDataCamera*>( other.d->m_abstractView );
+ GeoDataCamera *otherCam = dynamic_cast<GeoDataCamera*>(other_d->m_abstractView);
Q_ASSERT(thisCam && otherCam);
if ( *thisCam != *otherCam ) {
@@ -121,7 +80,7 @@ bool GeoDataNetworkLinkControl::operator==( const GeoDataNetworkLinkControl &oth
}
} else if ( d->m_abstractView->nodeType() == GeoDataTypes::GeoDataLookAtType ) {
GeoDataLookAt *thisLookAt = dynamic_cast<GeoDataLookAt*>( d->m_abstractView );
- GeoDataLookAt *otherLookAt = dynamic_cast<GeoDataLookAt*>( other.d->m_abstractView );
+ GeoDataLookAt *otherLookAt = dynamic_cast<GeoDataLookAt*>(other_d->m_abstractView);
Q_ASSERT(thisLookAt && otherLookAt);
if ( *thisLookAt != *otherLookAt ) {
@@ -139,127 +98,155 @@ bool GeoDataNetworkLinkControl::operator!=( const GeoDataNetworkLinkControl &oth
GeoDataNetworkLinkControl::~GeoDataNetworkLinkControl()
{
- delete d->m_abstractView;
- delete d;
}
+GeoDataFeature * GeoDataNetworkLinkControl::clone() const
+{
+ return new GeoDataNetworkLinkControl(*this);
+}
+
+
const char *GeoDataNetworkLinkControl::nodeType() const
{
+ Q_D(const GeoDataNetworkLinkControl);
return GeoDataTypes::GeoDataNetworkLinkControlType;
}
qreal GeoDataNetworkLinkControl::minRefreshPeriod() const
{
+ Q_D(const GeoDataNetworkLinkControl);
return d->m_minRefreshPeriod;
}
void GeoDataNetworkLinkControl::setMinRefreshPeriod(qreal minRefreshPeriod )
{
+ Q_D(GeoDataNetworkLinkControl);
d->m_minRefreshPeriod = minRefreshPeriod;
}
qreal GeoDataNetworkLinkControl::maxSessionLength() const
{
+ Q_D(const GeoDataNetworkLinkControl);
return d->m_maxSessionLength;
}
void GeoDataNetworkLinkControl::setMaxSessionLength(qreal maxSessionLength)
{
+ Q_D(GeoDataNetworkLinkControl);
d->m_maxSessionLength = maxSessionLength;
}
QString GeoDataNetworkLinkControl::cookie() const
{
+ Q_D(const GeoDataNetworkLinkControl);
return d->m_cookie;
}
void GeoDataNetworkLinkControl::setCookie( const QString &cookie )
{
+ Q_D(GeoDataNetworkLinkControl);
d->m_cookie = cookie;
}
QString GeoDataNetworkLinkControl::message() const
{
+ Q_D(const GeoDataNetworkLinkControl);
return d->m_message;
}
void GeoDataNetworkLinkControl::setMessage( const QString &message )
{
+ Q_D(GeoDataNetworkLinkControl);
d->m_message = message;
}
QString GeoDataNetworkLinkControl::linkName() const
{
+ Q_D(const GeoDataNetworkLinkControl);
return d->m_linkName;
}
void GeoDataNetworkLinkControl::setLinkName( const QString &linkName )
{
+ Q_D(GeoDataNetworkLinkControl);
d->m_linkName = linkName;
}
QString GeoDataNetworkLinkControl::linkDescription() const
{
+ Q_D(const GeoDataNetworkLinkControl);
return d->m_linkDescription;
}
void GeoDataNetworkLinkControl::setLinkDescription( const QString &linkDescription )
{
+ Q_D(GeoDataNetworkLinkControl);
d->m_linkDescription = linkDescription;
}
QString GeoDataNetworkLinkControl::linkSnippet() const
{
+ Q_D(const GeoDataNetworkLinkControl);
return d->m_linkSnippet;
}
void GeoDataNetworkLinkControl::setLinkSnippet( const QString &linkSnippet )
{
+ Q_D(GeoDataNetworkLinkControl);
d->m_linkSnippet = linkSnippet;
}
int GeoDataNetworkLinkControl::maxLines() const
{
+ Q_D(const GeoDataNetworkLinkControl);
return d->m_maxLines;
}
void GeoDataNetworkLinkControl::setMaxLines(int maxLines)
{
+ Q_D(GeoDataNetworkLinkControl);
d->m_maxLines = maxLines;
}
QDateTime GeoDataNetworkLinkControl::expires() const
{
+ Q_D(const GeoDataNetworkLinkControl);
return d->m_expires;
}
void GeoDataNetworkLinkControl::setExpires( const QDateTime &expires )
{
+ Q_D(GeoDataNetworkLinkControl);
d->m_expires = expires;
}
GeoDataUpdate &GeoDataNetworkLinkControl::update()
{
+ Q_D(GeoDataNetworkLinkControl);
return d->m_update;
}
const GeoDataUpdate& GeoDataNetworkLinkControl::update() const
{
+ Q_D(const GeoDataNetworkLinkControl);
return d->m_update;
}
void GeoDataNetworkLinkControl::setUpdate( const GeoDataUpdate &update )
{
+ Q_D(GeoDataNetworkLinkControl);
d->m_update = update;
}
GeoDataAbstractView *GeoDataNetworkLinkControl::abstractView() const
{
+ Q_D(const GeoDataNetworkLinkControl);
return d->m_abstractView;
}
void GeoDataNetworkLinkControl::setAbstractView( GeoDataAbstractView *abstractView )
{
+ Q_D(GeoDataNetworkLinkControl);
d->m_abstractView = abstractView;
d->m_abstractView->setParent( this );
}
diff --git a/src/lib/marble/geodata/data/GeoDataNetworkLinkControl.h b/src/lib/marble/geodata/data/GeoDataNetworkLinkControl.h
index b5d5fbb..2f8d814 100644
--- a/src/lib/marble/geodata/data/GeoDataNetworkLinkControl.h
+++ b/src/lib/marble/geodata/data/GeoDataNetworkLinkControl.h
@@ -32,12 +32,14 @@ public:
GeoDataNetworkLinkControl( const GeoDataNetworkLinkControl &other );
+ ~GeoDataNetworkLinkControl();
+
GeoDataNetworkLinkControl& operator=( const GeoDataNetworkLinkControl &other );
bool operator==( const GeoDataNetworkLinkControl &other ) const;
bool operator!=( const GeoDataNetworkLinkControl &other ) const;
- ~GeoDataNetworkLinkControl();
+ GeoDataFeature * clone() const override;
/** Provides type information for downcasting a GeoNode */
virtual const char* nodeType() const;
@@ -79,7 +81,7 @@ public:
void setAbstractView( GeoDataAbstractView *abstractView );
private:
- GeoDataNetworkLinkControlPrivate* const d;
+ Q_DECLARE_PRIVATE(GeoDataNetworkLinkControl)
};
}
diff --git a/src/lib/marble/geodata/data/GeoDataNetworkLinkControl_p.h b/src/lib/marble/geodata/data/GeoDataNetworkLinkControl_p.h
new file mode 100644
index 0000000..8286c53
--- /dev/null
+++ b/src/lib/marble/geodata/data/GeoDataNetworkLinkControl_p.h
@@ -0,0 +1,97 @@
+//
+// This file is part of the Marble Virtual Globe.
+//
+// This program is free software licensed under the GNU LGPL. You can
+// find a copy of this license in LICENSE.txt in the top directory of
+// the source code.
+//
+// Copyright 2013 Mohammed Nafees <nafees.technocool@gmail.com>
+//
+
+#ifndef GEODATANETWORKLINKCONTROL_P_H
+#define GEODATANETWORKLINKCONTROL_P_H
+
+#include "GeoDataContainer_p.h"
+
+#include "GeoDataTypes.h"
+#include "GeoDataUpdate.h"
+#include <QDateTime>
+
+namespace Marble
+{
+
+class GeoDataNetworkLinkControlPrivate : public GeoDataContainerPrivate
+{
+public:
+ GeoDataNetworkLinkControlPrivate();
+ GeoDataNetworkLinkControlPrivate(const GeoDataNetworkLinkControlPrivate &other);
+ ~GeoDataNetworkLinkControlPrivate();
+ GeoDataNetworkLinkControlPrivate& operator=(const GeoDataNetworkLinkControlPrivate &other);
+
+ qreal m_minRefreshPeriod;
+ qreal m_maxSessionLength;
+ QString m_cookie;
+ QString m_message;
+ QString m_linkName;
+ QString m_linkDescription;
+ QString m_linkSnippet;
+ int m_maxLines;
+ QDateTime m_expires;
+ GeoDataUpdate m_update;
+ GeoDataAbstractView *m_abstractView;
+};
+
+GeoDataNetworkLinkControlPrivate::GeoDataNetworkLinkControlPrivate() :
+ m_minRefreshPeriod( 0.0 ),
+ m_maxSessionLength( 0.0 ),
+ m_maxLines( 2 ),
+ m_expires(),
+ m_update(),
+ m_abstractView( 0 )
+{
+}
+
+GeoDataNetworkLinkControlPrivate::GeoDataNetworkLinkControlPrivate( const GeoDataNetworkLinkControlPrivate &other )
+ : GeoDataContainerPrivate(other),
+ m_minRefreshPeriod(other.m_minRefreshPeriod),
+ m_maxSessionLength(other.m_maxSessionLength),
+ m_cookie(other.m_cookie),
+ m_message(other.m_message),
+ m_linkName(other.m_linkName),
+ m_linkDescription(other.m_linkDescription),
+ m_linkSnippet(other.m_linkSnippet),
+ m_maxLines(other.m_maxLines),
+ m_expires(other.m_expires),
+ m_update(other.m_update),
+ m_abstractView(other.m_abstractView ? other.m_abstractView->copy() : 0)
+{
+}
+
+GeoDataNetworkLinkControlPrivate::~GeoDataNetworkLinkControlPrivate()
+{
+ delete m_abstractView;
+}
+
+GeoDataNetworkLinkControlPrivate& GeoDataNetworkLinkControlPrivate::operator=(const GeoDataNetworkLinkControlPrivate &other)
+{
+ GeoDataContainerPrivate::operator=(other);
+ m_minRefreshPeriod = other.m_minRefreshPeriod;
+ m_maxSessionLength = other.m_maxSessionLength;
+ m_cookie = other.m_cookie;
+ m_message = other.m_message;
+ m_linkName = other.m_linkName;
+ m_linkDescription = other.m_linkDescription;
+ m_linkSnippet = other.m_linkSnippet;
+ m_maxLines = other.m_maxLines;
+ m_expires = other.m_expires;
+ m_update = other.m_update;
+
+ delete m_abstractView;
+ m_abstractView = other.m_abstractView ? other.m_abstractView->copy() : 0;
+
+ return *this;
+}
+
+}
+
+#endif
diff --git a/src/lib/marble/geodata/data/GeoDataOverlay.cpp b/src/lib/marble/geodata/data/GeoDataOverlay.cpp
index e8e0730..b97f773 100644
--- a/src/lib/marble/geodata/data/GeoDataOverlay.cpp
+++ b/src/lib/marble/geodata/data/GeoDataOverlay.cpp
@@ -9,77 +9,80 @@
//
#include "GeoDataOverlay.h"
-#include "GeoDataDocument.h"
+#include "GeoDataOverlay_p.h"
-#include <QImage>
-#include <QColor>
+#include "GeoDataDocument.h"
namespace Marble {
-class GeoDataOverlayPrivate
+GeoDataOverlay::GeoDataOverlay()
+ : GeoDataFeature(new GeoDataOverlayPrivate)
{
-public:
- QColor m_color;
-
- int m_drawOrder;
-
- QImage m_image;
-
- QString m_iconPath;
-
- GeoDataOverlayPrivate();
-};
+ // nothing to do
+}
-GeoDataOverlayPrivate::GeoDataOverlayPrivate() : m_color( Qt::white ), m_drawOrder( 0 )
+GeoDataOverlay::GeoDataOverlay(const GeoDataOverlay &other)
+ : GeoDataFeature(other, new GeoDataOverlayPrivate(*other.d_func()))
{
// nothing to do
}
-GeoDataOverlay::GeoDataOverlay() : d( new GeoDataOverlayPrivate )
+GeoDataOverlay::GeoDataOverlay(GeoDataOverlayPrivate *priv)
+ : GeoDataFeature(priv)
{
- // nothing to do
}
-GeoDataOverlay::~GeoDataOverlay()
+GeoDataOverlay::GeoDataOverlay(const GeoDataOverlay& other, GeoDataOverlayPrivate *priv)
+ : GeoDataFeature(other, priv)
{
- delete d;
}
-GeoDataOverlay::GeoDataOverlay( const GeoDataOverlay &other ) :
- GeoDataFeature( other ), d( new GeoDataOverlayPrivate( *other.d ) )
+GeoDataOverlay::~GeoDataOverlay()
{
- // nothing to do
}
GeoDataOverlay &GeoDataOverlay::operator=( const GeoDataOverlay &other )
{
- GeoDataFeature::operator=( other );
- *d = *other.d;
+ if (this != &other) {
+ Q_D(GeoDataOverlay);
+ *d = *other.d_func();
+ }
+
return *this;
}
+GeoDataFeature * GeoDataOverlay::clone() const
+{
+ return new GeoDataOverlay(*this);
+}
+
QColor GeoDataOverlay::color() const
{
+ Q_D(const GeoDataOverlay);
return d->m_color;
}
void GeoDataOverlay::setColor( const QColor &color )
{
+ Q_D(GeoDataOverlay);
d->m_color = color;
}
int GeoDataOverlay::drawOrder() const
{
+ Q_D(const GeoDataOverlay);
return d->m_drawOrder;
}
void GeoDataOverlay::setDrawOrder( int order )
{
+ Q_D(GeoDataOverlay);
d->m_drawOrder = order;
}
QImage GeoDataOverlay::icon() const
{
+ Q_D(const GeoDataOverlay);
if ( d->m_image.isNull() && !d->m_iconPath.isEmpty() ) {
d->m_image = QImage( absoluteIconFile() );
}
@@ -88,32 +91,39 @@ QImage GeoDataOverlay::icon() const
void GeoDataOverlay::setIcon( const QImage &icon )
{
+ Q_D(GeoDataOverlay);
d->m_image = icon;
}
void GeoDataOverlay::setIconFile( const QString &path )
{
+ Q_D(GeoDataOverlay);
d->m_iconPath = path;
d->m_image = QImage( path );
}
QString GeoDataOverlay::iconFile() const
{
+ Q_D(const GeoDataOverlay);
return d->m_iconPath;
}
QString GeoDataOverlay::absoluteIconFile() const
{
+ Q_D(const GeoDataOverlay);
return resolvePath( d->m_iconPath );
}
bool GeoDataOverlay::equals(const GeoDataOverlay& other) const
{
+ Q_D(const GeoDataOverlay);
+ const GeoDataOverlayPrivate* const other_d = other.d_func();
+
return GeoDataFeature::equals(other) &&
- d->m_drawOrder == other.d->m_drawOrder &&
- d->m_color == other.d->m_color &&
- d->m_iconPath == other.d->m_iconPath &&
- d->m_image == other.d->m_image;
+ d->m_drawOrder == other_d->m_drawOrder &&
+ d->m_color == other_d->m_color &&
+ d->m_iconPath == other_d->m_iconPath &&
+ d->m_image == other_d->m_image;
}
}
diff --git a/src/lib/marble/geodata/data/GeoDataOverlay.h b/src/lib/marble/geodata/data/GeoDataOverlay.h
index 1002df7..0184210 100644
--- a/src/lib/marble/geodata/data/GeoDataOverlay.h
+++ b/src/lib/marble/geodata/data/GeoDataOverlay.h
@@ -37,6 +37,8 @@ class GEODATA_EXPORT GeoDataOverlay: public GeoDataFeature
GeoDataOverlay& operator=( const GeoDataOverlay &other );
+ GeoDataFeature * clone() const override;
+
QColor color() const;
void setColor( const QColor &color );
@@ -60,12 +62,15 @@ class GEODATA_EXPORT GeoDataOverlay: public GeoDataFeature
*/
QString absoluteIconFile() const;
-private:
- GeoDataOverlayPrivate * const d;
-
protected:
+ explicit GeoDataOverlay(GeoDataOverlayPrivate *priv);
+ GeoDataOverlay(const GeoDataOverlay& other, GeoDataOverlayPrivate *priv);
+
bool equals(const GeoDataOverlay &other) const;
using GeoDataFeature::equals;
+
+ private:
+ Q_DECLARE_PRIVATE(GeoDataOverlay)
};
}
diff --git a/src/lib/marble/geodata/data/GeoDataOverlay_p.h b/src/lib/marble/geodata/data/GeoDataOverlay_p.h
new file mode 100644
index 0000000..2d43b59
--- /dev/null
+++ b/src/lib/marble/geodata/data/GeoDataOverlay_p.h
@@ -0,0 +1,48 @@
+//
+// This file is part of the Marble Virtual Globe.
+//
+// This program is free software licensed under the GNU LGPL. You can
+// find a copy of this license in LICENSE.txt in the top directory of
+// the source code.
+//
+// Copyright 2012 Dennis Nienhüser <nienhueser@kde.org>
+//
+
+#ifndef MARBLE_GEODATAOVERLAY_P_H
+#define MARBLE_GEODATAOVERLAY_P_H
+
+#include "GeoDataFeature_p.h"
+
+#include <QImage>
+#include <QColor>
+
+namespace Marble {
+
+class GeoDataOverlayPrivate : public GeoDataFeaturePrivate
+{
+public:
+ QColor m_color;
+
+ int m_drawOrder;
+
+ mutable QImage m_image;
+
+ QString m_iconPath;
+
+ GeoDataOverlayPrivate()
+ : m_color(Qt::white),
+ m_drawOrder(0)
+ {
+ }
+
+ GeoDataOverlayPrivate(const GeoDataOverlayPrivate& other)
+ : GeoDataFeaturePrivate(other),
+ m_color(Qt::white),
+ m_drawOrder(0)
+ {
+ }
+};
+
+}
+
+#endif
diff --git a/src/lib/marble/geodata/data/GeoDataPhotoOverlay.cpp b/src/lib/marble/geodata/data/GeoDataPhotoOverlay.cpp
index 3165f00..7422b4b 100644
--- a/src/lib/marble/geodata/data/GeoDataPhotoOverlay.cpp
+++ b/src/lib/marble/geodata/data/GeoDataPhotoOverlay.cpp
@@ -10,61 +10,47 @@
//
#include "GeoDataPhotoOverlay.h"
-#include "GeoDataTypes.h"
-#include "GeoDataPoint.h"
-#include "GeoDataImagePyramid.h"
-#include "GeoDataViewVolume.h"
+#include "GeoDataPhotoOverlay_p.h"
namespace Marble {
-class GeoDataPhotoOverlayPrivate
-{
-public:
- GeoDataPhotoOverlayPrivate();
-
- qreal m_rotation;
- GeoDataViewVolume m_viewVolume;
- GeoDataImagePyramid m_imagePyramid;
- GeoDataPoint m_point;
- GeoDataPhotoOverlay::Shape m_shape;
-};
-
-GeoDataPhotoOverlayPrivate::GeoDataPhotoOverlayPrivate() :
- m_rotation( 0.0 ),
- m_viewVolume(),
- m_imagePyramid(),
- m_point(),
- m_shape( GeoDataPhotoOverlay::Rectangle )
+GeoDataPhotoOverlay::GeoDataPhotoOverlay()
+ : GeoDataOverlay(new GeoDataPhotoOverlayPrivate)
{
// nothing to do
}
-GeoDataPhotoOverlay::GeoDataPhotoOverlay() : d( new GeoDataPhotoOverlayPrivate )
+GeoDataPhotoOverlay::GeoDataPhotoOverlay(const GeoDataPhotoOverlay &other)
+ : GeoDataOverlay(other, new GeoDataPhotoOverlayPrivate(*other.d_func()))
{
// nothing to do
}
-GeoDataPhotoOverlay::GeoDataPhotoOverlay( const Marble::GeoDataPhotoOverlay &other ) :
- GeoDataOverlay( other ), d( new GeoDataPhotoOverlayPrivate( *other.d ) )
+GeoDataPhotoOverlay::~GeoDataPhotoOverlay()
{
- // nothing to do
}
GeoDataPhotoOverlay &GeoDataPhotoOverlay::operator=( const GeoDataPhotoOverlay &other )
{
- GeoDataOverlay::operator=( other );
- *d = *other.d;
+ if (this != &other) {
+ Q_D(GeoDataPhotoOverlay);
+ *d = *other.d_func();
+ }
+
return *this;
}
bool GeoDataPhotoOverlay::operator==(const GeoDataPhotoOverlay& other) const
{
+ Q_D(const GeoDataPhotoOverlay);
+ const GeoDataPhotoOverlayPrivate* const other_d = other.d_func();
+
return equals(other) &&
- d->m_rotation == other.d->m_rotation &&
- d->m_shape == other.d->m_shape &&
- d->m_imagePyramid == other.d->m_imagePyramid &&
- d->m_point == other.d->m_point &&
- d->m_viewVolume == other.d->m_viewVolume;
+ d->m_rotation == other_d->m_rotation &&
+ d->m_shape == other_d->m_shape &&
+ d->m_imagePyramid == other_d->m_imagePyramid &&
+ d->m_point == other_d->m_point &&
+ d->m_viewVolume == other_d->m_viewVolume;
}
bool GeoDataPhotoOverlay::operator!=(const GeoDataPhotoOverlay& other) const
@@ -72,78 +58,92 @@ bool GeoDataPhotoOverlay::operator!=(const GeoDataPhotoOverlay& other) const
return !this->operator==(other);
}
-GeoDataPhotoOverlay::~GeoDataPhotoOverlay()
+GeoDataFeature * GeoDataPhotoOverlay::clone() const
{
- delete d;
+ return new GeoDataPhotoOverlay(*this);
}
const char *GeoDataPhotoOverlay::nodeType() const
{
+ Q_D(const GeoDataPhotoOverlay);
return GeoDataTypes::GeoDataPhotoOverlayType;
}
qreal GeoDataPhotoOverlay::rotation() const
{
+ Q_D(const GeoDataPhotoOverlay);
return d->m_rotation;
}
void GeoDataPhotoOverlay::setRotation( const qreal rotation )
{
+ Q_D(GeoDataPhotoOverlay);
d->m_rotation = rotation;
}
GeoDataViewVolume& GeoDataPhotoOverlay::viewVolume()
{
+ Q_D(GeoDataPhotoOverlay);
return d->m_viewVolume;
}
const GeoDataViewVolume& GeoDataPhotoOverlay::viewVolume() const
{
+ Q_D(const GeoDataPhotoOverlay);
return d->m_viewVolume;
}
void GeoDataPhotoOverlay::setViewVolume( const GeoDataViewVolume &viewVolume )
{
+ Q_D(GeoDataPhotoOverlay);
d->m_viewVolume = viewVolume;
}
GeoDataImagePyramid& GeoDataPhotoOverlay::imagePyramid()
{
+ Q_D(GeoDataPhotoOverlay);
return d->m_imagePyramid;
}
const GeoDataImagePyramid& GeoDataPhotoOverlay::imagePyramid() const
{
+ Q_D(const GeoDataPhotoOverlay);
return d->m_imagePyramid;
}
void GeoDataPhotoOverlay::setImagePyramid( const GeoDataImagePyramid &imagePyramid )
{
+ Q_D(GeoDataPhotoOverlay);
d->m_imagePyramid = imagePyramid;
}
GeoDataPoint& GeoDataPhotoOverlay::point()
{
+ Q_D(GeoDataPhotoOverlay);
return d->m_point;
}
const GeoDataPoint& GeoDataPhotoOverlay::point() const
{
+ Q_D(const GeoDataPhotoOverlay);
return d->m_point;
}
void GeoDataPhotoOverlay::setPoint( const GeoDataPoint &point )
{
+ Q_D(GeoDataPhotoOverlay);
d->m_point = point;
}
GeoDataPhotoOverlay::Shape GeoDataPhotoOverlay::shape() const
{
+ Q_D(const GeoDataPhotoOverlay);
return d->m_shape;
}
void GeoDataPhotoOverlay::setShape( Shape shape )
{
+ Q_D(GeoDataPhotoOverlay);
d->m_shape = shape;
}
diff --git a/src/lib/marble/geodata/data/GeoDataPhotoOverlay.h b/src/lib/marble/geodata/data/GeoDataPhotoOverlay.h
index b9720ef..5ef8779 100644
--- a/src/lib/marble/geodata/data/GeoDataPhotoOverlay.h
+++ b/src/lib/marble/geodata/data/GeoDataPhotoOverlay.h
@@ -33,10 +33,13 @@ public:
GeoDataPhotoOverlay( const GeoDataPhotoOverlay &other );
+ ~GeoDataPhotoOverlay();
+
GeoDataPhotoOverlay& operator=( const GeoDataPhotoOverlay &other );
bool operator==( const GeoDataPhotoOverlay &other ) const;
bool operator!=( const GeoDataPhotoOverlay &other ) const;
- ~GeoDataPhotoOverlay();
+
+ GeoDataFeature * clone() const override;
/** Provides type information for downcasting a GeoNode */
virtual const char* nodeType() const;
@@ -66,7 +69,7 @@ public:
void setShape( Shape shape );
private:
- GeoDataPhotoOverlayPrivate* const d;
+ Q_DECLARE_PRIVATE(GeoDataPhotoOverlay)
};
}
diff --git a/src/lib/marble/geodata/data/GeoDataPhotoOverlay_p.h b/src/lib/marble/geodata/data/GeoDataPhotoOverlay_p.h
new file mode 100644
index 0000000..9b14c5d
--- /dev/null
+++ b/src/lib/marble/geodata/data/GeoDataPhotoOverlay_p.h
@@ -0,0 +1,58 @@
+//
+// This file is part of the Marble Virtual Globe.
+//
+// This program is free software licensed under the GNU LGPL. You can
+// find a copy of this license in LICENSE.txt in the top directory of
+// the source code.
+//
+// Copyright 2012 Dennis Nienhüser <nienhueser@kde.org>
+// Copyright 2013 Mohammed Nafees <nafees.technocool@gmail.com>
+//
+
+#ifndef MARBLE_GEODATAPHOTOOVERLAY_P_H
+#define MARBLE_GEODATAPHOTOOVERLAY_P_H
+
+#include "GeoDataOverlay_p.h"
+#include "GeoDataTypes.h"
+#include "GeoDataPoint.h"
+#include "GeoDataImagePyramid.h"
+#include "GeoDataViewVolume.h"
+
+namespace Marble {
+
+class GeoDataPhotoOverlayPrivate : public GeoDataOverlayPrivate
+{
+public:
+ GeoDataPhotoOverlayPrivate();
+ GeoDataPhotoOverlayPrivate(const GeoDataPhotoOverlayPrivate& other);
+
+ qreal m_rotation;
+ GeoDataViewVolume m_viewVolume;
+ GeoDataImagePyramid m_imagePyramid;
+ GeoDataPoint m_point;
+ GeoDataPhotoOverlay::Shape m_shape;
+};
+
+GeoDataPhotoOverlayPrivate::GeoDataPhotoOverlayPrivate() :
+ m_rotation( 0.0 ),
+ m_viewVolume(),
+ m_imagePyramid(),
+ m_point(),
+ m_shape( GeoDataPhotoOverlay::Rectangle )
+{
+ // nothing to do
+}
+
+GeoDataPhotoOverlayPrivate::GeoDataPhotoOverlayPrivate(const GeoDataPhotoOverlayPrivate& other)
+ : GeoDataOverlayPrivate(other),
+ m_rotation(other.m_rotation),
+ m_viewVolume(other.m_viewVolume),
+ m_imagePyramid(other.m_imagePyramid),
+ m_point(other.m_point),
+ m_shape(other.m_shape)
+{
+}
+
+}
+
+#endif
diff --git a/src/lib/marble/geodata/data/GeoDataPlacemark.cpp b/src/lib/marble/geodata/data/GeoDataPlacemark.cpp
index ad7cbe4..a2a268d 100644
--- a/src/lib/marble/geodata/data/GeoDataPlacemark.cpp
+++ b/src/lib/marble/geodata/data/GeoDataPlacemark.cpp
@@ -44,15 +44,14 @@ GeoDataPlacemark::GeoDataPlacemark()
d->m_geometry->setParent(this);
}
+
GeoDataPlacemark::GeoDataPlacemark( const GeoDataPlacemark& other )
- : GeoDataFeature( other )
+ : GeoDataFeature(other, new GeoDataPlacemarkPrivate(*other.d_func()))
{
- // FIXME: temporary (until detach() is called) violates following invariant
- // which could lead to crashes
-// Q_ASSERT( this == p()->m_geometry->parent() );
-
- // FIXME: fails as well when "other" is a copy where detach wasn't called
-// Q_ASSERT( other_d->m_geometry == 0 || &other == other_d->m_geometry->parent() );
+ Q_D(GeoDataPlacemark);
+ if (d->m_geometry) {
+ d->m_geometry->setParent(this);
+ }
}
GeoDataPlacemark::GeoDataPlacemark( const QString& name )
@@ -70,7 +69,13 @@ GeoDataPlacemark::~GeoDataPlacemark()
GeoDataPlacemark &GeoDataPlacemark::operator=( const GeoDataPlacemark &other )
{
- GeoDataFeature::operator=( other );
+ if (this != &other) {
+ Q_D(GeoDataPlacemark);
+ *d = *other.d_func();
+ if (d->m_geometry) {
+ d->m_geometry->setParent(this);
+ }
+ }
return *this;
}
@@ -171,6 +176,12 @@ bool GeoDataPlacemark::operator!=( const GeoDataPlacemark& other ) const
return !this->operator==( other );
}
+GeoDataFeature * GeoDataPlacemark::clone() const
+{
+ return new GeoDataPlacemark(*this);
+}
+
+
GeoDataPlacemark::GeoDataVisualCategory GeoDataPlacemark::visualCategory() const
{
Q_D(const GeoDataPlacemark);
@@ -179,18 +190,13 @@ GeoDataPlacemark::GeoDataVisualCategory GeoDataPlacemark::visualCategory() const
void GeoDataPlacemark::setVisualCategory(GeoDataPlacemark::GeoDataVisualCategory index)
{
- detach();
-
Q_D(GeoDataPlacemark);
d->m_visualCategory = index;
}
GeoDataGeometry* GeoDataPlacemark::geometry()
{
- detach();
-
Q_D(GeoDataPlacemark);
- d->m_geometry->setParent(this);
return d->m_geometry;
}
@@ -237,7 +243,6 @@ bool GeoDataPlacemark::hasOsmData() const
void GeoDataPlacemark::clearOsmData()
{
- detach();
extendedData().removeKey(OsmPlacemarkData::osmHashKey());
}
@@ -327,8 +332,6 @@ void GeoDataPlacemark::setCoordinate( const GeoDataCoordinates &point )
void GeoDataPlacemark::setGeometry( GeoDataGeometry *entry )
{
- detach();
-
Q_D(GeoDataPlacemark);
delete d->m_geometry;
d->m_geometry = entry;
@@ -672,10 +675,7 @@ void GeoDataPlacemark::setArea( qreal area )
return; // nothing to do
}
- detach();
-
Q_D(GeoDataPlacemark);
- d->m_geometry->setParent(this);
d->placemarkExtendedData().m_area = area;
}
@@ -687,10 +687,7 @@ qint64 GeoDataPlacemark::population() const
void GeoDataPlacemark::setPopulation( qint64 population )
{
- detach();
-
Q_D(GeoDataPlacemark);
- d->m_geometry->setParent(this);
d->m_population = population;
}
@@ -706,10 +703,7 @@ void GeoDataPlacemark::setState( const QString &state )
return; // nothing to do
}
- detach();
-
Q_D(GeoDataPlacemark);
- d->m_geometry->setParent(this);
d->placemarkExtendedData().m_state = state;
}
@@ -725,10 +719,7 @@ void GeoDataPlacemark::setCountryCode( const QString &countrycode )
return; // nothing to do
}
- detach();
-
Q_D(GeoDataPlacemark);
- d->m_geometry->setParent(this);
d->placemarkExtendedData().m_countrycode = countrycode;
}
@@ -744,10 +735,7 @@ void GeoDataPlacemark::setBalloonVisible( bool visible )
return; // nothing to do
}
- detach();
-
Q_D(GeoDataPlacemark);
- d->m_geometry->setParent(this);
d->placemarkExtendedData().m_isBalloonVisible = visible;
}
@@ -785,11 +773,7 @@ QXmlStreamWriter& GeoDataPlacemark::operator <<( QXmlStreamWriter& stream ) cons
void GeoDataPlacemark::unpack( QDataStream& stream )
{
- detach();
-
Q_D(GeoDataPlacemark);
- // TODO: check if this should be done after the switch
- d->m_geometry->setParent(this);
GeoDataFeature::unpack( stream );
stream >> d->placemarkExtendedData().m_countrycode;
@@ -797,6 +781,7 @@ void GeoDataPlacemark::unpack( QDataStream& stream )
stream >> d->m_population;
int geometryId;
stream >> geometryId;
+ GeoDataGeometry *geometry = nullptr;
switch( geometryId ) {
case InvalidGeometryId:
break;
@@ -804,46 +789,46 @@ void GeoDataPlacemark::unpack( QDataStream& stream )
{
GeoDataPoint* point = new GeoDataPoint;
point->unpack( stream );
- delete d->m_geometry;
- d->m_geometry = point;
+ geometry = point;
}
break;
case GeoDataLineStringId:
{
GeoDataLineString* lineString = new GeoDataLineString;
lineString->unpack( stream );
- delete d->m_geometry;
- d->m_geometry = lineString;
+ geometry = lineString;
}
break;
case GeoDataLinearRingId:
{
GeoDataLinearRing* linearRing = new GeoDataLinearRing;
linearRing->unpack( stream );
- delete d->m_geometry;
- d->m_geometry = linearRing;
+ geometry = linearRing;
}
break;
case GeoDataPolygonId:
{
GeoDataPolygon* polygon = new GeoDataPolygon;
polygon->unpack( stream );
- delete d->m_geometry;
- d->m_geometry = polygon;
+ geometry = polygon;
}
break;
case GeoDataMultiGeometryId:
{
GeoDataMultiGeometry* multiGeometry = new GeoDataMultiGeometry;
multiGeometry->unpack( stream );
- delete d->m_geometry;
- d->m_geometry = multiGeometry;
+ geometry = multiGeometry;
}
break;
case GeoDataModelId:
break;
default: break;
};
+ if (geometry) {
+ delete d->m_geometry;
+ d->m_geometry = geometry;
+ d->m_geometry->setParent(this);
+ }
}
}
diff --git a/src/lib/marble/geodata/data/GeoDataPlacemark.h b/src/lib/marble/geodata/data/GeoDataPlacemark.h
index f2b3007..d5343cd 100644
--- a/src/lib/marble/geodata/data/GeoDataPlacemark.h
+++ b/src/lib/marble/geodata/data/GeoDataPlacemark.h
@@ -81,6 +81,8 @@ class GEODATA_EXPORT GeoDataPlacemark: public GeoDataFeature
bool operator==( const GeoDataPlacemark& other ) const;
bool operator!=( const GeoDataPlacemark& other ) const;
+ GeoDataFeature * clone() const override;
+
/**
* @brief A categorization of a placemark as defined by ...FIXME.
* There is an additional osm tag mapping to GeoDataVisualCategory
diff --git a/src/lib/marble/geodata/data/GeoDataPlacemark_p.h b/src/lib/marble/geodata/data/GeoDataPlacemark_p.h
index 77db108..336ac7b 100644
--- a/src/lib/marble/geodata/data/GeoDataPlacemark_p.h
+++ b/src/lib/marble/geodata/data/GeoDataPlacemark_p.h
@@ -69,6 +69,18 @@ class GeoDataPlacemarkPrivate : public GeoDataFeaturePrivate
{
}
+ GeoDataPlacemarkPrivate(const GeoDataPlacemarkPrivate& other)
+ : GeoDataFeaturePrivate(other),
+ m_geometry(cloneGeometry(other.m_geometry)),
+ m_population(other.m_population),
+ m_placemarkExtendedData(nullptr),
+ m_visualCategory(other.m_visualCategory)
+ {
+ if (other.m_placemarkExtendedData) {
+ m_placemarkExtendedData = new GeoDataPlacemarkExtendedData(*other.m_placemarkExtendedData);
+ }
+ }
+
virtual ~GeoDataPlacemarkPrivate()
{
delete m_geometry;
@@ -82,68 +94,69 @@ class GeoDataPlacemarkPrivate : public GeoDataFeaturePrivate
}
GeoDataFeaturePrivate::operator=( other );
+
m_population = other.m_population;
m_visualCategory = other.m_visualCategory;
- GeoDataGeometry * geometry = 0;
- if ( other.m_geometry ) {
- switch( other.m_geometry->geometryId() ) {
+ delete m_geometry;
+ m_geometry = cloneGeometry(other.m_geometry);
+ // TODO: why not set parent here to geometry?
+
+ delete m_placemarkExtendedData;
+ if (other.m_placemarkExtendedData) {
+ m_placemarkExtendedData = new GeoDataPlacemarkExtendedData(*other.m_placemarkExtendedData);
+ } else {
+ m_placemarkExtendedData = nullptr;
+ }
+
+ return *this;
+ }
+
+ virtual const char* nodeType() const
+ {
+ return GeoDataTypes::GeoDataPlacemarkType;
+ }
+
+ virtual EnumFeatureId featureId() const
+ {
+ return GeoDataPlacemarkId;
+ }
+
+ static GeoDataGeometry * cloneGeometry(const GeoDataGeometry * geometry)
+ {
+ GeoDataGeometry * result = nullptr;
+ if (geometry) {
+ switch (geometry->geometryId()) {
case InvalidGeometryId:
break;
case GeoDataPointId:
- geometry = new GeoDataPoint( *static_cast<const GeoDataPoint*>( other.m_geometry ) );
+ result = new GeoDataPoint(*static_cast<const GeoDataPoint*>(geometry));
break;
case GeoDataLineStringId:
- geometry = new GeoDataLineString( *static_cast<const GeoDataLineString*>( other.m_geometry ) );
+ result = new GeoDataLineString(*static_cast<const GeoDataLineString*>(geometry));
break;
case GeoDataLinearRingId:
- geometry = new GeoDataLinearRing( *static_cast<const GeoDataLinearRing*>( other.m_geometry ) );
+ result = new GeoDataLinearRing(*static_cast<const GeoDataLinearRing*>(geometry));
break;
case GeoDataPolygonId:
- geometry = new GeoDataPolygon( *static_cast<const GeoDataPolygon*>( other.m_geometry ) );
+ result = new GeoDataPolygon(*static_cast<const GeoDataPolygon*>(geometry));
break;
case GeoDataMultiGeometryId:
- geometry = new GeoDataMultiGeometry( *static_cast<const GeoDataMultiGeometry*>( other.m_geometry ) );
+ result = new GeoDataMultiGeometry(*static_cast<const GeoDataMultiGeometry*>(geometry));
break;
case GeoDataTrackId:
- geometry = new GeoDataTrack( *static_cast<const GeoDataTrack*>( other.m_geometry ) );
+ result = new GeoDataTrack(*static_cast<const GeoDataTrack*>(geometry));
break;
case GeoDataMultiTrackId:
- geometry = new GeoDataMultiTrack( *static_cast<const GeoDataMultiTrack*>( other.m_geometry ) );
+ result = new GeoDataMultiTrack(*static_cast<const GeoDataMultiTrack*>(geometry));
break;
case GeoDataModelId:
break;
- default: break;
+ default:
+ break;
}
}
- delete m_geometry;
- m_geometry = geometry;
- // TODO: why not set parent here to geometry?
-
- delete m_placemarkExtendedData;
- m_placemarkExtendedData = nullptr;
- if (other.m_placemarkExtendedData) {
- m_placemarkExtendedData = new GeoDataPlacemarkExtendedData(*other.m_placemarkExtendedData);
- }
-
- return *this;
- }
-
- virtual GeoDataFeaturePrivate* copy()
- {
- GeoDataPlacemarkPrivate* copy = new GeoDataPlacemarkPrivate;
- *copy = *this;
- return copy;
- }
-
- virtual const char* nodeType() const
- {
- return GeoDataTypes::GeoDataPlacemarkType;
- }
-
- virtual EnumFeatureId featureId() const
- {
- return GeoDataPlacemarkId;
+ return result;
}
GeoDataPlacemarkExtendedData & placemarkExtendedData()
diff --git a/src/lib/marble/geodata/data/GeoDataScreenOverlay.cpp b/src/lib/marble/geodata/data/GeoDataScreenOverlay.cpp
index fd32d05..f73bc36 100644
--- a/src/lib/marble/geodata/data/GeoDataScreenOverlay.cpp
+++ b/src/lib/marble/geodata/data/GeoDataScreenOverlay.cpp
@@ -9,51 +9,46 @@
//
#include "GeoDataScreenOverlay.h"
+#include "GeoDataScreenOverlay_p.h"
#include "GeoDataTypes.h"
namespace Marble {
-class GeoDataScreenOverlayPrivate
-{
-public:
- GeoDataScreenOverlayPrivate();
-
- GeoDataVec2 m_overlayXY;
- GeoDataVec2 m_screenXY;
- GeoDataVec2 m_rotationXY;
- GeoDataVec2 m_size;
- qreal m_rotation;
-};
-
-GeoDataScreenOverlayPrivate::GeoDataScreenOverlayPrivate() :
- m_rotation(0.0)
+GeoDataScreenOverlay::GeoDataScreenOverlay()
+ : GeoDataOverlay(new GeoDataScreenOverlayPrivate)
{
}
-GeoDataScreenOverlay::GeoDataScreenOverlay() :
- d( new GeoDataScreenOverlayPrivate )
+GeoDataScreenOverlay::GeoDataScreenOverlay( const Marble::GeoDataScreenOverlay &other )
+ : GeoDataOverlay(other, new GeoDataScreenOverlayPrivate(*other.d_func()))
{
}
-GeoDataScreenOverlay::GeoDataScreenOverlay( const Marble::GeoDataScreenOverlay &other ) :
- GeoDataOverlay( other ), d( new GeoDataScreenOverlayPrivate( *other.d ) )
+GeoDataScreenOverlay::~GeoDataScreenOverlay()
{
}
GeoDataScreenOverlay &GeoDataScreenOverlay::operator=( const GeoDataScreenOverlay &other )
{
- *d = *other.d;
+ if (this != &other) {
+ Q_D(GeoDataScreenOverlay);
+ *d = *other.d_func();
+ }
+
return *this;
}
bool GeoDataScreenOverlay::operator==(const GeoDataScreenOverlay& other) const
{
+ Q_D(const GeoDataScreenOverlay);
+ const GeoDataScreenOverlayPrivate* const other_d = other.d_func();
+
return equals(other) &&
- d->m_overlayXY == other.d->m_overlayXY &&
- d->m_screenXY == other.d->m_screenXY &&
- d->m_rotationXY == other.d->m_rotationXY &&
- d->m_size == other.d->m_size &&
- d->m_rotation == other.d->m_rotation;
+ d->m_overlayXY == other_d->m_overlayXY &&
+ d->m_screenXY == other_d->m_screenXY &&
+ d->m_rotationXY == other_d->m_rotationXY &&
+ d->m_size == other_d->m_size &&
+ d->m_rotation == other_d->m_rotation;
}
bool GeoDataScreenOverlay::operator!=(const GeoDataScreenOverlay& other) const
@@ -61,9 +56,9 @@ bool GeoDataScreenOverlay::operator!=(const GeoDataScreenOverlay& other) const
return !this->operator==(other);
}
-GeoDataScreenOverlay::~GeoDataScreenOverlay()
+GeoDataFeature * GeoDataScreenOverlay::clone() const
{
- delete d;
+ return new GeoDataScreenOverlay(*this);
}
const char *GeoDataScreenOverlay::nodeType() const
@@ -73,16 +68,19 @@ const char *GeoDataScreenOverlay::nodeType() const
GeoDataVec2 GeoDataScreenOverlay::overlayXY() const
{
+ Q_D(const GeoDataScreenOverlay);
return d->m_overlayXY;
}
void GeoDataScreenOverlay::setOverlayXY(const GeoDataVec2 &vec2)
{
+ Q_D(GeoDataScreenOverlay);
d->m_overlayXY = vec2;
}
void GeoDataScreenOverlay::setOverlayXY(qreal x, qreal y, GeoDataVec2::Unit xunit, GeoDataVec2::Unit yunit)
{
+ Q_D(GeoDataScreenOverlay);
d->m_screenXY.setX(x);
d->m_screenXY.setY(y);
d->m_screenXY.setXunits(xunit);
@@ -91,16 +89,19 @@ void GeoDataScreenOverlay::setOverlayXY(qreal x, qreal y, GeoDataVec2::Unit xuni
GeoDataVec2 GeoDataScreenOverlay::screenXY() const
{
+ Q_D(const GeoDataScreenOverlay);
return d->m_screenXY;
}
void GeoDataScreenOverlay::setScreenXY(const GeoDataVec2 &vec2)
{
+ Q_D(GeoDataScreenOverlay);
d->m_screenXY = vec2;
}
void GeoDataScreenOverlay::setScreenXY(qreal x, qreal y, GeoDataVec2::Unit xunit, GeoDataVec2::Unit yunit)
{
+ Q_D(GeoDataScreenOverlay);
d->m_screenXY.setX(x);
d->m_screenXY.setY(y);
d->m_screenXY.setXunits(xunit);
@@ -109,16 +110,19 @@ void GeoDataScreenOverlay::setScreenXY(qreal x, qreal y, GeoDataVec2::Unit xunit
GeoDataVec2 GeoDataScreenOverlay::rotationXY() const
{
+ Q_D(const GeoDataScreenOverlay);
return d->m_rotationXY;
}
void GeoDataScreenOverlay::setRotationXY(const GeoDataVec2 &vec2)
{
+ Q_D(GeoDataScreenOverlay);
d->m_rotationXY = vec2;
}
void GeoDataScreenOverlay::setRotationXY(qreal x, qreal y, GeoDataVec2::Unit xunit, GeoDataVec2::Unit yunit)
{
+ Q_D(GeoDataScreenOverlay);
d->m_rotationXY.setX(x);
d->m_rotationXY.setY(y);
d->m_rotationXY.setXunits(xunit);
@@ -127,16 +131,19 @@ void GeoDataScreenOverlay::setRotationXY(qreal x, qreal y, GeoDataVec2::Unit xun
GeoDataVec2 GeoDataScreenOverlay::size() const
{
+ Q_D(const GeoDataScreenOverlay);
return d->m_size;
}
void GeoDataScreenOverlay::setSize(const GeoDataVec2 &vec2)
{
+ Q_D(GeoDataScreenOverlay);
d->m_size = vec2;
}
void GeoDataScreenOverlay::setSize(qreal x, qreal y, GeoDataVec2::Unit xunit, GeoDataVec2::Unit yunit)
{
+ Q_D(GeoDataScreenOverlay);
d->m_size.setX(x);
d->m_size.setY(y);
d->m_size.setXunits(xunit);
@@ -145,11 +152,13 @@ void GeoDataScreenOverlay::setSize(qreal x, qreal y, GeoDataVec2::Unit xunit, Ge
qreal GeoDataScreenOverlay::rotation() const
{
+ Q_D(const GeoDataScreenOverlay);
return d->m_rotation;
}
void GeoDataScreenOverlay::setRotation(qreal rotation)
{
+ Q_D(GeoDataScreenOverlay);
d->m_rotation = rotation;
}
diff --git a/src/lib/marble/geodata/data/GeoDataScreenOverlay.h b/src/lib/marble/geodata/data/GeoDataScreenOverlay.h
index 85e80b6..7f31a69 100644
--- a/src/lib/marble/geodata/data/GeoDataScreenOverlay.h
+++ b/src/lib/marble/geodata/data/GeoDataScreenOverlay.h
@@ -28,10 +28,13 @@ public:
GeoDataScreenOverlay( const GeoDataScreenOverlay &other );
+ ~GeoDataScreenOverlay();
+
GeoDataScreenOverlay& operator=( const GeoDataScreenOverlay &other );
bool operator==( const GeoDataScreenOverlay &other ) const;
bool operator!=( const GeoDataScreenOverlay &other ) const;
- ~GeoDataScreenOverlay();
+
+ GeoDataFeature * clone() const override;
/** Provides type information for downcasting a GeoNode */
virtual const char* nodeType() const;
@@ -56,7 +59,7 @@ public:
void setRotation( qreal rotation );
private:
- GeoDataScreenOverlayPrivate* const d;
+ Q_DECLARE_PRIVATE(GeoDataScreenOverlay)
};
}
diff --git a/src/lib/marble/geodata/data/GeoDataScreenOverlay_p.h b/src/lib/marble/geodata/data/GeoDataScreenOverlay_p.h
new file mode 100644
index 0000000..85cfb39
--- /dev/null
+++ b/src/lib/marble/geodata/data/GeoDataScreenOverlay_p.h
@@ -0,0 +1,37 @@
+//
+// This file is part of the Marble Virtual Globe->
+//
+// This program is free software licensed under the GNU LGPL-> You can
+// find a copy of this license in LICENSE->txt in the top directory of
+// the source code->
+//
+// Copyright 2012 Mohammed Nafees <nafees.technocool@gmail.com>
+//
+
+#ifndef GEODATASCREENOVERLAY_P_H
+#define GEODATASCREENOVERLAY_P_H
+
+#include "GeoDataOverlay_p.h"
+
+namespace Marble {
+
+class GeoDataScreenOverlayPrivate : public GeoDataOverlayPrivate
+{
+public:
+ GeoDataScreenOverlayPrivate();
+
+ GeoDataVec2 m_overlayXY;
+ GeoDataVec2 m_screenXY;
+ GeoDataVec2 m_rotationXY;
+ GeoDataVec2 m_size;
+ qreal m_rotation;
+};
+
+GeoDataScreenOverlayPrivate::GeoDataScreenOverlayPrivate() :
+ m_rotation(0.0)
+{
+}
+
+}
+
+#endif
diff --git a/src/lib/marble/geodata/data/GeoDataTour.cpp b/src/lib/marble/geodata/data/GeoDataTour.cpp
index 947ae85..a160387 100644
--- a/src/lib/marble/geodata/data/GeoDataTour.cpp
+++ b/src/lib/marble/geodata/data/GeoDataTour.cpp
@@ -23,11 +23,27 @@ GeoDataTour::GeoDataTour()
// nothing to do
}
+GeoDataTour::GeoDataTour(const GeoDataTour& other)
+ : GeoDataFeature(other, new GeoDataTourPrivate(*other.d_func()))
+{
+}
+
GeoDataTour::~GeoDataTour()
{
// nothing to do;
}
+GeoDataTour& GeoDataTour::operator=(const GeoDataTour& other)
+{
+ if (this != &other) {
+ Q_D(GeoDataTour);
+ *d = *other.d_func();
+ }
+
+ return *this;
+}
+
+
bool GeoDataTour::operator==(const GeoDataTour& other) const
{
Q_D(const GeoDataTour);
@@ -40,10 +56,14 @@ bool GeoDataTour::operator!=(const GeoDataTour& other) const
return !this->operator==(other);
}
-GeoDataPlaylist* GeoDataTour::playlist()
+GeoDataFeature * GeoDataTour::clone() const
{
- detach();
+ return new GeoDataTour(*this);
+}
+
+GeoDataPlaylist* GeoDataTour::playlist()
+{
Q_D(GeoDataTour);
return d->m_playlist;
}
@@ -56,8 +76,6 @@ const GeoDataPlaylist* GeoDataTour::playlist() const
void GeoDataTour::setPlaylist(GeoDataPlaylist *playlist)
{
- detach();
-
Q_D(GeoDataTour);
d->m_playlist = playlist;
d->m_playlist->setParent(this);
diff --git a/src/lib/marble/geodata/data/GeoDataTour.h b/src/lib/marble/geodata/data/GeoDataTour.h
index 3196ad8..e957b21 100644
--- a/src/lib/marble/geodata/data/GeoDataTour.h
+++ b/src/lib/marble/geodata/data/GeoDataTour.h
@@ -27,11 +27,16 @@ class GEODATA_EXPORT GeoDataTour : public GeoDataFeature
{
public:
GeoDataTour();
+ GeoDataTour(const GeoDataTour& other);
virtual ~GeoDataTour();
+ GeoDataTour& operator=(const GeoDataTour& other);
+
bool operator==(const GeoDataTour &other) const;
bool operator!=(const GeoDataTour &other) const;
+ GeoDataFeature * clone() const override;
+
GeoDataPlaylist* playlist();
const GeoDataPlaylist* playlist() const;
void setPlaylist(GeoDataPlaylist* playlist);
diff --git a/src/lib/marble/geodata/data/GeoDataTour_p.h b/src/lib/marble/geodata/data/GeoDataTour_p.h
index 577bfff..3af9b2d 100644
--- a/src/lib/marble/geodata/data/GeoDataTour_p.h
+++ b/src/lib/marble/geodata/data/GeoDataTour_p.h
@@ -28,6 +28,14 @@ public:
{
// nothing to do
}
+ GeoDataTourPrivate(const GeoDataTourPrivate &other)
+ : GeoDataFeaturePrivate(other),
+ m_playlist(nullptr)
+ {
+ if (other.m_playlist) {
+ m_playlist = new GeoDataPlaylist(*other.m_playlist);
+ }
+ }
virtual ~GeoDataTourPrivate()
{
@@ -52,13 +60,6 @@ public:
return *this;
}
- virtual GeoDataTourPrivate* copy()
- {
- GeoDataTourPrivate *copy = new GeoDataTourPrivate;
- *copy = *this;
- return copy;
- }
-
virtual const char *nodeType() const
{
return GeoDataTypes::GeoDataTourType;
diff --git a/tests/TestGeoDataCopy.cpp b/tests/TestGeoDataCopy.cpp
index 2e6e130..9c51d6f 100644
--- a/tests/TestGeoDataCopy.cpp
+++ b/tests/TestGeoDataCopy.cpp
@@ -369,11 +369,8 @@ void TestGeoDataCopy::copyFolder()
GeoDataFolder other = folder;
QCOMPARE(other.size(), 3);
- QEXPECT_FAIL("", "FIXME", Continue);
QCOMPARE(other.child(0)->parent(), &other);
- QEXPECT_FAIL("", "FIXME", Continue);
QCOMPARE(other.child(1)->parent(), &other);
- QEXPECT_FAIL("", "FIXME", Continue);
QCOMPARE(other.child(2)->parent(), &other);
QCOMPARE(static_cast<GeoDataPlacemark*>(other.child(0))->coordinate(), coord1);
QCOMPARE(static_cast<GeoDataPlacemark*>(other.child(1))->coordinate(), coord2);
@@ -486,9 +483,7 @@ void TestGeoDataCopy::copyPlacemark()
const GeoDataPlacemark other2(other);
QCOMPARE(placemark.geometry()->parent(), &placemark);
- QEXPECT_FAIL("", "geometry needs to be detach()ed", Continue);
QCOMPARE(other.geometry()->parent(), &other);
- QEXPECT_FAIL("", "geometry needs to be detach()ed", Continue);
QCOMPARE(other2.geometry()->parent(), &other2);
}