[Marble-commits] branches/KDE/4.3/kdeedu/marble/src

Patrick Spendrin ps_ml at gmx.de
Sun Jul 12 23:53:48 CEST 2009


SVN commit 995519 by sengels:

backport r993608, r993609, r994029, r994825, r994857, r994859, r994886

this makes kml files to be shown mostly correct again, removes a memory leak and paints the sky in a light violet-yellowish

BUG: 199942


 M  +6 -1      lib/KmlFileViewItem.cpp  
 M  +2 -1      lib/KmlFileViewItem.h  
 M  +4 -4      lib/MarbleGeometryModel.cpp  
 M  +8 -14     lib/MarbleModel.cpp  
 M  +1 -2      lib/MarbleModel.h  
 M  +3 -3      lib/PlacemarkLoader.cpp  
 M  +1 -1      lib/PlacemarkLoader.h  
 M  +21 -10    lib/PlacemarkManager.cpp  
 M  +1 -2      lib/PlacemarkManager.h  
 M  +6 -3      plugins/render/geodata/GeoRendererView.cpp  


--- branches/KDE/4.3/kdeedu/marble/src/lib/KmlFileViewItem.cpp #995518:995519
@@ -19,7 +19,7 @@
 
 using namespace Marble;
 
-KmlFileViewItem::KmlFileViewItem( PlacemarkManager& manager, GeoDataDocument const& document ) :
+KmlFileViewItem::KmlFileViewItem( PlacemarkManager& manager, const GeoDataDocument& document ) :
     m_placemarkManager( manager ),
     m_document( document )
 {
@@ -30,6 +30,11 @@
     //TODO
 }
 
+GeoDataDocument* KmlFileViewItem::document()
+{
+    return &m_document;
+}
+
 void KmlFileViewItem::saveFile()
 {
     //TODO
--- branches/KDE/4.3/kdeedu/marble/src/lib/KmlFileViewItem.h #995518:995519
@@ -24,7 +24,7 @@
 class KmlFileViewItem : public AbstractFileViewItem
 {
   public:
-    KmlFileViewItem( PlacemarkManager& manager, GeoDataDocument const& document );
+    KmlFileViewItem( PlacemarkManager& manager, const GeoDataDocument& document );
     ~KmlFileViewItem();
 
     /*
@@ -37,6 +37,7 @@
     virtual void setShown( bool value );
     virtual int size() const;
 
+    GeoDataDocument* document();
   private:
     PlacemarkManager&   m_placemarkManager;
     GeoDataDocument    m_document;
--- branches/KDE/4.3/kdeedu/marble/src/lib/MarbleGeometryModel.cpp #995518:995519
@@ -51,11 +51,11 @@
         if( !geometry ) return;
 
         GeoDataMultiGeometry* multiGeometry = static_cast<GeoDataMultiGeometry*>( geometry );
-        QVector<GeoDataGeometry>::iterator iterator = multiGeometry->begin();
-        QVector<GeoDataGeometry>::iterator end = multiGeometry->end();
+        QVector<GeoDataGeometry>::iterator iterator = multiGeometry->vector().begin();
+        QVector<GeoDataGeometry>::iterator end = multiGeometry->vector().end();
         for(; iterator != end; ++iterator ) {
-            m_parent.insert( &( *iterator ), geometry );
-            if( iterator->geometryId() == GeoDataMultiGeometryId ) mapGeometry( &( *iterator ) );
+            m_parent.insert( iterator, geometry );
+            if( iterator->geometryId() == GeoDataMultiGeometryId ) mapGeometry( iterator );
         }
     };
 
--- branches/KDE/4.3/kdeedu/marble/src/lib/MarbleModel.cpp #995518:995519
@@ -93,8 +93,7 @@
 
     void resize( int width, int height );
     void notifyModelChanged();
-    void geoDataDocumentLoaded( GeoDataDocument& document );
-    void geoDataDocumentAdded( GeoDataDocument* document );
+    void geoDataDocumentAdded( const GeoDataDocument& document );
 
     static QAtomicInt       refCounter;
     MarbleModel             *m_parent;
@@ -174,10 +173,8 @@
 
     d->m_placemarkmanager = new PlacemarkManager();
 
-    connect( d->m_placemarkmanager, SIGNAL( geoDataDocumentLoaded( GeoDataDocument& ) ),
-             this,                  SLOT( geoDataDocumentLoaded( GeoDataDocument& ) ) );
-    connect( d->m_placemarkmanager, SIGNAL( geoDataDocumentAdded( GeoDataDocument* ) ),
-             this,                  SLOT( geoDataDocumentAdded( GeoDataDocument* ) ) );
+    connect( d->m_placemarkmanager, SIGNAL( geoDataDocumentAdded( const GeoDataDocument& ) ),
+             this,                  SLOT( geoDataDocumentAdded( const GeoDataDocument& ) ) );
 
     d->m_placemarkmodel = new MarblePlacemarkModel( d->m_placemarkmanager, this );
     d->m_popSortModel = new QSortFilterProxyModel( this );
@@ -425,6 +422,7 @@
                 GeoSceneAbstractDataset* dataset = *itds;
                 if( dataset->fileFormat() == "KML" ) {
                     QString containername = reinterpret_cast<GeoSceneXmlDataSource*>(dataset)->filename();
+                    if( containername.endsWith(".kml") ) containername.remove(".kml");
                     loadedContainers.removeOne( containername );
                     loadList << containername;          
                 }
@@ -483,6 +481,7 @@
     d->m_layerManager->syncViewParamsAndPlugins( mapTheme );
 
     d->notifyModelChanged();
+    d->m_placemarkLayout->requestStyleReset();
 }
 
 void MarbleModel::setupTextureMapper( Projection projection )
@@ -722,14 +721,9 @@
     emit m_parent->modelChanged();
 }
 
-void MarbleModelPrivate::geoDataDocumentLoaded( GeoDataDocument& document )
+void MarbleModelPrivate::geoDataDocumentAdded( const GeoDataDocument& document )
 {
-    new KmlFileViewItem( *m_placemarkmanager, document );
-}
-
-void MarbleModelPrivate::geoDataDocumentAdded( GeoDataDocument* document )
-{
-    QVector<GeoDataFeature>::Iterator end = document->end();
+/*    QVector<GeoDataFeature>::Iterator end = document->end();
     QVector<GeoDataFeature>::Iterator itr = document->begin();
     for ( ; itr != end; ++itr ) {
         // use *itr (or itr.value()) here
@@ -737,7 +731,7 @@
         itr->setStyle( &document->style( styleUrl ) );
     }
 
-    m_geometrymodel->setGeoDataRoot( document );
+    m_geometrymodel->setGeoDataRoot( document );*/
 }
 
 void MarbleModel::update()
--- branches/KDE/4.3/kdeedu/marble/src/lib/MarbleModel.h #995518:995519
@@ -350,8 +350,7 @@
     MarbleModelPrivate  * const d;
 
     Q_PRIVATE_SLOT( d, void notifyModelChanged() )
-    Q_PRIVATE_SLOT( d, void geoDataDocumentLoaded( GeoDataDocument& ) )
-    Q_PRIVATE_SLOT( d, void geoDataDocumentAdded( GeoDataDocument* ) )
+    Q_PRIVATE_SLOT( d, void geoDataDocumentAdded( const GeoDataDocument& ) )
 };
 
 }
--- branches/KDE/4.3/kdeedu/marble/src/lib/PlacemarkLoader.cpp #995518:995519
@@ -183,7 +183,7 @@
 
     qDebug() << "newGeoDataDocumentAdded" << m_filepath;
 
-    emit newGeoDataDocumentAdded( *m_document );
+    emit newGeoDataDocumentAdded( m_document );
 }
 
 void PlacemarkLoader::importKmlFromData( PlacemarkContainer* placemarkContainer )
@@ -211,7 +211,7 @@
 
     qDebug() << "newGeoDataDocumentAdded" << m_filepath;
     
-    emit newGeoDataDocumentAdded( *m_document );
+    emit newGeoDataDocumentAdded( m_document );
 }
 
 void PlacemarkLoader::saveFile( const QString& filename,
@@ -325,7 +325,7 @@
 
     qDebug() << "newGeoDataDocumentAdded" << m_filepath;
 	m_document->setVisible( false );
-    emit newGeoDataDocumentAdded( *m_document );
+    emit newGeoDataDocumentAdded( m_document );
     return true;
 }
 
--- branches/KDE/4.3/kdeedu/marble/src/lib/PlacemarkLoader.h #995518:995519
@@ -32,7 +32,7 @@
     Q_SIGNALS:
         void placemarksLoaded( PlacemarkLoader*, PlacemarkContainer * );
         void placemarkLoaderFailed( PlacemarkLoader* );
-        void newGeoDataDocumentAdded( const GeoDataDocument& );
+        void newGeoDataDocumentAdded( GeoDataDocument* );
     private:
         bool loadFile( const QString& filename, PlacemarkContainer* placemarkContainer );
         void saveFile( const QString& filename, PlacemarkContainer* placemarkContainer );
--- branches/KDE/4.3/kdeedu/marble/src/lib/PlacemarkManager.cpp #995518:995519
@@ -134,23 +134,35 @@
                     this, SLOT( loadPlacemarkContainer( PlacemarkLoader*, PlacemarkContainer * ) ) );
         connect (   loader, SIGNAL( placemarkLoaderFailed( PlacemarkLoader* ) ), 
                     this, SLOT( cleanupLoader( PlacemarkLoader* ) ) );
-        connect (   loader, SIGNAL( newGeoDataDocumentAdded( GeoDataDocument ) ), 
-                    this, SIGNAL( geoDataDocumentAdded( GeoDataDocument ) ) );
-        connect (   loader, SIGNAL( newGeoDataDocumentAdded( GeoDataDocument ) ), 
-                    this, SLOT( addGeoDataDocument( GeoDataDocument ) ) );
+        connect (   loader, SIGNAL( newGeoDataDocumentAdded( GeoDataDocument* ) ), 
+                    this, SLOT( addGeoDataDocument( GeoDataDocument* ) ) );
         d->m_loaderList.append( loader );
         d->m_pathList.append( toRegularName( filepath ) );
         loader->start();
     }
 }
 
-void PlacemarkManager::addGeoDataDocument( GeoDataDocument const & document )
+void PlacemarkManager::addGeoDataDocument( GeoDataDocument* document )
 {
-    AbstractFileViewItem* item = new KmlFileViewItem( *this,
-                                                      document );
+    AbstractFileViewItem* item = new KmlFileViewItem( *this, *document );
 
     d->m_fileViewModel->append( item );
-//    d->m_geomodel->setGeoDataRoot( document );
+
+// now get the document that will be preserved throughout the life time
+    GeoDataDocument* doc = dynamic_cast<KmlFileViewItem*>(item)->document();
+    // remove the hashes in front of the styles.
+    QVector<GeoDataFeature>::Iterator end = doc->end();
+    QVector<GeoDataFeature>::Iterator itr = doc->begin();
+    for ( ; itr != end; ++itr ) {
+        // use *itr (or itr.value()) here
+        QString styleUrl = itr->styleUrl().remove('#');
+        itr->setStyle( &doc->style( styleUrl ) );
+    }
+
+    // do not set this file if it only contains points
+    if( doc->isVisible() )
+        d->m_geomodel->setGeoDataRoot( doc );
+    emit geoDataDocumentAdded( *doc );
 }
 
 void PlacemarkManager::addPlacemarkData( const QString& data, const QString& key )
@@ -166,6 +178,7 @@
     {
         if( toRegularName( nkey ) == toRegularName( d->m_fileViewModel->data(d->m_fileViewModel->index(i, 0)).toString() ) ) {
             d->m_fileViewModel->remove(d->m_fileViewModel->index(i, 0));
+            break;
         }
     };
 }
@@ -221,8 +234,6 @@
     connect (   loader, SIGNAL( placemarkLoaderFailed( PlacemarkLoader* ) ), 
                 this, SLOT( cleanupLoader( PlacemarkLoader* ) ) );
     connect (   loader, SIGNAL( newGeoDataDocumentAdded( GeoDataDocument* ) ), 
-                this, SIGNAL( geoDataDocumentAdded( GeoDataDocument* ) ) );
-    connect (   loader, SIGNAL( newGeoDataDocumentAdded( GeoDataDocument* ) ), 
                 this, SLOT( addGeoDataDocument( GeoDataDocument* ) ) );
     d->m_loaderList.append( loader );
     loader->start();
--- branches/KDE/4.3/kdeedu/marble/src/lib/PlacemarkManager.h #995518:995519
@@ -117,13 +117,12 @@
 
  Q_SIGNALS:
     void geoDataDocumentAdded( const GeoDataDocument& );
-    void geoDataDocumentLoaded( const GeoDataDocument& );
     void finalize();
 
  private Q_SLOTS:
     void loadPlacemarkContainer( PlacemarkLoader* loader, PlacemarkContainer * );
     void cleanupLoader( PlacemarkLoader* loader );
-    void addGeoDataDocument( const GeoDataDocument& );
+    void addGeoDataDocument( GeoDataDocument* );
 
  private:
     void setPlacemarkModel( MarblePlacemarkModel *model );
--- branches/KDE/4.3/kdeedu/marble/src/plugins/render/geodata/GeoRendererView.cpp #995518:995519
@@ -206,16 +206,19 @@
     if( object->geometryId() == GeoDataPolygonId ) {
         setBrushStyle( mapped );
         setPenStyle( mapped );
-        m_painter->drawPolygon( *static_cast<GeoDataPolygon*>( object ) );
+        GeoDataPolygon polygon( *static_cast<GeoDataPolygon*>( object ) );
+        m_painter->drawPolygon( polygon );
     }
     if( object->geometryId() == GeoDataLinearRingId ) {
         m_painter->setBrush( QColor( 0, 0, 0, 0 ) );
         setPenStyle( mapped );
-        m_painter->drawPolygon( *static_cast<GeoDataLinearRing*>( object ) );
+        GeoDataLinearRing linearRing( *static_cast<GeoDataLinearRing*>( object ) );
+        m_painter->drawPolygon( linearRing );
     }
     if( object->geometryId() == GeoDataLineStringId ) {
         setPenStyle( mapped );
-        m_painter->drawPolyline( *static_cast<GeoDataLineString*>( object ) );
+        GeoDataLineString lineString( *static_cast<GeoDataLineString*>( object ) );
+        m_painter->drawPolyline( lineString );
     }
     /* Note: GeoDataMultiGeometry is handled within the model */
     m_painter->restore();


More information about the Marble-commits mailing list