[Marble-commits] KDE/kdeedu/marble/src/lib/geodata

Bastian Holst bastianholst at gmx.de
Tue Mar 30 21:48:05 CEST 2010


SVN commit 1109214 by bholst:

Making GeoDataLookAt implicitly shared and saving GeoDataAbstractView instead of GeoDataLookAt* in GeoDataFeature as it is done in KML.
http://reviewboard.kde.org/r/3448/


 M  +1 -2      GeoDataTest.cpp  
 M  +3 -0      data/GeoDataAbstractView.h  
 M  +11 -10    data/GeoDataFeature.cpp  
 M  +6 -13     data/GeoDataFeature.h  
 M  +12 -10    data/GeoDataFeature_p.h  
 M  +31 -21    data/GeoDataLookAt.cpp  
 M  +1 -0      data/GeoDataLookAt.h  
 M  +11 -4     data/GeoDataLookAt_p.h  


--- trunk/KDE/kdeedu/marble/src/lib/geodata/GeoDataTest.cpp #1109213:1109214
@@ -28,7 +28,6 @@
 #include "GeoDataDocument.h"
 #include "GeoDataFolder.h"
 #include "GeoDataPlacemark.h"
-#include "GeoDataLookAt.h"
 
 #include "GeoSceneDocument.h"
 #include "GeoSceneHead.h"
@@ -192,7 +191,7 @@
 void dumpGeoDataPlacemark(const GeoDataPlacemark& placemark)
 {
     Q_UNUSED(placemark);
-//	qDebug() << placemark.name() << placemark.population() << placemark.coordinate().toString()<<"lookAt info "<<(placemark.lookAt()->coordinate())->toString()<<placemark.lookAt()->altitude();
+//	qDebug() << placemark.name() << placemark.population() << placemark.coordinate().toString();
 }
 
 void dumpFoldersRecursively(const GeoDataContainer& container, int depth)
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataAbstractView.h #1109213:1109214
@@ -8,6 +8,9 @@
 namespace Marble
 {
 
+/**
+ * @see GeoDataLookAt
+ */
 class GEODATA_EXPORT GeoDataAbstractView : public GeoDataObject
 {
  public:
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataFeature.cpp #1109213:1109214
@@ -420,6 +420,17 @@
     d->m_descriptionCDATA = cdata;
 }
 
+GeoDataAbstractView GeoDataFeature::abstractView() const
+{
+    return d->m_abstractView;
+}
+
+void GeoDataFeature::setAbstractView( const GeoDataAbstractView &abstractView )
+{
+    detach();
+    d->m_abstractView = abstractView;
+}
+
 QString GeoDataFeature::styleUrl() const
 {
     return d->m_styleUrl;
@@ -514,16 +525,6 @@
     d->m_styleMap = styleMap;
 }
 
-GeoDataLookAt* GeoDataFeature::lookAt() const
-{
-	return p()->m_lookAt;
-}
-
-void GeoDataFeature::setLookAt( GeoDataLookAt* lookAt )
-{
-	p()->m_lookAt = lookAt;
-}
-	
 int GeoDataFeature::popularityIndex() const
 {
     return d->m_popularityIndex;
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataFeature.h #1109213:1109214
@@ -21,7 +21,6 @@
 #include <QtGui/QColor>
 
 #include "GeoDataObject.h"
-#include "GeoDataLookAt.h"
 
 #include "geodata_export.h"
 
@@ -34,6 +33,7 @@
 class GeoDataDocument;
 class GeoDataPlacemark;
 class GeoDataRegion;
+class GeoDataAbstractView;
 
 class GeoDataStyle;
 class GeoDataStyleMap;
@@ -191,6 +191,11 @@
     /// Set the description to be CDATA See: @see descriptionIsCDATA()
     void setDescriptionCDATA( bool cdata );
 
+    /// Get the Abstract view of the feature
+    GeoDataAbstractView abstractView() const;
+    /// Set the abstract view of the feature
+    void setAbstractView( const GeoDataAbstractView &abstractView );
+
     /// Return the styleUrl of the feature.
     QString styleUrl() const;
     /// Set the styleUrl of this feature to @p value.
@@ -289,19 +294,7 @@
      */
     void setStyleMap( GeoDataStyleMap* map );
 
-    /**
-     * Returns pointer to the GeoDataLooAt of the feature.
-     */
-    GeoDataLookAt* lookAt() const;
 
-    /**
-     * Sets the lookAt of the placemark.
-     * @param  LookAt  the new LookAt of the feature.
-     */
-    void setLookAt( GeoDataLookAt *lookAt );
-
-	
-
     // ----------------------------------------------------------------
     // The following functions are use for painting, and mostly for placemarks.
 
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataFeature_p.h #1109213:1109214
@@ -14,6 +14,7 @@
 #include <QtCore/QString>
 #include <QtCore/QAtomicInt>
 
+#include "GeoDataAbstractView.h"
 #include "GeoDataFeature.h"
 #include "GeoDataRegion.h"
 
@@ -31,7 +32,8 @@
         m_descriptionCDATA(),
         m_address(),
         m_phoneNumber(),
-        m_styleUrl(),        
+        m_styleUrl(),
+        m_abstractView(),
         m_popularity( 0 ),
         m_popularityIndex( 19 ),
         m_visible( true ),
@@ -102,14 +104,15 @@
         return GeoDataTypes::GeoDataFeatureType;
     }
 
-    QString     m_name;         // Name of the feature. Is shown on screen
-    QString     m_description;  // A longer textual description
-    bool        m_descriptionCDATA; // True if description should be considered CDATA
-    QString     m_address;      // The address.  Optional
-    QString     m_phoneNumber;  // Phone         Optional
-    QString     m_styleUrl;     // styleUrl     Url#tag to a document wide style
-    qint64      m_popularity;   // Population(!)
-    int         m_popularityIndex; // Index of population
+    QString             m_name;         // Name of the feature. Is shown on screen
+    QString             m_description;  // A longer textual description
+    bool                m_descriptionCDATA; // True if description should be considered CDATA
+    QString             m_address;      // The address.  Optional
+    QString             m_phoneNumber;  // Phone         Optional
+    QString             m_styleUrl;     // styleUrl     Url#tag to a document wide style
+    GeoDataAbstractView m_abstractView; // AbstractView  Optional
+    qint64              m_popularity;   // Population(!)
+    int                 m_popularityIndex; // Index of population
 
     bool        m_visible;      // True if this feature should be shown.
     GeoDataFeature::GeoDataVisualCategory  m_visualCategory; // the visual category
@@ -119,7 +122,6 @@
 
     GeoDataStyle*    m_style;
     GeoDataStyleMap* m_styleMap;
-    GeoDataLookAt*   m_lookAt;
 
     GeoDataRegion m_region;
     
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataLookAt.cpp #1109213:1109214
@@ -9,65 +9,70 @@
 namespace Marble
 {
 
-GeoDataLookAt::GeoDataLookAt() : d (new GeoDataLookAtPrivate)
+GeoDataLookAt::GeoDataLookAt()
+    : d( new GeoDataLookAtPrivate )
 {
-    // nothing to do
 }
 
-GeoDataLookAt::GeoDataLookAt(const GeoDataLookAt& other) : 
-        d (new GeoDataLookAtPrivate(*other.d))
+GeoDataLookAt::GeoDataLookAt( const GeoDataLookAt& other )
+    : d( other.d )
 {
-    // nothing to do
+    d->ref.ref();
 }
 
-GeoDataLookAt& GeoDataLookAt::operator=(const GeoDataLookAt &other)                                   
+GeoDataLookAt& GeoDataLookAt::operator=( const GeoDataLookAt &other )                                   
 {
-    *d = *other.d;
-    return *this;    
+    qAtomicAssign( d, other.d );
+    return *this;
 }
 
 GeoDataLookAt::~GeoDataLookAt()
 {
-    delete d;
+    if( !d->ref.deref() )
+        delete d;
 }
 
-void GeoDataLookAt::setAltitude( qreal altitude)
+void GeoDataLookAt::setAltitude( qreal altitude )
 {
-    d->m_coord.setAltitude(altitude);
+    detach();
+    d->m_coordinates.setAltitude( altitude );
 }
 
 qreal GeoDataLookAt::altitude() const
 {
-    return d->m_coord.altitude();
+    return d->m_coordinates.altitude();
 }
 
-void GeoDataLookAt::setLatitude( qreal latitude, GeoDataCoordinates::Unit unit)
+void GeoDataLookAt::setLatitude( qreal latitude, GeoDataCoordinates::Unit unit )
 {
-    d->m_coord.setLatitude(latitude,unit);
+    detach();
+    d->m_coordinates.setLatitude( latitude,unit );
 }
 
-qreal GeoDataLookAt::latitude(GeoDataCoordinates::Unit unit) const
+qreal GeoDataLookAt::latitude( GeoDataCoordinates::Unit unit ) const
 {
-    return d->m_coord.latitude(unit);
+    return d->m_coordinates.latitude( unit );
 }
 
-void GeoDataLookAt::setLongitude( qreal longitude, GeoDataCoordinates::Unit unit)
+void GeoDataLookAt::setLongitude( qreal longitude, GeoDataCoordinates::Unit unit )
 {
-    d->m_coord.setLongitude(longitude,unit);
+    detach();
+    d->m_coordinates.setLongitude( longitude, unit );
 }
 
-qreal GeoDataLookAt::longitude(GeoDataCoordinates::Unit unit) const
+qreal GeoDataLookAt::longitude( GeoDataCoordinates::Unit unit ) const
 {
-    return d->m_coord.longitude(unit);
+    return d->m_coordinates.longitude( unit );
 }
 
 GeoDataCoordinates GeoDataLookAt::coordinates() const
 {
-    return d->m_coord;
+    return d->m_coordinates;
 }
 
 void GeoDataLookAt::setRange( qreal range )
 {
+    detach();
     d->m_range = range;
 }
 
@@ -76,4 +81,9 @@
     return d->m_range;
 }
 
+void GeoDataLookAt::detach()
+{
+    qAtomicDetach( d );
 }
+
+}
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataLookAt.h #1109213:1109214
@@ -86,6 +86,7 @@
           */
         qreal range() const;
 
+        void detach();
     private:
         GeoDataLookAtPrivate *d;
 
--- trunk/KDE/kdeedu/marble/src/lib/geodata/data/GeoDataLookAt_p.h #1109213:1109214
@@ -1,22 +1,29 @@
 #ifndef GEODATALOOKAT_P_H
 #define GEODATALOOKAT_P_H
 
+// Marble
 #include "GeoDataCoordinates.h"
 
+// Qt
+#include <QtCore/QAtomicInt>
+
 namespace Marble
 {
 
 class GeoDataLookAtPrivate
 {
  public :
-    GeoDataLookAtPrivate() : m_range(0.0)
+    GeoDataLookAtPrivate()
+        : m_coordinates(),
+          m_range( 0.0 ),
+          ref( 1 )
     {
-        // nothing to do
     }
 
-    GeoDataCoordinates m_coord;
-
+    GeoDataCoordinates m_coordinates;
     qreal m_range;
+    
+    QAtomicInt ref;
 };
 
 } // namespace Marble


More information about the Marble-commits mailing list