summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedrich W. H. Kossebau <kossebau@kde.org>2016-10-07 05:14:38 (GMT)
committerFriedrich W. H. Kossebau <kossebau@kde.org>2016-10-07 05:14:38 (GMT)
commitc85227a4ccda5f7a6595102f67cf73de0e6791b1 (patch)
tree64fdb91c3b1538a4a254ab50c14e1250d3129bfe
parentcafdd1e7322b96af4f155a6e1d433bdd2a44de8c (diff)
Qt'fy access to pimpl objects for GeoDataFeature & subclasses
-rw-r--r--src/lib/marble/geodata/data/GeoDataContainer.cpp147
-rw-r--r--src/lib/marble/geodata/data/GeoDataContainer.h3
-rw-r--r--src/lib/marble/geodata/data/GeoDataDocument.cpp153
-rw-r--r--src/lib/marble/geodata/data/GeoDataDocument.h3
-rw-r--r--src/lib/marble/geodata/data/GeoDataFeature.cpp177
-rw-r--r--src/lib/marble/geodata/data/GeoDataFeature.h10
-rw-r--r--src/lib/marble/geodata/data/GeoDataFeature_p.h9
-rw-r--r--src/lib/marble/geodata/data/GeoDataFolder.cpp5
-rw-r--r--src/lib/marble/geodata/data/GeoDataFolder.h2
-rw-r--r--src/lib/marble/geodata/data/GeoDataPlacemark.cpp241
-rw-r--r--src/lib/marble/geodata/data/GeoDataPlacemark.h3
-rw-r--r--src/lib/marble/geodata/data/GeoDataPlacemark_p.h1
-rw-r--r--src/lib/marble/geodata/data/GeoDataTour.cpp26
-rw-r--r--src/lib/marble/geodata/data/GeoDataTour.h3
14 files changed, 478 insertions, 305 deletions
diff --git a/src/lib/marble/geodata/data/GeoDataContainer.cpp b/src/lib/marble/geodata/data/GeoDataContainer.cpp
index bb0b3c8..8c2c207 100644
--- a/src/lib/marble/geodata/data/GeoDataContainer.cpp
+++ b/src/lib/marble/geodata/data/GeoDataContainer.cpp
@@ -53,26 +53,18 @@ GeoDataContainer::~GeoDataContainer()
{
}
-GeoDataContainerPrivate* GeoDataContainer::p()
-{
- return static_cast<GeoDataContainerPrivate*>(d);
-}
-
-const GeoDataContainerPrivate* GeoDataContainer::p() const
-{
- return static_cast<GeoDataContainerPrivate*>(d);
-}
-
bool GeoDataContainer::equals( const GeoDataContainer &other ) const
{
if ( !GeoDataFeature::equals(other) ) {
return false;
}
- QVector<GeoDataFeature*>::const_iterator thisBegin = p()->m_vector.constBegin();
- QVector<GeoDataFeature*>::const_iterator thisEnd = p()->m_vector.constEnd();
- QVector<GeoDataFeature*>::const_iterator otherBegin = other.p()->m_vector.constBegin();
- QVector<GeoDataFeature*>::const_iterator otherEnd = other.p()->m_vector.constEnd();
+ Q_D(const GeoDataContainer);
+ const GeoDataContainerPrivate* const other_d = other.d_func();
+ QVector<GeoDataFeature*>::const_iterator thisBegin = d->m_vector.constBegin();
+ QVector<GeoDataFeature*>::const_iterator thisEnd = d->m_vector.constEnd();
+ QVector<GeoDataFeature*>::const_iterator otherBegin = other_d->m_vector.constBegin();
+ QVector<GeoDataFeature*>::const_iterator otherEnd = other_d->m_vector.constEnd();
for (; thisBegin != thisEnd && otherBegin != otherEnd; ++thisBegin, ++otherBegin) {
if ( (*thisBegin)->nodeType() != (*otherBegin)->nodeType() ) {
@@ -159,10 +151,11 @@ bool GeoDataContainer::equals( const GeoDataContainer &other ) const
GeoDataLatLonAltBox GeoDataContainer::latLonAltBox() const
{
+ Q_D(const GeoDataContainer);
GeoDataLatLonAltBox result;
- QVector<GeoDataFeature*>::const_iterator it = p()->m_vector.constBegin();
- QVector<GeoDataFeature*>::const_iterator end = p()->m_vector.constEnd();
+ QVector<GeoDataFeature*>::const_iterator it = d->m_vector.constBegin();
+ QVector<GeoDataFeature*>::const_iterator end = d->m_vector.constEnd();
for (; it != end; ++it) {
// Get all the placemarks from GeoDataContainer
@@ -196,10 +189,11 @@ GeoDataLatLonAltBox GeoDataContainer::latLonAltBox() const
QVector<GeoDataFolder*> GeoDataContainer::folderList() const
{
+ Q_D(const GeoDataContainer);
QVector<GeoDataFolder*> results;
- QVector<GeoDataFeature*>::const_iterator it = p()->m_vector.constBegin();
- QVector<GeoDataFeature*>::const_iterator end = p()->m_vector.constEnd();
+ QVector<GeoDataFeature*>::const_iterator it = d->m_vector.constBegin();
+ QVector<GeoDataFeature*>::const_iterator end = d->m_vector.constEnd();
for (; it != end; ++it) {
GeoDataFolder *folder = dynamic_cast<GeoDataFolder*>(*it);
@@ -213,8 +207,9 @@ QVector<GeoDataFolder*> GeoDataContainer::folderList() const
QVector<GeoDataPlacemark*> GeoDataContainer::placemarkList() const
{
+ Q_D(const GeoDataContainer);
QVector<GeoDataPlacemark*> results;
- for (auto it=p()->m_vector.constBegin(), end = p()->m_vector.constEnd(); it != end; ++it) {
+ for (auto it = d->m_vector.constBegin(), end = d->m_vector.constEnd(); it != end; ++it) {
if ((*it)->nodeType() == GeoDataTypes::GeoDataPlacemarkType) {
results.append(static_cast<GeoDataPlacemark*>(*it));
}
@@ -224,7 +219,8 @@ QVector<GeoDataPlacemark*> GeoDataContainer::placemarkList() const
QVector<GeoDataFeature*> GeoDataContainer::featureList() const
{
- return p()->m_vector;
+ Q_D(const GeoDataContainer);
+ return d->m_vector;
}
/**
@@ -233,12 +229,15 @@ QVector<GeoDataFeature*> GeoDataContainer::featureList() const
GeoDataFeature* GeoDataContainer::child( int i )
{
detach();
- return p()->m_vector.at(i);
+
+ Q_D(GeoDataContainer);
+ return d->m_vector.at(i);
}
const GeoDataFeature* GeoDataContainer::child( int i ) const
{
- return p()->m_vector.at(i);
+ Q_D(const GeoDataContainer);
+ return d->m_vector.at(i);
}
/**
@@ -246,10 +245,9 @@ const GeoDataFeature* GeoDataContainer::child( int i ) const
*/
int GeoDataContainer::childPosition( const GeoDataFeature* object ) const
{
- for ( int i=0; i< p()->m_vector.size(); i++ )
- {
- if ( p()->m_vector.at( i ) == object )
- {
+ Q_D(const GeoDataContainer);
+ for (int i = 0; i < d->m_vector.size(); ++i) {
+ if (d->m_vector.at(i) == object) {
return i;
}
}
@@ -265,39 +263,49 @@ void GeoDataContainer::insert( GeoDataFeature *other, int index )
void GeoDataContainer::insert( int index, GeoDataFeature *feature )
{
detach();
+
+ Q_D(GeoDataContainer);
feature->setParent(this);
- p()->m_vector.insert( index, feature );
+ d->m_vector.insert( index, feature );
}
void GeoDataContainer::append( GeoDataFeature *other )
{
detach();
+
+ Q_D(GeoDataContainer);
other->setParent(this);
- p()->m_vector.append( other );
+ d->m_vector.append( other );
}
void GeoDataContainer::remove( int index )
{
detach();
- p()->m_vector.remove( index );
+
+ Q_D(GeoDataContainer);
+ d->m_vector.remove( index );
}
void GeoDataContainer::remove(int index, int count)
{
detach();
- p()->m_vector.remove( index, count );
+
+ Q_D(GeoDataContainer);
+ d->m_vector.remove( index, count );
}
int GeoDataContainer::removeAll(GeoDataFeature *feature)
{
detach();
+
+ Q_D(GeoDataContainer);
#if QT_VERSION >= 0x050400
- return p()->m_vector.removeAll(feature);
+ return d->m_vector.removeAll(feature);
#else
int count = 0;
- QVector<GeoDataFeature*> &vector = p()->m_vector;
+ QVector<GeoDataFeature*> &vector = d->m_vector;
QVector<GeoDataFeature*>::iterator it = vector.begin();
while(it != vector.end()) {
@@ -316,28 +324,36 @@ int GeoDataContainer::removeAll(GeoDataFeature *feature)
void GeoDataContainer::removeAt(int index)
{
detach();
- p()->m_vector.removeAt( index );
+
+ Q_D(GeoDataContainer);
+ d->m_vector.removeAt( index );
}
void GeoDataContainer::removeFirst()
{
detach();
- p()->m_vector.removeFirst();
+
+ Q_D(GeoDataContainer);
+ d->m_vector.removeFirst();
}
void GeoDataContainer::removeLast()
{
detach();
- p()->m_vector.removeLast();
+
+ Q_D(GeoDataContainer);
+ d->m_vector.removeLast();
}
bool GeoDataContainer::removeOne( GeoDataFeature *feature )
{
detach();
+
+ Q_D(GeoDataContainer);
#if QT_VERSION >= 0x050400
- return p()->m_vector.removeOne( feature );
+ return d->m_vector.removeOne( feature );
#else
- QVector<GeoDataFeature*> &vector = p()->m_vector;
+ QVector<GeoDataFeature*> &vector = d->m_vector;
const int i = vector.indexOf(feature);
if (i < 0) {
@@ -352,79 +368,98 @@ bool GeoDataContainer::removeOne( GeoDataFeature *feature )
int GeoDataContainer::size() const
{
- return p()->m_vector.size();
+ Q_D(const GeoDataContainer);
+ return d->m_vector.size();
}
GeoDataFeature& GeoDataContainer::at( int pos )
{
detach();
- return *(p()->m_vector[ pos ]);
+
+ Q_D(GeoDataContainer);
+ return *(d->m_vector[pos]);
}
const GeoDataFeature& GeoDataContainer::at( int pos ) const
{
- return *(p()->m_vector.at( pos ));
+ Q_D(const GeoDataContainer);
+ return *(d->m_vector.at(pos));
}
GeoDataFeature& GeoDataContainer::last()
{
detach();
- return *(p()->m_vector.last());
+
+ Q_D(GeoDataContainer);
+ return *(d->m_vector.last());
}
const GeoDataFeature& GeoDataContainer::last() const
{
- return *(p()->m_vector.last());
+ Q_D(const GeoDataContainer);
+ return *(d->m_vector.last());
}
GeoDataFeature& GeoDataContainer::first()
{
detach();
- return *(p()->m_vector.first());
+
+ Q_D(GeoDataContainer);
+ return *(d->m_vector.first());
}
const GeoDataFeature& GeoDataContainer::first() const
{
- return *(p()->m_vector.first());
+ Q_D(const GeoDataContainer);
+ return *(d->m_vector.first());
}
void GeoDataContainer::clear()
{
GeoDataContainer::detach();
- qDeleteAll(p()->m_vector);
- p()->m_vector.clear();
+
+ Q_D(GeoDataContainer);
+ qDeleteAll(d->m_vector);
+ d->m_vector.clear();
}
QVector<GeoDataFeature*>::Iterator GeoDataContainer::begin()
{
detach();
- return p()->m_vector.begin();
+
+ Q_D(GeoDataContainer);
+ return d->m_vector.begin();
}
QVector<GeoDataFeature*>::Iterator GeoDataContainer::end()
{
detach();
- return p()->m_vector.end();
+
+ Q_D(GeoDataContainer);
+ return d->m_vector.end();
}
QVector<GeoDataFeature*>::ConstIterator GeoDataContainer::constBegin() const
{
- return p()->m_vector.constBegin();
+ Q_D(const GeoDataContainer);
+ return d->m_vector.constBegin();
}
QVector<GeoDataFeature*>::ConstIterator GeoDataContainer::constEnd() const
{
- return p()->m_vector.constEnd();
+ Q_D(const GeoDataContainer);
+ return d->m_vector.constEnd();
}
void GeoDataContainer::pack( QDataStream& stream ) const
{
+ Q_D(const GeoDataContainer);
GeoDataFeature::pack( stream );
- stream << p()->m_vector.count();
+ stream << d->m_vector.count();
- for ( QVector <GeoDataFeature*>::const_iterator iterator = p()->m_vector.constBegin();
- iterator != p()->m_vector.constEnd();
+ for (QVector<GeoDataFeature*>::const_iterator iterator = d->m_vector.constBegin();
+ iterator != d->m_vector.constEnd();
++iterator )
{
const GeoDataFeature *feature = *iterator;
@@ -436,6 +471,8 @@ void GeoDataContainer::pack( QDataStream& stream ) const
void GeoDataContainer::unpack( QDataStream& stream )
{
detach();
+
+ Q_D(GeoDataContainer);
GeoDataFeature::unpack( stream );
int count;
@@ -451,14 +488,14 @@ void GeoDataContainer::unpack( QDataStream& stream )
{
GeoDataFolder *folder = new GeoDataFolder;
folder->unpack( stream );
- p()->m_vector.append( folder );
+ d->m_vector.append( folder );
}
break;
case GeoDataPlacemarkId:
{
GeoDataPlacemark *placemark = new GeoDataPlacemark;
placemark->unpack( stream );
- p()->m_vector.append( placemark );
+ d->m_vector.append( placemark );
}
break;
case GeoDataNetworkLinkId:
diff --git a/src/lib/marble/geodata/data/GeoDataContainer.h b/src/lib/marble/geodata/data/GeoDataContainer.h
index 81a4485..e03cb43 100644
--- a/src/lib/marble/geodata/data/GeoDataContainer.h
+++ b/src/lib/marble/geodata/data/GeoDataContainer.h
@@ -174,8 +174,7 @@ class GEODATA_EXPORT GeoDataContainer : public GeoDataFeature
using GeoDataFeature::equals;
private:
- GeoDataContainerPrivate* p();
- const GeoDataContainerPrivate* p() const;
+ Q_DECLARE_PRIVATE(GeoDataContainer)
};
}
diff --git a/src/lib/marble/geodata/data/GeoDataDocument.cpp b/src/lib/marble/geodata/data/GeoDataDocument.cpp
index 09570cc..a6f9035 100644
--- a/src/lib/marble/geodata/data/GeoDataDocument.cpp
+++ b/src/lib/marble/geodata/data/GeoDataDocument.cpp
@@ -51,41 +51,33 @@ GeoDataDocument::~GeoDataDocument()
{
}
-GeoDataDocumentPrivate* GeoDataDocument::p()
-{
- return static_cast<GeoDataDocumentPrivate*>(d);
-}
-
-const GeoDataDocumentPrivate* GeoDataDocument::p() const
-{
- return static_cast<GeoDataDocumentPrivate*>(d);
-}
-
bool GeoDataDocument::operator==( const GeoDataDocument &other ) const
{
if (!GeoDataContainer::equals(other)) {
return false;
}
- if (!(p()->m_styleHash.size() == other.p()->m_styleHash.size() &&
- p()->m_styleMapHash == other.p()->m_styleMapHash &&
- p()->m_schemaHash == other.p()->m_schemaHash &&
- p()->m_filename == other.p()->m_filename &&
- p()->m_baseUri == other.p()->m_baseUri &&
- p()->m_networkLinkControl == other.p()->m_networkLinkControl &&
- p()->m_property == other.p()->m_property &&
- p()->m_documentRole == other.p()->m_documentRole)) {
+ Q_D(const GeoDataDocument);
+ const GeoDataDocumentPrivate* const other_d = other.d_func();
+ if (!(d->m_styleHash.size() == other_d->m_styleHash.size() &&
+ d->m_styleMapHash == other_d->m_styleMapHash &&
+ d->m_schemaHash == other_d->m_schemaHash &&
+ d->m_filename == other_d->m_filename &&
+ d->m_baseUri == other_d->m_baseUri &&
+ d->m_networkLinkControl == other_d->m_networkLinkControl &&
+ d->m_property == other_d->m_property &&
+ d->m_documentRole == other_d->m_documentRole)) {
return false;
}
- auto iter = p()->m_styleHash.constBegin();
- auto const end = p()->m_styleHash.constEnd();
+ auto iter = d->m_styleHash.constBegin();
+ auto const end = d->m_styleHash.constEnd();
for (; iter != end; ++iter) {
- if (!other.p()->m_styleHash.contains(iter.key())) {
+ if (!other_d->m_styleHash.contains(iter.key())) {
return false;
}
- if (*iter.value() != *other.p()->m_styleHash[iter.key()]) {
+ if (*iter.value() != *other_d->m_styleHash[iter.key()]) {
return false;
}
}
@@ -100,88 +92,113 @@ bool GeoDataDocument::operator!=( const GeoDataDocument &other ) const
DocumentRole GeoDataDocument::documentRole() const
{
- return p()->m_documentRole;
+ Q_D(const GeoDataDocument);
+ return d->m_documentRole;
}
void GeoDataDocument::setDocumentRole( DocumentRole role )
{
- p()->m_documentRole = role;
+ detach();
+
+ Q_D(GeoDataDocument);
+ d->m_documentRole = role;
}
QString GeoDataDocument::property() const
{
- return p()->m_property;
+ Q_D(const GeoDataDocument);
+ return d->m_property;
}
void GeoDataDocument::setProperty( const QString& property )
{
- p()->m_property = property;
+ detach();
+
+ Q_D(GeoDataDocument);
+ d->m_property = property;
}
QString GeoDataDocument::fileName() const
{
- return p()->m_filename;
+ Q_D(const GeoDataDocument);
+ return d->m_filename;
}
void GeoDataDocument::setFileName( const QString &value )
{
detach();
- p()->m_filename = value;
+
+ Q_D(GeoDataDocument);
+ d->m_filename = value;
}
QString GeoDataDocument::baseUri() const
{
- return p()->m_baseUri;
+ Q_D(const GeoDataDocument);
+ return d->m_baseUri;
}
void GeoDataDocument::setBaseUri( const QString &baseUrl )
{
detach();
- p()->m_baseUri = baseUrl;
+
+ Q_D(GeoDataDocument);
+ d->m_baseUri = baseUrl;
}
GeoDataNetworkLinkControl GeoDataDocument::networkLinkControl() const
{
- return p()->m_networkLinkControl;
+ Q_D(const GeoDataDocument);
+ return d->m_networkLinkControl;
}
void GeoDataDocument::setNetworkLinkControl( const GeoDataNetworkLinkControl &networkLinkControl )
{
detach();
- p()->m_networkLinkControl = networkLinkControl;
+
+ Q_D(GeoDataDocument);
+ d->m_networkLinkControl = networkLinkControl;
}
void GeoDataDocument::addStyle( const GeoDataStyle::Ptr &style )
{
detach();
- p()->m_styleHash.insert( style->id(), style );
- p()->m_styleHash[ style->id() ]->setParent( this );
+
+ Q_D(GeoDataDocument);
+ d->m_styleHash.insert(style->id(), style);
+ d->m_styleHash[style->id()]->setParent(this);
}
void GeoDataDocument::removeStyle( const QString& styleId )
{
detach();
- p()->m_styleHash.remove( styleId );
+
+ 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
*/
- return p()->m_styleHash[ styleId ];
+ Q_D(GeoDataDocument);
+ return d->m_styleHash[styleId];
}
GeoDataStyle::ConstPtr GeoDataDocument::style( const QString &styleId ) const
{
- return p()->m_styleHash.value( styleId );
+ Q_D(const GeoDataDocument);
+ return d->m_styleHash.value(styleId);
}
QList<GeoDataStyle::ConstPtr> GeoDataDocument::styles() const
{
+ Q_D(const GeoDataDocument);
QList<GeoDataStyle::ConstPtr> result;
- foreach(auto const & style, p()->m_styleHash.values()) {
+ foreach(auto const & style, d->m_styleHash.values()) {
result << style;
}
@@ -191,76 +208,96 @@ QList<GeoDataStyle::ConstPtr> GeoDataDocument::styles() const
QList<GeoDataStyle::Ptr> GeoDataDocument::styles()
{
detach();
- return p()->m_styleHash.values();
+
+ Q_D(GeoDataDocument);
+ return d->m_styleHash.values();
}
void GeoDataDocument::addStyleMap( const GeoDataStyleMap& map )
{
detach();
- p()->m_styleMapHash.insert( map.id(), map );
- p()->m_styleMapHash[ map.id() ].setParent( this );
+
+ Q_D(GeoDataDocument);
+ d->m_styleMapHash.insert(map.id(), map);
+ d->m_styleMapHash[map.id()].setParent(this);
}
void GeoDataDocument::removeStyleMap( const QString& mapId )
{
detach();
- p()->m_styleMapHash.remove( mapId );
+
+ Q_D(GeoDataDocument);
+ d->m_styleMapHash.remove(mapId);
}
GeoDataStyleMap& GeoDataDocument::styleMap( const QString& styleId )
{
- return p()->m_styleMapHash[ styleId ];
+ detach();
+
+ Q_D(GeoDataDocument);
+ return d->m_styleMapHash[styleId];
}
GeoDataStyleMap GeoDataDocument::styleMap( const QString &styleId ) const
{
- return p()->m_styleMapHash.value( styleId );
+ Q_D(const GeoDataDocument);
+ return d->m_styleMapHash.value(styleId);
}
QList<GeoDataStyleMap> GeoDataDocument::styleMaps() const
{
- return p()->m_styleMapHash.values();
+ Q_D(const GeoDataDocument);
+ return d->m_styleMapHash.values();
}
void GeoDataDocument::addSchema( const GeoDataSchema& schema )
{
detach();
- p()->m_schemaHash.insert( schema.id(), schema );
- p()->m_schemaHash[ schema.id() ].setParent( this );
+
+ Q_D(GeoDataDocument);
+ d->m_schemaHash.insert(schema.id(), schema);
+ d->m_schemaHash[schema.id()].setParent(this);
}
void GeoDataDocument::removeSchema( const QString& schemaId )
{
detach();
- GeoDataSchema schema = p()->m_schemaHash.take( schemaId );
+
+ Q_D(GeoDataDocument);
+ GeoDataSchema schema = d->m_schemaHash.take(schemaId);
schema.setParent( 0 );
}
GeoDataSchema GeoDataDocument::schema( const QString& schemaId ) const
{
- return p()->m_schemaHash.value( schemaId );
+ Q_D(const GeoDataDocument);
+ return d->m_schemaHash.value(schemaId);
}
GeoDataSchema &GeoDataDocument::schema( const QString &schemaId )
{
- return p()->m_schemaHash[ schemaId ];
+ detach();
+
+ Q_D(GeoDataDocument);
+ return d->m_schemaHash[schemaId];
}
QList<GeoDataSchema> GeoDataDocument::schemas() const
{
- return p()->m_schemaHash.values();
+ Q_D(const GeoDataDocument);
+ return d->m_schemaHash.values();
}
void GeoDataDocument::pack( QDataStream& stream ) const
{
+ Q_D(const GeoDataDocument);
GeoDataContainer::pack( stream );
- stream << p()->m_styleHash.size();
-
-
+ stream << d->m_styleHash.size();
+
for( QMap<QString, GeoDataStyle::Ptr>::const_iterator iterator
- = p()->m_styleHash.constBegin();
- iterator != p()->m_styleHash.constEnd();
+ = d->m_styleHash.constBegin();
+ iterator != d->m_styleHash.constEnd();
++iterator ) {
iterator.value()->pack( stream );
}
@@ -270,6 +307,8 @@ void GeoDataDocument::pack( QDataStream& stream ) const
void GeoDataDocument::unpack( QDataStream& stream )
{
detach();
+
+ Q_D(GeoDataDocument);
GeoDataContainer::unpack( stream );
int size = 0;
@@ -278,7 +317,7 @@ void GeoDataDocument::unpack( QDataStream& stream )
for( int i = 0; i < size; i++ ) {
GeoDataStyle::Ptr style;
style->unpack( stream );
- p()->m_styleHash.insert( style->id(), style );
+ d->m_styleHash.insert(style->id(), style);
}
}
diff --git a/src/lib/marble/geodata/data/GeoDataDocument.h b/src/lib/marble/geodata/data/GeoDataDocument.h
index 374f9bb..3229496 100644
--- a/src/lib/marble/geodata/data/GeoDataDocument.h
+++ b/src/lib/marble/geodata/data/GeoDataDocument.h
@@ -196,8 +196,7 @@ public:
virtual void unpack( QDataStream& stream );
private:
- GeoDataDocumentPrivate *p();
- const GeoDataDocumentPrivate *p() const;
+ Q_DECLARE_PRIVATE(GeoDataDocument)
};
}
diff --git a/src/lib/marble/geodata/data/GeoDataFeature.cpp b/src/lib/marble/geodata/data/GeoDataFeature.cpp
index c71da23..955bd2d 100644
--- a/src/lib/marble/geodata/data/GeoDataFeature.cpp
+++ b/src/lib/marble/geodata/data/GeoDataFeature.cpp
@@ -35,86 +35,84 @@ namespace Marble
const QSharedPointer<const GeoDataStyle> GeoDataFeaturePrivate::s_defaultStyle(new GeoDataStyle);
GeoDataFeature::GeoDataFeature()
- : d( new GeoDataFeaturePrivate() )
+ : d_ptr(new GeoDataFeaturePrivate())
{
- d->ref.ref();
+ d_ptr->ref.ref();
}
GeoDataFeature::GeoDataFeature( const GeoDataFeature& other )
: GeoDataObject(),
- d( other.d )
+ d_ptr( other.d_ptr )
{
- d->ref.ref();
+ d_ptr->ref.ref();
}
GeoDataFeature::GeoDataFeature( const QString& name )
- : d( new GeoDataFeaturePrivate() )
+ : d_ptr(new GeoDataFeaturePrivate())
{
- d->ref.ref();
- d->m_name = name;
+ d_ptr->ref.ref();
+ d_ptr->m_name = name;
}
-GeoDataFeature::GeoDataFeature( GeoDataFeaturePrivate *priv )
- : d( priv )
+GeoDataFeature::GeoDataFeature(GeoDataFeaturePrivate *dd)
+ : d_ptr(dd)
{
- d->ref.ref();
+ d_ptr->ref.ref();
}
GeoDataFeature::~GeoDataFeature()
{
- if (!d->ref.deref()) {
- delete d;
+ if (!d_ptr->ref.deref()) {
+ delete d_ptr;
}
}
-GeoDataFeaturePrivate* GeoDataFeature::p() const
-{
- return static_cast<GeoDataFeaturePrivate*>(d);
-}
-
GeoDataFeature& GeoDataFeature::operator=( const GeoDataFeature& other )
{
- if (!d->ref.deref()) {
- delete d;
+ if (!d_ptr->ref.deref()) {
+ delete d_ptr;
}
- d = other.d;
- d->ref.ref();
+ d_ptr = other.d_ptr;
+ d_ptr->ref.ref();
return *this;
}
bool GeoDataFeature::equals( const GeoDataFeature &other ) const
{
- if ( !GeoDataObject::equals(other) ||
- d->m_name != other.d->m_name ||
- d->m_styleUrl != other.d->m_styleUrl ||
- d->m_popularity != other.d->m_popularity ||
- d->m_zoomLevel != other.d->m_zoomLevel ||
- d->m_visible != other.d->m_visible ||
- d->m_role != other.d->m_role ||
- d->m_extendedData != other.d->m_extendedData ||
- *style() != *other.style() ) {
+ Q_D(const GeoDataFeature);
+ const GeoDataFeaturePrivate* const other_d = other.d_func();
+
+ if (!GeoDataObject::equals(other) ||
+ d->m_name != other_d->m_name ||
+ d->m_styleUrl != other_d->m_styleUrl ||
+ d->m_popularity != other_d->m_popularity ||
+ d->m_zoomLevel != other_d->m_zoomLevel ||
+ d->m_visible != other_d->m_visible ||
+ d->m_role != other_d->m_role ||
+ d->m_extendedData != other_d->m_extendedData ||
+ *style() != *other.style()) {
return false;
}
- if ( (!d->m_styleMap && other.d->m_styleMap) ||
- (d->m_styleMap && !other.d->m_styleMap) ) {
+ if ((!d->m_styleMap && other_d->m_styleMap) ||
+ (d->m_styleMap && !other_d->m_styleMap)) {
return false;
}
- if ( (d->m_styleMap && other.d->m_styleMap) &&
- (*d->m_styleMap != *other.d->m_styleMap) ) {
+ if ((d->m_styleMap && other_d->m_styleMap) &&
+ (*d->m_styleMap != *other_d->m_styleMap)) {
return false;
}
- if ( (!d->m_featureExtendedData && other.d->m_featureExtendedData && other.d->m_featureExtendedData->m_abstractView) ||
- (d->m_featureExtendedData && d->m_featureExtendedData->m_abstractView && !other.d->m_featureExtendedData) ) {
+ if ((!d->m_featureExtendedData && other_d->m_featureExtendedData && other_d->m_featureExtendedData->m_abstractView) ||
+ (d->m_featureExtendedData && d->m_featureExtendedData->m_abstractView && !other_d->m_featureExtendedData)) {
return false;
}
- if ( (d->m_featureExtendedData && other.d->m_featureExtendedData) &&
- (*d->m_featureExtendedData != *other.d->m_featureExtendedData) ) {
+ if ((d->m_featureExtendedData && other_d->m_featureExtendedData) &&
+ (*d->m_featureExtendedData != *other_d->m_featureExtendedData)) {
return false;
}
@@ -123,38 +121,47 @@ bool GeoDataFeature::equals( const GeoDataFeature &other ) const
const char* GeoDataFeature::nodeType() const
{
- return p()->nodeType();
+ Q_D(const GeoDataFeature);
+ return d->nodeType();
}
EnumFeatureId GeoDataFeature::featureId() const
{
+ Q_D(const GeoDataFeature);
return d->featureId();
}
QString GeoDataFeature::name() const
{
+ Q_D(const GeoDataFeature);
return d->m_name;
}
void GeoDataFeature::setName( const QString &value )
{
detach();
+
+ Q_D(GeoDataFeature);
d->m_name = value;
}
GeoDataSnippet GeoDataFeature::snippet() const
{
+ Q_D(const GeoDataFeature);
return d->featureExtendedData().m_snippet;
}
void GeoDataFeature::setSnippet( const GeoDataSnippet &snippet )
{
detach();
+
+ Q_D(GeoDataFeature);
d->featureExtendedData().m_snippet = snippet;
}
QString GeoDataFeature::address() const
{
+ Q_D(const GeoDataFeature);
if (!d->m_featureExtendedData) {
return QString();
}
@@ -164,16 +171,19 @@ QString GeoDataFeature::address() const
void GeoDataFeature::setAddress( const QString &value)
{
- if (value.isEmpty() && !d->m_featureExtendedData) {
+ if (value.isEmpty() && !d_func()->m_featureExtendedData) {
return; // nothing to change
}
detach();
+
+ Q_D(GeoDataFeature);
d->featureExtendedData().m_address = value;
}
QString GeoDataFeature::phoneNumber() const
{
+ Q_D(const GeoDataFeature);
if (!d->m_featureExtendedData) {
return QString();
}
@@ -183,16 +193,19 @@ QString GeoDataFeature::phoneNumber() const
void GeoDataFeature::setPhoneNumber( const QString &value)
{
- if (value.isEmpty() && !d->m_featureExtendedData) {
+ if (value.isEmpty() && !d_func()->m_featureExtendedData) {
return; // nothing to change
}
detach();
+
+ Q_D(GeoDataFeature);
d->featureExtendedData().m_phoneNumber = value;
}
QString GeoDataFeature::description() const
{
+ Q_D(const GeoDataFeature);
if (!d->m_featureExtendedData) {
return QString();
}
@@ -202,16 +215,19 @@ QString GeoDataFeature::description() const
void GeoDataFeature::setDescription( const QString &value)
{
- if (value.isEmpty() && !d->m_featureExtendedData) {
+ if (value.isEmpty() && !d_func()->m_featureExtendedData) {
return; // nothing to change
}
detach();
+
+ Q_D(GeoDataFeature);
d->featureExtendedData().m_description = value;
}
bool GeoDataFeature::descriptionIsCDATA() const
{
+ Q_D(const GeoDataFeature);
if (!d->m_featureExtendedData) {
return false;
}
@@ -222,11 +238,14 @@ bool GeoDataFeature::descriptionIsCDATA() const
void GeoDataFeature::setDescriptionCDATA( bool cdata )
{
detach();
+
+ Q_D(GeoDataFeature);
d->featureExtendedData().m_descriptionCDATA = cdata;
}
const GeoDataAbstractView* GeoDataFeature::abstractView() const
{
+ Q_D(const GeoDataFeature);
if (!d->m_featureExtendedData) {
return nullptr;
}
@@ -239,21 +258,26 @@ GeoDataAbstractView *GeoDataFeature::abstractView()
// FIXME: Calling detach() doesn't help at all because the m_abstractView
// object isn't actually copied in the Private class as well.
// detach();
+
+ Q_D(GeoDataFeature);
return d->featureExtendedData().m_abstractView;
}
void GeoDataFeature::setAbstractView( GeoDataAbstractView *abstractView )
{
- if (abstractView == nullptr && !d->m_featureExtendedData) {
+ if (abstractView == nullptr && !d_func()->m_featureExtendedData) {
return; // nothing to change
}
detach();
+
+ Q_D(GeoDataFeature);
d->featureExtendedData().m_abstractView = abstractView;
}
QString GeoDataFeature::styleUrl() const
{
+ Q_D(const GeoDataFeature);
return d->m_styleUrl;
}
@@ -261,6 +285,7 @@ void GeoDataFeature::setStyleUrl( const QString &value )
{
detach();
+ Q_D(GeoDataFeature);
d->m_styleUrl = value;
if ( value.isEmpty() ) {
@@ -292,17 +317,21 @@ void GeoDataFeature::setStyleUrl( const QString &value )
bool GeoDataFeature::isVisible() const
{
+ Q_D(const GeoDataFeature);
return d->m_visible;
}
void GeoDataFeature::setVisible( bool value )
{
detach();
+
+ Q_D(GeoDataFeature);
d->m_visible = value;
}
bool GeoDataFeature::isGloballyVisible() const
{
+ Q_D(const GeoDataFeature);
if ( parent() == 0 ) {
return d->m_visible;
}
@@ -313,45 +342,57 @@ bool GeoDataFeature::isGloballyVisible() const
const GeoDataTimeSpan &GeoDataFeature::timeSpan() const
{
+ Q_D(const GeoDataFeature);
return d->featureExtendedData().m_timeSpan;
}
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;
}
const GeoDataTimeStamp &GeoDataFeature::timeStamp() const
{
+ Q_D(const GeoDataFeature);
return d->featureExtendedData().m_timeStamp;
}
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;
}
const GeoDataExtendedData &GeoDataFeature::extendedData() const
{
+ Q_D(const GeoDataFeature);
return d->m_extendedData;
}
GeoDataStyle::ConstPtr GeoDataFeature::style() const
{
+ Q_D(const GeoDataFeature);
if (d->m_style) {
return d->m_style;
}
@@ -361,12 +402,15 @@ GeoDataStyle::ConstPtr GeoDataFeature::style() const
GeoDataStyle::ConstPtr GeoDataFeature::customStyle() const
{
+ Q_D(const GeoDataFeature);
return d->m_style;
}
void GeoDataFeature::setStyle( const GeoDataStyle::Ptr &style )
{
detach();
+
+ Q_D(GeoDataFeature);
if (style)
style->setParent( this );
d->m_style = style;
@@ -375,89 +419,118 @@ 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;
}
-GeoDataRegion& GeoDataFeature::region() const
+const GeoDataRegion& GeoDataFeature::region() const
+{
+ Q_D(const GeoDataFeature);
+ return d->featureExtendedData().m_region;
+}
+
+GeoDataRegion& GeoDataFeature::region()
{
- // FIXME: Should call detach(). Maybe don't return reference.
+ detach();
+
+ Q_D(GeoDataFeature);
return d->featureExtendedData().m_region;
}
void GeoDataFeature::setRegion( const GeoDataRegion& region )
{
detach();
+
+ Q_D(GeoDataFeature);
d->featureExtendedData().m_region = region;
}
const QString GeoDataFeature::role() const
{
+ Q_D(const GeoDataFeature);
return d->m_role;
}
void GeoDataFeature::setRole( const QString &role )
{
detach();
+
+ Q_D(GeoDataFeature);
d->m_role = role;
}
const GeoDataStyleMap* GeoDataFeature::styleMap() const
{
+ Q_D(const GeoDataFeature);
return d->m_styleMap;
}
void GeoDataFeature::setStyleMap( const GeoDataStyleMap* styleMap )
{
+ detach();
+
+ Q_D(GeoDataFeature);
d->m_styleMap = styleMap;
}
int GeoDataFeature::zoomLevel() const
{
+ Q_D(const GeoDataFeature);
return d->m_zoomLevel;
}
void GeoDataFeature::setZoomLevel( int zoomLevel )
{
detach();
+
+ Q_D(GeoDataFeature);
d->m_zoomLevel = zoomLevel;
}
qint64 GeoDataFeature::popularity() const
{
+ Q_D(const GeoDataFeature);
return d->m_popularity;
}
void GeoDataFeature::setPopularity( qint64 popularity )
{
detach();
+
+ Q_D(GeoDataFeature);
d->m_popularity = popularity;
}
void GeoDataFeature::detach()
{
- if(d->ref.load() == 1) {
+ if (d_ptr->ref.load() == 1) {
return;
}
- GeoDataFeaturePrivate* new_d = d->copy();
+ GeoDataFeaturePrivate* new_d = d_ptr->copy();
- if (!d->ref.deref()) {
- delete d;
+ if (!d_ptr->ref.deref()) {
+ delete d_ptr;
}
- d = new_d;
+ d_ptr = new_d;
- d->ref.ref();
+ d_ptr->ref.ref();
}
void GeoDataFeature::pack( QDataStream& stream ) const
{
+ Q_D(const GeoDataFeature);
+
GeoDataObject::pack( stream );
stream << d->m_name;
@@ -474,6 +547,8 @@ void GeoDataFeature::pack( QDataStream& stream ) const
void GeoDataFeature::unpack( QDataStream& stream )
{
detach();
+
+ Q_D(GeoDataFeature);
GeoDataObject::unpack( stream );
stream >> d->m_name;
diff --git a/src/lib/marble/geodata/data/GeoDataFeature.h b/src/lib/marble/geodata/data/GeoDataFeature.h
index 9ec006c..a4a5213 100644
--- a/src/lib/marble/geodata/data/GeoDataFeature.h
+++ b/src/lib/marble/geodata/data/GeoDataFeature.h
@@ -204,7 +204,8 @@ class GEODATA_EXPORT GeoDataFeature : public GeoDataObject
/**
* Return the region assigned to the placemark.
*/
- GeoDataRegion& region() const;
+ const GeoDataRegion& region() const;
+ GeoDataRegion& region();
/**
* @brief Sets the region of the placemark.
* @param region new value for the region
@@ -268,8 +269,8 @@ class GEODATA_EXPORT GeoDataFeature : public GeoDataObject
protected:
// the d-pointer needs to be protected to be accessible from derived classes
- GeoDataFeaturePrivate* d;
- explicit GeoDataFeature( GeoDataFeaturePrivate* priv );
+ GeoDataFeaturePrivate* d_ptr;
+ explicit GeoDataFeature(GeoDataFeaturePrivate* dd);
virtual void detach();
@@ -277,8 +278,7 @@ class GEODATA_EXPORT GeoDataFeature : public GeoDataObject
using GeoDataObject::equals;
private:
- // the private d pointer accessor - use it instead of the d pointer directly
- GeoDataFeaturePrivate* p() const;
+ Q_DECLARE_PRIVATE(GeoDataFeature)
};
}
diff --git a/src/lib/marble/geodata/data/GeoDataFeature_p.h b/src/lib/marble/geodata/data/GeoDataFeature_p.h
index 86649c6..1b5bed8 100644
--- a/src/lib/marble/geodata/data/GeoDataFeature_p.h
+++ b/src/lib/marble/geodata/data/GeoDataFeature_p.h
@@ -219,6 +219,13 @@ class GeoDataFeaturePrivate
}
return *m_featureExtendedData;
}
+ const GeoDataFeatureExtendedData & featureExtendedData() const
+ {
+ if (!m_featureExtendedData) {
+ m_featureExtendedData = new GeoDataFeatureExtendedData;
+ }
+ return *m_featureExtendedData;
+ }
QString m_name; // Name of the feature. Is shown on screen
QString m_styleUrl; // styleUrl Url#tag to a document wide style
@@ -233,7 +240,7 @@ class GeoDataFeaturePrivate
const GeoDataStyleMap* m_styleMap;
GeoDataExtendedData m_extendedData;
- GeoDataFeatureExtendedData* m_featureExtendedData;
+ mutable GeoDataFeatureExtendedData* m_featureExtendedData;
QAtomicInt ref;
diff --git a/src/lib/marble/geodata/data/GeoDataFolder.cpp b/src/lib/marble/geodata/data/GeoDataFolder.cpp
index c7ccdc4..e197ef8 100644
--- a/src/lib/marble/geodata/data/GeoDataFolder.cpp
+++ b/src/lib/marble/geodata/data/GeoDataFolder.cpp
@@ -64,11 +64,6 @@ GeoDataFolder::~GeoDataFolder()
{
}
-GeoDataFolderPrivate* GeoDataFolder::p() const
-{
- return static_cast<GeoDataFolderPrivate*>(d);
-}
-
bool GeoDataFolder::operator==( const GeoDataFolder &other ) const
{
return GeoDataContainer::equals( other );
diff --git a/src/lib/marble/geodata/data/GeoDataFolder.h b/src/lib/marble/geodata/data/GeoDataFolder.h
index cd0c9f2..6ccc553 100644
--- a/src/lib/marble/geodata/data/GeoDataFolder.h
+++ b/src/lib/marble/geodata/data/GeoDataFolder.h
@@ -58,7 +58,7 @@ class GEODATA_EXPORT GeoDataFolder : public GeoDataContainer
bool operator!=( const GeoDataFolder &other ) const;
private:
- GeoDataFolderPrivate *p() const;
+ Q_DECLARE_PRIVATE(GeoDataFolder)
};
}
diff --git a/src/lib/marble/geodata/data/GeoDataPlacemark.cpp b/src/lib/marble/geodata/data/GeoDataPlacemark.cpp
index 056df65..ad7cbe4 100644
--- a/src/lib/marble/geodata/data/GeoDataPlacemark.cpp
+++ b/src/lib/marble/geodata/data/GeoDataPlacemark.cpp
@@ -40,7 +40,8 @@ const GeoDataPlacemarkExtendedData GeoDataPlacemarkPrivate::s_nullPlacemarkExten
GeoDataPlacemark::GeoDataPlacemark()
: GeoDataFeature( new GeoDataPlacemarkPrivate )
{
- p()->m_geometry->setParent( this );
+ Q_D(GeoDataPlacemark);
+ d->m_geometry->setParent(this);
}
GeoDataPlacemark::GeoDataPlacemark( const GeoDataPlacemark& other )
@@ -51,14 +52,15 @@ GeoDataPlacemark::GeoDataPlacemark( const GeoDataPlacemark& other )
// Q_ASSERT( this == p()->m_geometry->parent() );
// FIXME: fails as well when "other" is a copy where detach wasn't called
-// Q_ASSERT( other.p()->m_geometry == 0 || &other == other.p()->m_geometry->parent() );
+// Q_ASSERT( other_d->m_geometry == 0 || &other == other_d->m_geometry->parent() );
}
GeoDataPlacemark::GeoDataPlacemark( const QString& name )
: GeoDataFeature( new GeoDataPlacemarkPrivate )
{
+ Q_D(GeoDataPlacemark);
d->m_name = name;
- p()->m_geometry->setParent( this );
+ d->m_geometry->setParent(this);
}
GeoDataPlacemark::~GeoDataPlacemark()
@@ -75,82 +77,85 @@ GeoDataPlacemark &GeoDataPlacemark::operator=( const GeoDataPlacemark &other )
bool GeoDataPlacemark::operator==( const GeoDataPlacemark& other ) const
{
+ Q_D(const GeoDataPlacemark);
+ const GeoDataPlacemarkPrivate* const other_d = other.d_func();
if (!equals(other) ||
- p()->m_population != other.p()->m_population) {
+ d->m_population != other_d->m_population) {
return false;
}
- if ((p()->m_placemarkExtendedData && !other.p()->m_placemarkExtendedData) ||
- (!p()->m_placemarkExtendedData && other.p()->m_placemarkExtendedData)) {
+ if ((d->m_placemarkExtendedData && !other_d->m_placemarkExtendedData) ||
+ (!d->m_placemarkExtendedData && other_d->m_placemarkExtendedData)) {
return false;
}
- if (p()->m_placemarkExtendedData && other.p()->m_placemarkExtendedData &&
- !(*p()->m_placemarkExtendedData == *other.p()->m_placemarkExtendedData)) {
+ if (d->m_placemarkExtendedData && other_d->m_placemarkExtendedData &&
+ !(*d->m_placemarkExtendedData == *other_d->m_placemarkExtendedData)) {
return false;
}
- if ( !p()->m_geometry && !other.p()->m_geometry ) {
+ if (!d->m_geometry && !other_d->m_geometry) {
return true;
- } else if ( (!p()->m_geometry && other.p()->m_geometry) ||
- (p()->m_geometry && !other.p()->m_geometry) ) {
+ }
+ if ((!d->m_geometry && other_d->m_geometry) ||
+ (d->m_geometry && !other_d->m_geometry)) {
return false;
}
- if ( p()->m_geometry->nodeType() != other.p()->m_geometry->nodeType() ) {
+ if (d->m_geometry->nodeType() != other_d->m_geometry->nodeType()) {
return false;
}
- if ( p()->m_geometry->nodeType() == GeoDataTypes::GeoDataPolygonType ) {
- GeoDataPolygon *thisPoly = dynamic_cast<GeoDataPolygon*>( p()->m_geometry );
- GeoDataPolygon *otherPoly = dynamic_cast<GeoDataPolygon*>( other.p()->m_geometry );
+ if (d->m_geometry->nodeType() == GeoDataTypes::GeoDataPolygonType) {
+ GeoDataPolygon *thisPoly = dynamic_cast<GeoDataPolygon*>(d->m_geometry);
+ GeoDataPolygon *otherPoly = dynamic_cast<GeoDataPolygon*>(other_d->m_geometry);
Q_ASSERT( thisPoly && otherPoly );
if ( *thisPoly != *otherPoly ) {
return false;
}
- } else if ( p()->m_geometry->nodeType() == GeoDataTypes::GeoDataLineStringType ) {
- GeoDataLineString *thisLine = dynamic_cast<GeoDataLineString*>( p()->m_geometry );
- GeoDataLineString *otherLine = dynamic_cast<GeoDataLineString*>( other.p()->m_geometry );
+ } else if (d->m_geometry->nodeType() == GeoDataTypes::GeoDataLineStringType) {
+ GeoDataLineString *thisLine = dynamic_cast<GeoDataLineString*>(d->m_geometry);
+ GeoDataLineString *otherLine = dynamic_cast<GeoDataLineString*>(other_d->m_geometry);
Q_ASSERT( thisLine && otherLine );
if ( *thisLine != *otherLine ) {
return false;
}
- } else if ( p()->m_geometry->nodeType() == GeoDataTypes::GeoDataModelType ) {
- GeoDataModel *thisModel = dynamic_cast<GeoDataModel*>( p()->m_geometry );
- GeoDataModel *otherModel = dynamic_cast<GeoDataModel*>( other.p()->m_geometry );
+ } else if (d->m_geometry->nodeType() == GeoDataTypes::GeoDataModelType) {
+ GeoDataModel *thisModel = dynamic_cast<GeoDataModel*>(d->m_geometry);
+ GeoDataModel *otherModel = dynamic_cast<GeoDataModel*>(other_d->m_geometry);
Q_ASSERT( thisModel && otherModel );
if ( *thisModel != *otherModel ) {
return false;
}
- /*} else if ( p()->m_geometry->nodeType() == GeoDataTypes::GeoDataMultiGeometryType ) {
- GeoDataMultiGeometry *thisMG = dynamic_cast<GeoDataMultiGeometry*>( p()->m_geometry );
- GeoDataMultiGeometry *otherMG = dynamic_cast<GeoDataMultiGeometry*>( other.p()->m_geometry );
+ /*} else if (d->m_geometry->nodeType() == GeoDataTypes::GeoDataMultiGeometryType) {
+ GeoDataMultiGeometry *thisMG = dynamic_cast<GeoDataMultiGeometry*>(d->m_geometry);
+ GeoDataMultiGeometry *otherMG = dynamic_cast<GeoDataMultiGeometry*>(other_d->m_geometry);
Q_ASSERT( thisMG && otherMG );
if ( *thisMG != *otherMG ) {
return false;
} */ // Does not have equality operators. I guess they need to be implemented soon.
- } else if ( p()->m_geometry->nodeType() == GeoDataTypes::GeoDataTrackType ) {
- GeoDataTrack *thisTrack = dynamic_cast<GeoDataTrack*>( p()->m_geometry );
- GeoDataTrack *otherTrack = dynamic_cast<GeoDataTrack*>( other.p()->m_geometry );
+ } else if (d->m_geometry->nodeType() == GeoDataTypes::GeoDataTrackType) {
+ GeoDataTrack *thisTrack = dynamic_cast<GeoDataTrack*>(d->m_geometry);
+ GeoDataTrack *otherTrack = dynamic_cast<GeoDataTrack*>(other_d->m_geometry);
Q_ASSERT( thisTrack && otherTrack );
if ( *thisTrack != *otherTrack ) {
return false;
}
- } else if ( p()->m_geometry->nodeType() == GeoDataTypes::GeoDataMultiTrackType ) {
- GeoDataMultiTrack *thisMT = dynamic_cast<GeoDataMultiTrack*>( p()->m_geometry );
- GeoDataMultiTrack *otherMT = dynamic_cast<GeoDataMultiTrack*>( other.p()->m_geometry );
+ } else if (d->m_geometry->nodeType() == GeoDataTypes::GeoDataMultiTrackType) {
+ GeoDataMultiTrack *thisMT = dynamic_cast<GeoDataMultiTrack*>(d->m_geometry);
+ GeoDataMultiTrack *otherMT = dynamic_cast<GeoDataMultiTrack*>(other_d->m_geometry);
Q_ASSERT( thisMT && otherMT );
if ( *thisMT != *otherMT ) {
return false;
}
- } else if ( p()->m_geometry->nodeType() == GeoDataTypes::GeoDataPointType ) {
- GeoDataPoint *thisPoint = dynamic_cast<GeoDataPoint*>( p()->m_geometry );
- GeoDataPoint *otherPoint = dynamic_cast<GeoDataPoint*>( other.p()->m_geometry );
+ } else if (d->m_geometry->nodeType() == GeoDataTypes::GeoDataPointType) {
+ GeoDataPoint *thisPoint = dynamic_cast<GeoDataPoint*>(d->m_geometry);
+ GeoDataPoint *otherPoint = dynamic_cast<GeoDataPoint*>(other_d->m_geometry);
Q_ASSERT( thisPoint && otherPoint );
if ( *thisPoint != *otherPoint ) {
@@ -168,42 +173,39 @@ bool GeoDataPlacemark::operator!=( const GeoDataPlacemark& other ) const
GeoDataPlacemark::GeoDataVisualCategory GeoDataPlacemark::visualCategory() const
{
- return p()->m_visualCategory;
+ Q_D(const GeoDataPlacemark);
+ return d->m_visualCategory;
}
void GeoDataPlacemark::setVisualCategory(GeoDataPlacemark::GeoDataVisualCategory index)
{
detach();
- p()->m_visualCategory = index;
-}
-
-GeoDataPlacemarkPrivate* GeoDataPlacemark::p()
-{
- return static_cast<GeoDataPlacemarkPrivate*>(d);
-}
-const GeoDataPlacemarkPrivate* GeoDataPlacemark::p() const
-{
- return static_cast<GeoDataPlacemarkPrivate*>(d);
+ Q_D(GeoDataPlacemark);
+ d->m_visualCategory = index;
}
GeoDataGeometry* GeoDataPlacemark::geometry()
{
detach();
- p()->m_geometry->setParent( this );
- return p()->m_geometry;
+
+ Q_D(GeoDataPlacemark);
+ d->m_geometry->setParent(this);
+ return d->m_geometry;
}
const GeoDataGeometry* GeoDataPlacemark::geometry() const
{
- return p()->m_geometry;
+ Q_D(const GeoDataPlacemark);
+ return d->m_geometry;
}
const OsmPlacemarkData& GeoDataPlacemark::osmData() const
{
+ Q_D(const GeoDataPlacemark);
QVariant &placemarkVariantData = extendedData().valueRef( OsmPlacemarkData::osmHashKey() ).valueRef();
if ( !placemarkVariantData.canConvert<OsmPlacemarkData>() ) {
- return p()->s_nullOsmPlacemarkData;
+ return d->s_nullOsmPlacemarkData;
}
OsmPlacemarkData &osmData = *reinterpret_cast<OsmPlacemarkData*>( placemarkVariantData.data() );
@@ -251,12 +253,15 @@ GeoDataLookAt *GeoDataPlacemark::lookAt()
bool GeoDataPlacemark::placemarkLayoutOrderCompare(const GeoDataPlacemark *left, const GeoDataPlacemark *right)
{
- if (left->d->m_zoomLevel != right->d->m_zoomLevel) {
- return (left->d->m_zoomLevel < right->d->m_zoomLevel); // lower zoom level comes first
+ const GeoDataPlacemarkPrivate * const left_d = left->d_func();
+ const GeoDataPlacemarkPrivate * const right_d = right->d_func();
+
+ if (left_d->m_zoomLevel != right_d->m_zoomLevel) {
+ return (left_d->m_zoomLevel < right_d->m_zoomLevel); // lower zoom level comes first
}
- if (left->d->m_popularity != right->d->m_popularity) {
- return left->d->m_popularity > right->d->m_popularity; // higher popularity comes first
+ if (left_d->m_popularity != right_d->m_popularity) {
+ return (left_d->m_popularity > right_d->m_popularity); // higher popularity comes first
}
return left < right; // lower pointer value comes first
@@ -264,18 +269,19 @@ bool GeoDataPlacemark::placemarkLayoutOrderCompare(const GeoDataPlacemark *left,
GeoDataCoordinates GeoDataPlacemark::coordinate( const QDateTime &dateTime, bool *iconAtCoordinates ) const
{
+ Q_D(const GeoDataPlacemark);
bool hasIcon = false;
GeoDataCoordinates coord;
- if( p()->m_geometry ) {
+ if (d->m_geometry) {
// Beware: comparison between pointers, not strings.
- if (p()->m_geometry->nodeType() == GeoDataTypes::GeoDataPointType
- || p()->m_geometry->nodeType() == GeoDataTypes::GeoDataPolygonType
- || p()->m_geometry->nodeType() == GeoDataTypes::GeoDataLinearRingType) {
+ if (d->m_geometry->nodeType() == GeoDataTypes::GeoDataPointType
+ || d->m_geometry->nodeType() == GeoDataTypes::GeoDataPolygonType
+ || d->m_geometry->nodeType() == GeoDataTypes::GeoDataLinearRingType) {
hasIcon = true;
- coord = p()->m_geometry->latLonAltBox().center();
- } else if ( p()->m_geometry->nodeType() == GeoDataTypes::GeoDataMultiGeometryType ) {
- const GeoDataMultiGeometry *multiGeometry = static_cast<const GeoDataMultiGeometry *>( p()->m_geometry );
+ coord = d->m_geometry->latLonAltBox().center();
+ } else if (d->m_geometry->nodeType() == GeoDataTypes::GeoDataMultiGeometryType) {
+ const GeoDataMultiGeometry *multiGeometry = static_cast<const GeoDataMultiGeometry *>(d->m_geometry);
QVector<GeoDataGeometry*>::ConstIterator it = multiGeometry->constBegin();
QVector<GeoDataGeometry*>::ConstIterator end = multiGeometry->constEnd();
@@ -288,13 +294,13 @@ GeoDataCoordinates GeoDataPlacemark::coordinate( const QDateTime &dateTime, bool
}
}
- coord = p()->m_geometry->latLonAltBox().center();
- } else if ( p()->m_geometry->nodeType() == GeoDataTypes::GeoDataTrackType ) {
- const GeoDataTrack *track = static_cast<const GeoDataTrack *>( p()->m_geometry );
+ coord = d->m_geometry->latLonAltBox().center();
+ } else if (d->m_geometry->nodeType() == GeoDataTypes::GeoDataTrackType) {
+ const GeoDataTrack *track = static_cast<const GeoDataTrack *>(d->m_geometry);
hasIcon = track->size() != 0 && track->firstWhen() <= dateTime;
coord = track->coordinatesAt( dateTime );
} else {
- coord = p()->m_geometry->latLonAltBox().center();
+ coord = d->m_geometry->latLonAltBox().center();
}
}
@@ -322,9 +328,11 @@ void GeoDataPlacemark::setCoordinate( const GeoDataCoordinates &point )
void GeoDataPlacemark::setGeometry( GeoDataGeometry *entry )
{
detach();
- delete p()->m_geometry;
- p()->m_geometry = entry;
- p()->m_geometry->setParent( this );
+
+ Q_D(GeoDataPlacemark);
+ delete d->m_geometry;
+ d->m_geometry = entry;
+ d->m_geometry->setParent(this);
}
@@ -350,7 +358,8 @@ QString GeoDataPlacemark::displayName() const
QString GeoDataPlacemark::categoryName() const
{
- switch (p()->m_visualCategory) {
+ Q_D(const GeoDataPlacemark);
+ switch (d->m_visualCategory) {
case Valley: return GeoDataPlacemarkPrivate::tr("Valley");
case OtherTerrain: return GeoDataPlacemarkPrivate::tr("Terrain");
case Crater: return GeoDataPlacemarkPrivate::tr("Crater");
@@ -653,91 +662,106 @@ QString GeoDataPlacemark::categoryName() const
qreal GeoDataPlacemark::area() const
{
- return p()->m_placemarkExtendedData ? p()->m_placemarkExtendedData->m_area : -1.0;
+ Q_D(const GeoDataPlacemark);
+ return d->m_placemarkExtendedData ? d->m_placemarkExtendedData->m_area : -1.0;
}
void GeoDataPlacemark::setArea( qreal area )
{
- if (area == -1.0 && !p()->m_placemarkExtendedData) {
+ if (area == -1.0 && !d_func()->m_placemarkExtendedData) {
return; // nothing to do
}
detach();
- p()->m_geometry->setParent( this );
- p()->placemarkExtendedData().m_area = area;
+
+ Q_D(GeoDataPlacemark);
+ d->m_geometry->setParent(this);
+ d->placemarkExtendedData().m_area = area;
}
qint64 GeoDataPlacemark::population() const
{
- return p()->m_population;
+ Q_D(const GeoDataPlacemark);
+ return d->m_population;
}
void GeoDataPlacemark::setPopulation( qint64 population )
{
detach();
- p()->m_geometry->setParent( this );
- p()->m_population = population;
+
+ Q_D(GeoDataPlacemark);
+ d->m_geometry->setParent(this);
+ d->m_population = population;
}
const QString GeoDataPlacemark::state() const
{
- return p()->m_placemarkExtendedData ? p()->m_placemarkExtendedData->m_state : QString();
+ Q_D(const GeoDataPlacemark);
+ return d->m_placemarkExtendedData ? d->m_placemarkExtendedData->m_state : QString();
}
void GeoDataPlacemark::setState( const QString &state )
{
- if (state.isEmpty() && !p()->m_placemarkExtendedData) {
+ if (state.isEmpty() && !d_func()->m_placemarkExtendedData) {
return; // nothing to do
}
detach();
- p()->m_geometry->setParent( this );
- p()->placemarkExtendedData().m_state = state;
+
+ Q_D(GeoDataPlacemark);
+ d->m_geometry->setParent(this);
+ d->placemarkExtendedData().m_state = state;
}
const QString GeoDataPlacemark::countryCode() const
{
- return p()->m_placemarkExtendedData ? p()->m_placemarkExtendedData->m_countrycode : QString();
+ Q_D(const GeoDataPlacemark);
+ return d->m_placemarkExtendedData ? d->m_placemarkExtendedData->m_countrycode : QString();
}
void GeoDataPlacemark::setCountryCode( const QString &countrycode )
{
- if (countrycode.isEmpty() && !p()->m_placemarkExtendedData) {
+ if (countrycode.isEmpty() && !d_func()->m_placemarkExtendedData) {
return; // nothing to do
}
detach();
- p()->m_geometry->setParent( this );
- p()->placemarkExtendedData().m_countrycode = countrycode;
+
+ Q_D(GeoDataPlacemark);
+ d->m_geometry->setParent(this);
+ d->placemarkExtendedData().m_countrycode = countrycode;
}
bool GeoDataPlacemark::isBalloonVisible() const
{
- return p()->m_placemarkExtendedData ? p()->m_placemarkExtendedData->m_isBalloonVisible : false;
+ Q_D(const GeoDataPlacemark);
+ return d->m_placemarkExtendedData ? d->m_placemarkExtendedData->m_isBalloonVisible : false;
}
void GeoDataPlacemark::setBalloonVisible( bool visible )
{
- if (!visible && !p()->m_placemarkExtendedData) {
+ if (!visible && !d_func()->m_placemarkExtendedData) {
return; // nothing to do
}
detach();
- p()->m_geometry->setParent( this );
- p()->placemarkExtendedData().m_isBalloonVisible = visible;
+
+ Q_D(GeoDataPlacemark);
+ d->m_geometry->setParent(this);
+ d->placemarkExtendedData().m_isBalloonVisible = visible;
}
void GeoDataPlacemark::pack( QDataStream& stream ) const
{
+ Q_D(const GeoDataPlacemark);
GeoDataFeature::pack( stream );
- stream << p()->placemarkExtendedData().m_countrycode;
- stream << p()->placemarkExtendedData().m_area;
- stream << p()->m_population;
- if ( p()->m_geometry )
- {
- stream << p()->m_geometry->geometryId();
- p()->m_geometry->pack( stream );
+ stream << d->placemarkExtendedData().m_countrycode;
+ stream << d->placemarkExtendedData().m_area;
+ stream << d->m_population;
+ if (d->m_geometry) {
+ stream << d->m_geometry->geometryId();
+ d->m_geometry->pack( stream );
}
else
{
@@ -762,12 +786,15 @@ QXmlStreamWriter& GeoDataPlacemark::operator <<( QXmlStreamWriter& stream ) cons
void GeoDataPlacemark::unpack( QDataStream& stream )
{
detach();
- p()->m_geometry->setParent( this );
+
+ Q_D(GeoDataPlacemark);
+ // TODO: check if this should be done after the switch
+ d->m_geometry->setParent(this);
GeoDataFeature::unpack( stream );
- stream >> p()->placemarkExtendedData().m_countrycode;
- stream >> p()->placemarkExtendedData().m_area;
- stream >> p()->m_population;
+ stream >> d->placemarkExtendedData().m_countrycode;
+ stream >> d->placemarkExtendedData().m_area;
+ stream >> d->m_population;
int geometryId;
stream >> geometryId;
switch( geometryId ) {
@@ -777,40 +804,40 @@ void GeoDataPlacemark::unpack( QDataStream& stream )
{
GeoDataPoint* point = new GeoDataPoint;
point->unpack( stream );
- delete p()->m_geometry;
- p()->m_geometry = point;
+ delete d->m_geometry;
+ d->m_geometry = point;
}
break;
case GeoDataLineStringId:
{
GeoDataLineString* lineString = new GeoDataLineString;
lineString->unpack( stream );
- delete p()->m_geometry;
- p()->m_geometry = lineString;
+ delete d->m_geometry;
+ d->m_geometry = lineString;
}
break;
case GeoDataLinearRingId:
{
GeoDataLinearRing* linearRing = new GeoDataLinearRing;
linearRing->unpack( stream );
- delete p()->m_geometry;
- p()->m_geometry = linearRing;
+ delete d->m_geometry;
+ d->m_geometry = linearRing;
}
break;
case GeoDataPolygonId:
{
GeoDataPolygon* polygon = new GeoDataPolygon;
polygon->unpack( stream );
- delete p()->m_geometry;
- p()->m_geometry = polygon;
+ delete d->m_geometry;
+ d->m_geometry = polygon;
}
break;
case GeoDataMultiGeometryId:
{
GeoDataMultiGeometry* multiGeometry = new GeoDataMultiGeometry;
multiGeometry->unpack( stream );
- delete p()->m_geometry;
- p()->m_geometry = multiGeometry;
+ delete d->m_geometry;
+ d->m_geometry = multiGeometry;
}
break;
case GeoDataModelId:
diff --git a/src/lib/marble/geodata/data/GeoDataPlacemark.h b/src/lib/marble/geodata/data/GeoDataPlacemark.h
index 0ffdbf5..f2b3007 100644
--- a/src/lib/marble/geodata/data/GeoDataPlacemark.h
+++ b/src/lib/marble/geodata/data/GeoDataPlacemark.h
@@ -627,8 +627,7 @@ class GEODATA_EXPORT GeoDataPlacemark: public GeoDataFeature
static bool placemarkLayoutOrderCompare(const GeoDataPlacemark *a, const GeoDataPlacemark* b);
private:
- inline GeoDataPlacemarkPrivate *p();
- inline const GeoDataPlacemarkPrivate *p() const;
+ Q_DECLARE_PRIVATE(GeoDataPlacemark)
};
}
diff --git a/src/lib/marble/geodata/data/GeoDataPlacemark_p.h b/src/lib/marble/geodata/data/GeoDataPlacemark_p.h
index c449371..77db108 100644
--- a/src/lib/marble/geodata/data/GeoDataPlacemark_p.h
+++ b/src/lib/marble/geodata/data/GeoDataPlacemark_p.h
@@ -118,6 +118,7 @@ class GeoDataPlacemarkPrivate : public GeoDataFeaturePrivate
}
delete m_geometry;
m_geometry = geometry;
+ // TODO: why not set parent here to geometry?
delete m_placemarkExtendedData;
m_placemarkExtendedData = nullptr;
diff --git a/src/lib/marble/geodata/data/GeoDataTour.cpp b/src/lib/marble/geodata/data/GeoDataTour.cpp
index 34973d0..947ae85 100644
--- a/src/lib/marble/geodata/data/GeoDataTour.cpp
+++ b/src/lib/marble/geodata/data/GeoDataTour.cpp
@@ -28,20 +28,11 @@ GeoDataTour::~GeoDataTour()
// nothing to do;
}
-GeoDataTourPrivate *GeoDataTour::p()
-{
- return static_cast<GeoDataTourPrivate*>(d);
-}
-
-const GeoDataTourPrivate *GeoDataTour::p() const
-{
- return static_cast<GeoDataTourPrivate*>(d);
-}
-
bool GeoDataTour::operator==(const GeoDataTour& other) const
{
+ Q_D(const GeoDataTour);
return equals( other ) &&
- *p()->m_playlist == *other.p()->m_playlist;
+ *d->m_playlist == *other.d_func()->m_playlist;
}
bool GeoDataTour::operator!=(const GeoDataTour& other) const
@@ -52,19 +43,24 @@ bool GeoDataTour::operator!=(const GeoDataTour& other) const
GeoDataPlaylist* GeoDataTour::playlist()
{
detach();
- return p()->m_playlist;
+
+ Q_D(GeoDataTour);
+ return d->m_playlist;
}
const GeoDataPlaylist* GeoDataTour::playlist() const
{
- return p()->m_playlist;
+ Q_D(const GeoDataTour);
+ return d->m_playlist;
}
void GeoDataTour::setPlaylist(GeoDataPlaylist *playlist)
{
detach();
- p()->m_playlist = playlist;
- p()->m_playlist->setParent( this );
+
+ Q_D(GeoDataTour);
+ d->m_playlist = playlist;
+ d->m_playlist->setParent(this);
}
const char *GeoDataTour::nodeType() const
diff --git a/src/lib/marble/geodata/data/GeoDataTour.h b/src/lib/marble/geodata/data/GeoDataTour.h
index b594b00..4b05e2a 100644
--- a/src/lib/marble/geodata/data/GeoDataTour.h
+++ b/src/lib/marble/geodata/data/GeoDataTour.h
@@ -39,8 +39,7 @@ public:
static const GeoDataTour null;
private:
- GeoDataTourPrivate *p();
- const GeoDataTourPrivate *p() const;
+ Q_DECLARE_PRIVATE(GeoDataTour)
};