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

Bernhard Beschow bbeschow at cs.tu-berlin.de
Wed Mar 30 16:37:44 CEST 2011


SVN commit 1226566 by beschow:

move all attributes of MarbledataFacade into MarbleModel

* forward in MarbledataFacade rather than in MarbleModel

 M  +12 -24    FileManager.cpp  
 M  +2 -8      FileManager.h  
 M  +1 -0      FileViewWidget.cpp  
 M  +6 -38     MarbleDataFacade.cpp  
 M  +1 -3      MarbleDataFacade.h  
 M  +1 -1      MarbleMap.cpp  
 M  +35 -8     MarbleModel.cpp  
 M  +5 -0      MarbleModel.h  
 M  +2 -2      PlacemarkLayout.h  


--- trunk/KDE/kdeedu/marble/src/lib/FileManager.cpp #1226565:1226566
@@ -18,7 +18,7 @@
 #include "FileLoader.h"
 #include "FileViewModel.h"
 #include "MarbleDebug.h"
-#include "MarbleDataFacade.h"
+#include "MarbleModel.h"
 #include "GeoDataTreeModel.h"
 
 #include "GeoDataDocument.h"
@@ -31,13 +31,13 @@
 class FileManagerPrivate
 {
 public:
-    FileManagerPrivate( )
-        : m_datafacade( 0 ),
+    FileManagerPrivate( MarbleModel* model )
+        : m_model( model ),
         m_t ( 0 )
     {
     }
 
-    MarbleDataFacade* m_datafacade;
+    MarbleModel* const m_model;
     QList<FileLoader*> m_loaderList;
     QStringList m_pathList;
     QList < GeoDataDocument* > m_fileItemList;
@@ -45,9 +45,9 @@
 };
 }
 
-FileManager::FileManager( QObject *parent )
+FileManager::FileManager( MarbleModel *model, QObject *parent )
     : QObject( parent )
-    , d( new FileManagerPrivate() )
+    , d( new FileManagerPrivate( model ) )
 {
 }
 
@@ -63,18 +63,6 @@
     delete d;
 }
 
-void FileManager::setDataFacade( MarbleDataFacade *facade )
-{
-    d->m_datafacade = facade;
-    d->m_datafacade->fileViewModel()->setFileManager( this );
-    d->m_datafacade->treeModel()->setFileManager( this );
-}
-
-MarbleDataFacade *FileManager::dataFacade()
-{
-    return d->m_datafacade;
-}
-
 QStringList FileManager::containers() const
 {
     QStringList retList;
@@ -88,8 +76,8 @@
 {
     if ( !containers().contains( filepath ) ) {
         mDebug() << "adding container:" << filepath;
-        if ( d->m_datafacade ) {
-            d->m_datafacade->connectTree( false );
+        if ( d->m_model ) {
+            d->m_model->connectTree( false );
         }
         if (d->m_t == 0) {
             mDebug() << "Starting placemark loading timer";
@@ -104,8 +92,8 @@
 
 void FileManager::addData( const QString &name, const QString &data )
 {
-    if ( d->m_datafacade ) {
-        d->m_datafacade->connectTree( false );
+    if ( d->m_model ) {
+        d->m_model->connectTree( false );
     }
     FileLoader* loader = new FileLoader( this, data, name );
     appendLoader( loader );
@@ -185,8 +173,8 @@
         mDebug() << "Empty loader list, connecting";
         QTime t;
         t.start();
-        if ( d->m_datafacade ) {
-            d->m_datafacade->connectTree( true );
+        if ( d->m_model ) {
+            d->m_model->connectTree( true );
         }
         mDebug() << "Done " << t.elapsed() << " ms";
         qDebug() << "Finished loading all placemarks " << d->m_t->elapsed();
--- trunk/KDE/kdeedu/marble/src/lib/FileManager.h #1226565:1226566
@@ -19,6 +19,7 @@
 namespace Marble
 {
 
+class MarbleModel;
 class FileManagerPrivate;
 class GeoDataDocument;
 class MarbleDataFacade;
@@ -41,7 +42,7 @@
      *
      * @param parent The parent object.
      */
-    explicit FileManager( QObject *parent = 0 );
+    FileManager( MarbleModel *model,  QObject *parent = 0 );
 
     /**
      * Destroys the file manager.
@@ -49,13 +50,6 @@
     ~FileManager();
 
     /**
-     * Sets the DataFacade from which the models can be accessed.
-     */
-    void setDataFacade ( MarbleDataFacade *facade );
-
-    MarbleDataFacade *dataFacade ();
-
-    /**
      * return a list containing all containers that have been queued for loading or that are
      * loaded already
      */
--- trunk/KDE/kdeedu/marble/src/lib/FileViewWidget.cpp #1226565:1226566
@@ -16,6 +16,7 @@
 
 // Marble
 #include "GeoDataPlacemark.h"
+#include "GeoDataTreeModel.h"
 #include "MarbleModel.h"
 #include "MarbleWidget.h"
 #include "FileViewModel.h"
--- trunk/KDE/kdeedu/marble/src/lib/MarbleDataFacade.cpp #1226565:1226566
@@ -34,7 +34,6 @@
 #include "GeoSceneDocument.h"
 #include "GeoSceneHead.h"
 
-#include "kdescendantsproxymodel.h"
 #include "routing/RoutingManager.h"
 
 namespace Marble
@@ -44,33 +43,11 @@
 {
  public:
     MarbleDataFacadePrivate( MarbleModel *model )
-        : m_model( model ),
-        m_fileviewmodel( new FileViewModel() ),
-        m_treemodel( new GeoDataTreeModel),
-        m_descendantproxy( new KDescendantsProxyModel ),
-        m_sortproxy( new QSortFilterProxyModel ),
-        m_dummytree( new GeoDataTreeModel )
+        : m_model( model )
     {
-        m_sortproxy->setFilterFixedString( GeoDataTypes::GeoDataPlacemarkType );
-        m_sortproxy->setFilterKeyColumn( 1 );
-        m_sortproxy->setSourceModel( m_descendantproxy );
     }
 
-    ~MarbleDataFacadePrivate()
-    {
-        delete m_fileviewmodel;
-        delete m_treemodel;
-        delete m_descendantproxy;
-        delete m_sortproxy;
-        delete m_dummytree;
-    }
-
-    MarbleModel  *m_model;
-    FileViewModel *m_fileviewmodel;
-    GeoDataTreeModel *m_treemodel;
-    KDescendantsProxyModel *m_descendantproxy;
-    QSortFilterProxyModel  *m_sortproxy;
-    GeoDataTreeModel *m_dummytree;
+    MarbleModel  *const m_model;
 };
 
 
@@ -117,12 +94,12 @@
 
 QAbstractItemModel* MarbleDataFacade::placemarkModel()
 {
-    return d->m_sortproxy;
+    return d->m_model->placemarkModel();
 }
 
 FileViewModel* MarbleDataFacade::fileViewModel() const
 {
-    return d->m_fileviewmodel;
+    return d->m_model->fileViewModel();
 }
 
 PluginManager* MarbleDataFacade::pluginManager()
@@ -135,19 +112,10 @@
     return d->m_model->routingManager();
 }
 
-GeoDataTreeModel* MarbleDataFacade::treeModel() const
+QAbstractItemModel* MarbleDataFacade::treeModel() const
 {
-    return d->m_treemodel;
+    return d->m_model->treeModel();
 }
 
-void MarbleDataFacade::connectTree(bool connect) const
-{
-    if ( connect ) {
-        d->m_descendantproxy->setSourceModel( d->m_treemodel );
-    } else {
-        d->m_descendantproxy->setSourceModel( d->m_dummytree );
     }
-}
 
-}
-
--- trunk/KDE/kdeedu/marble/src/lib/MarbleDataFacade.h #1226565:1226566
@@ -89,10 +89,8 @@
 
     RoutingManager* routingManager();
 
-    GeoDataTreeModel* treeModel() const;
+    QAbstractItemModel* treeModel() const;
 
-    void connectTree(bool connect) const;
-
 private:
     MarbleDataFacadePrivate  * const d;
 };
--- trunk/KDE/kdeedu/marble/src/lib/MarbleMap.cpp #1226565:1226566
@@ -85,7 +85,7 @@
           m_measureTool( model ),
           m_viewAngle( 110.0 )
 {
-    GeoDataObject *object = static_cast<GeoDataObject*>( model->dataFacade()->treeModel()->index(0, 0, QModelIndex()).internalPointer());
+    GeoDataObject *object = static_cast<GeoDataObject*>( model->treeModel()->index(0, 0, QModelIndex()).internalPointer());
     GeoDataDocument *document = dynamic_cast<GeoDataDocument*>( object->parent() );
     m_geometryLayer = new GeometryLayer( document );
     m_layerManager.addLayer( m_geometryLayer );
--- trunk/KDE/kdeedu/marble/src/lib/MarbleModel.cpp #1226565:1226566
@@ -24,6 +24,8 @@
 #include <QtGui/QItemSelectionModel>
 #include <QtGui/QSortFilterProxyModel>
 
+#include "kdescendantsproxymodel.h"
+
 #include "MapThemeManager.h"
 #include "global.h"
 #include "MarbleDebug.h"
@@ -41,6 +43,7 @@
 
 #include "GeoDataDocument.h"
 #include "GeoDataStyle.h"
+#include "GeoDataTypes.h"
 
 #include "DgmlAuxillaryDictionary.h"
 #include "MarbleClock.h"
@@ -88,12 +91,20 @@
                                                                    MarbleDirs::localPath() ),
                                                       m_pluginManager ) ),
           m_fileManager( 0 ),
+          m_fileviewmodel(),
+          m_treemodel(),
+          m_descendantproxy(),
+          m_sortproxy(),
+          m_dummytree(),
           m_placemarkselectionmodel( 0 ),
           m_positionTracking( 0 ),
           m_bookmarkManager( 0 ),
           m_routingManager( 0 ),
           m_legend( 0 )
     {
+        m_sortproxy.setFilterFixedString( GeoDataTypes::GeoDataPlacemarkType );
+        m_sortproxy.setFilterKeyColumn( 1 );
+        m_sortproxy.setSourceModel( &m_descendantproxy );
     }
 
     ~MarbleModelPrivate()
@@ -129,6 +140,12 @@
     // Places on the map
     FileManager             *m_fileManager;
 
+    FileViewModel            m_fileviewmodel;
+    GeoDataTreeModel         m_treemodel;
+    KDescendantsProxyModel   m_descendantproxy;
+    QSortFilterProxyModel    m_sortproxy;
+    GeoDataTreeModel         m_dummytree;
+
     // Selection handling
     QItemSelectionModel      m_placemarkselectionmodel;
 
@@ -148,11 +165,11 @@
     t.start();
 
     d->m_dataFacade = new MarbleDataFacade( this );
-    connect(d->m_dataFacade->treeModel(), SIGNAL( dataChanged(QModelIndex,QModelIndex) ),
+    connect(&d->m_treemodel, SIGNAL( dataChanged(QModelIndex,QModelIndex) ),
             this, SIGNAL( modelChanged() ) );
-    connect(d->m_dataFacade->treeModel(), SIGNAL( layoutChanged() ),
+    connect(&d->m_treemodel, SIGNAL( layoutChanged() ),
             this, SIGNAL( modelChanged() ) );
-    connect(d->m_dataFacade->treeModel(), SIGNAL( modelReset() ),
+    connect(&d->m_treemodel, SIGNAL( modelReset() ),
             this, SIGNAL( modelChanged() ) );
 
     // A new instance of FileStorageWatcher.
@@ -169,8 +186,9 @@
     connect( storagePolicy, SIGNAL( sizeChanged( qint64 ) ),
              d->m_storageWatcher, SLOT( addToCurrentSize( qint64 ) ) );
 
-    d->m_fileManager = new FileManager();
-    d->m_fileManager->setDataFacade(d->m_dataFacade);
+    d->m_fileManager = new FileManager( this );
+    d->m_fileviewmodel.setFileManager( d->m_fileManager );
+    d->m_treemodel.setFileManager( d->m_fileManager );
 
 
     d->m_positionTracking = new PositionTracking( d->m_fileManager, this );
@@ -351,12 +369,12 @@
 
 QAbstractItemModel *MarbleModel::treeModel() const
 {
-    return d->m_dataFacade->treeModel();
+    return &d->m_treemodel;
 }
 
 QAbstractItemModel *MarbleModel::placemarkModel() const
 {
-    return d->m_dataFacade->placemarkModel();
+    return &d->m_sortproxy;
 }
 
 QItemSelectionModel *MarbleModel::placemarkSelectionModel() const
@@ -371,7 +389,7 @@
 
 FileViewModel *MarbleModel::fileViewModel() const
 {
-    return d->m_dataFacade->fileViewModel();
+    return &d->m_fileviewmodel;
 }
 
 void MarbleModel::openGpxFile( const QString& filename )
@@ -501,6 +519,15 @@
     return d->m_planet;
 }
 
+void MarbleModel::connectTree( bool connect ) const
+{
+    if ( connect ) {
+        d->m_descendantproxy.setSourceModel( &d->m_treemodel );
+    } else {
+        d->m_descendantproxy.setSourceModel( &d->m_dummytree );
+    }
+}
+
 void MarbleModel::addDownloadPolicies( GeoSceneDocument *mapTheme )
 {
     if ( !mapTheme )
--- trunk/KDE/kdeedu/marble/src/lib/MarbleModel.h #1226565:1226566
@@ -302,6 +302,11 @@
     Q_DISABLE_COPY( MarbleModel )
     Q_PRIVATE_SLOT( d, void notifyModelChanged() )
 
+    // the following method is a bit of a hack...
+    // make it private and document the class using it:
+    friend class FileManager;
+    void connectTree( bool connect ) const;
+
     void addDownloadPolicies( GeoSceneDocument *mapTheme );
     MarbleModelPrivate  * const d;
 };
--- trunk/KDE/kdeedu/marble/src/lib/PlacemarkLayout.h #1226565:1226566
@@ -22,8 +22,6 @@
 #include <QtCore/QRect>
 #include <QtCore/QVector>
 
-#include "GeoDataPlacemark.h"   // In geodata/data/
-
 class QAbstractItemModel;
 class QSortFilterProxyModel;
 class QItemSelectionModel;
@@ -34,6 +32,8 @@
 namespace Marble
 {
 
+class GeoDataPlacemark;
+class GeoDataStyle;
 class PlacemarkPainter;
 class VisiblePlacemark;
 class ViewParams;


More information about the Marble-commits mailing list