diff --git a/src/lib/marble/geodata/data/GeoDataContainer_p.h b/src/lib/marble/geodata/data/GeoDataContainer_p.h index 96f140df2..ec0a27f0f 100644 --- a/src/lib/marble/geodata/data/GeoDataContainer_p.h +++ b/src/lib/marble/geodata/data/GeoDataContainer_p.h @@ -1,67 +1,68 @@ // // 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 2009 Patrick Spendrin // #ifndef MARBLE_GEODATACONTAINERPRIVATE_H #define MARBLE_GEODATACONTAINERPRIVATE_H #include "GeoDataFeature_p.h" #include "GeoDataTypes.h" namespace Marble { class GeoDataContainerPrivate : public GeoDataFeaturePrivate { public: GeoDataContainerPrivate() { } ~GeoDataContainerPrivate() { qDeleteAll( m_vector ); } GeoDataContainerPrivate& operator=( const GeoDataContainerPrivate &other) { GeoDataFeaturePrivate::operator=( other ); qDeleteAll( m_vector ); + m_vector.clear(); m_vector.reserve(other.m_vector.size()); foreach( GeoDataFeature *feature, other.m_vector ) { m_vector.append( new GeoDataFeature( *feature ) ); } return *this; } virtual GeoDataFeaturePrivate* copy() { GeoDataContainerPrivate* copy = new GeoDataContainerPrivate; *copy = *this; return copy; } virtual const char* nodeType() const { return GeoDataTypes::GeoDataContainerType; } virtual EnumFeatureId featureId() const { return GeoDataFolderId; } QVector m_vector; }; } // namespace Marble #endif diff --git a/src/lib/marble/geodata/data/GeoDataMultiGeometry_p.h b/src/lib/marble/geodata/data/GeoDataMultiGeometry_p.h index be481351c..ccd8d2d4f 100644 --- a/src/lib/marble/geodata/data/GeoDataMultiGeometry_p.h +++ b/src/lib/marble/geodata/data/GeoDataMultiGeometry_p.h @@ -1,102 +1,103 @@ // // 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 2009 Patrick Spendrin // #ifndef MARBLE_GEODATAMULTIGEOMETRYPRIVATE_H #define MARBLE_GEODATAMULTIGEOMETRYPRIVATE_H #include "GeoDataGeometry_p.h" #include "GeoDataPoint.h" #include "GeoDataPolygon.h" #include "GeoDataTrack.h" #include "GeoDataMultiTrack.h" #include "GeoDataLineString.h" #include "GeoDataLinearRing.h" #include "GeoDataModel.h" #include "GeoDataTypes.h" namespace Marble { class GeoDataMultiGeometryPrivate : public GeoDataGeometryPrivate { public: GeoDataMultiGeometryPrivate() { } ~GeoDataMultiGeometryPrivate() { qDeleteAll(m_vector); } GeoDataMultiGeometryPrivate& operator=( const GeoDataMultiGeometryPrivate &other) { GeoDataGeometryPrivate::operator=( other ); qDeleteAll( m_vector ); + m_vector.clear(); m_vector.reserve(other.m_vector.size()); foreach( GeoDataGeometry *geometry, other.m_vector ) { GeoDataGeometry *newGeometry; // This piece of code has been used for a couple of times. Isn't it possible // to add a virtual method copy() similar to how abstract view does this? if ( geometry->nodeType() == GeoDataTypes::GeoDataLineStringType ) { newGeometry = new GeoDataLineString( *geometry ); } else if ( geometry->nodeType() == GeoDataTypes::GeoDataPointType ) { // FIXME: Doesn't have a constructor which creates the object from a // GeoDataGeometry so cast is needed. newGeometry = new GeoDataPoint( *static_cast( geometry ) ); } else if ( geometry->nodeType() == GeoDataTypes::GeoDataModelType ) { // FIXME: Doesn't have a constructor which creates the object from a // GeoDataGeometry so cast is needed. newGeometry = new GeoDataModel( *static_cast( geometry ) ); } else if ( geometry->nodeType() == GeoDataTypes::GeoDataTrackType ) { newGeometry = new GeoDataTrack( *static_cast( geometry ) ); } else if ( geometry->nodeType() == GeoDataTypes::GeoDataMultiTrackType ) { newGeometry = new GeoDataMultiTrack( *geometry ); } else if ( geometry->nodeType() == GeoDataTypes::GeoDataPolygonType ) { newGeometry = new GeoDataPolygon( *geometry ); } else if ( geometry->nodeType() == GeoDataTypes::GeoDataLinearRingType ) { newGeometry = new GeoDataLinearRing( *geometry ); } else { qFatal("Unexpected type '%s'", geometry->nodeType() ); } m_vector.append( newGeometry ); } return *this; } virtual GeoDataGeometryPrivate* copy() { GeoDataMultiGeometryPrivate* copy = new GeoDataMultiGeometryPrivate; *copy = *this; return copy; } virtual const char* nodeType() const { return GeoDataTypes::GeoDataMultiGeometryType; } virtual EnumGeometryId geometryId() const { return GeoDataMultiGeometryId; } QVector m_vector; }; } // namespace Marble #endif diff --git a/src/lib/marble/geodata/data/GeoDataMultiTrack_p.h b/src/lib/marble/geodata/data/GeoDataMultiTrack_p.h index 80eda22d1..2d97e0f28 100644 --- a/src/lib/marble/geodata/data/GeoDataMultiTrack_p.h +++ b/src/lib/marble/geodata/data/GeoDataMultiTrack_p.h @@ -1,67 +1,68 @@ // // 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 Thibaut Gridel #ifndef MARBLE_GEODATAMULTITRACKPRIVATE_H #define MARBLE_GEODATAMULTITRACKPRIVATE_H #include "GeoDataGeometry_p.h" #include "GeoDataTypes.h" #include "GeoDataTrack.h" namespace Marble { class GeoDataMultiTrackPrivate : public GeoDataGeometryPrivate { public: GeoDataMultiTrackPrivate() { } ~GeoDataMultiTrackPrivate() { qDeleteAll(m_vector); } GeoDataMultiTrackPrivate& operator=( const GeoDataMultiTrackPrivate &other) { GeoDataGeometryPrivate::operator=( other ); qDeleteAll( m_vector ); + m_vector.clear(); m_vector.reserve(other.m_vector.size()); foreach( GeoDataTrack *track, other.m_vector ) { m_vector.append( new GeoDataTrack( *track ) ); } return *this; } virtual GeoDataGeometryPrivate* copy() { GeoDataMultiTrackPrivate* copy = new GeoDataMultiTrackPrivate; *copy = *this; return copy; } virtual const char* nodeType() const { return GeoDataTypes::GeoDataMultiTrackType; } virtual EnumGeometryId geometryId() const { return GeoDataMultiTrackId; } QVector m_vector; }; } // namespace Marble #endif