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

Bernhard Beschow bbeschow at cs.tu-berlin.de
Thu Aug 19 11:09:54 CEST 2010


SVN commit 1165398 by beschow:

move implementation of persistant cache limit from MarbleMap to MarbleModel

 M  +3 -36     MarbleMap.cpp  
 M  +0 -6      MarbleMap_p.h  
 M  +41 -1     MarbleModel.cpp  
 M  +14 -0     MarbleModel.h  


--- trunk/KDE/kdeedu/marble/src/lib/MarbleMap.cpp #1165397:1165398
@@ -34,15 +34,12 @@
 #include "AbstractFloatItem.h"
 #include "AbstractProjection.h"
 #include "AbstractScanlineTextureMapper.h"
-#include "FileStorageWatcher.h"
-#include "FileViewModel.h"
 #include "GeoDataFeature.h"
 #include "GeoDataLatLonAltBox.h"
 #include "GeoPainter.h"
 #include "GeoSceneDocument.h"
 #include "GeoSceneHead.h"
 #include "GeoSceneZoom.h"
-#include "HttpDownloadManager.h"
 #include "MarbleDebug.h"
 #include "MarbleDirs.h"
 #include "MarbleLocale.h"
@@ -53,7 +50,6 @@
 #include "PlacemarkLayout.h"
 #include "Planet.h"
 #include "RenderPlugin.h"
-#include "StoragePolicy.h"
 #include "SunLocator.h"
 #include "TextureColorizer.h"
 #include "ViewParams.h"
@@ -71,8 +67,6 @@
 
 MarbleMapPrivate::MarbleMapPrivate( MarbleMap *parent )
         : m_parent( parent ),
-          m_persistentTileCacheLimit( 0 ), // No limit
-          m_volatileTileCacheLimit( 1024*1024*30 ), // 30 MB
           m_viewAngle( 110.0 )
 {
 }
@@ -109,20 +103,6 @@
 
     m_parent->connect( m_model,               SIGNAL( repaintNeeded( QRegion ) ),
                        m_parent,              SIGNAL( repaintNeeded( QRegion ) ) );
-
-    // A new instance of FileStorageWatcher.
-    // The thread will be started at setting persistent tile cache size.
-    m_storageWatcher = new FileStorageWatcher( MarbleDirs::localPath(), m_parent );
-    m_parent->connect( m_parent, SIGNAL( themeChanged( QString ) ),
-		       m_storageWatcher, SLOT( updateTheme( QString ) ) );
-    // Setting the theme to the current theme.
-    m_storageWatcher->updateTheme( m_parent->mapThemeId() );
-    // connect the StoragePolicy used by the download manager to the FileStorageWatcher
-    StoragePolicy * const storagePolicy = m_model->downloadManager()->storagePolicy();
-    QObject::connect( storagePolicy, SIGNAL( cleared() ),
-                      m_storageWatcher, SLOT( resetCurrentSize() ) );
-    QObject::connect( storagePolicy, SIGNAL( sizeChanged( qint64 ) ),
-                      m_storageWatcher, SLOT( addToCurrentSize( qint64 ) ) );
 }
 
 // Used to be resizeEvent()
@@ -679,12 +659,12 @@
 
 quint64 MarbleMap::persistentTileCacheLimit() const
 {
-    return d->m_persistentTileCacheLimit;
+    return d->m_model->persistentTileCacheLimit();
 }
 
 quint64 MarbleMap::volatileTileCacheLimit() const
 {
-    return d->m_volatileTileCacheLimit;
+    return d->m_model->volatileTileCacheLimit();
 }
 
 void MarbleMap::zoomView( int newZoom )
@@ -1116,20 +1096,8 @@
 
 void MarbleMap::setPersistentTileCacheLimit( quint64 kiloBytes )
 {
-    d->m_persistentTileCacheLimit = kiloBytes;
-    d->m_storageWatcher->setCacheLimit( kiloBytes * 1024 );
-    
-    if( kiloBytes != 0 )
-    {
-	if( !d->m_storageWatcher->isRunning() )
-	    d->m_storageWatcher->start( QThread::IdlePriority );
+    d->m_model->setPersistentTileCacheLimit( kiloBytes );
     }
-    else
-    {
-	d->m_storageWatcher->quit();
-    }
-    // TODO: trigger update
-}
 
 void MarbleMap::clearVolatileTileCache()
 {
@@ -1139,7 +1107,6 @@
 void MarbleMap::setVolatileTileCacheLimit( quint64 kilobytes )
 {
     mDebug() << "kiloBytes" << kilobytes;
-    d->m_volatileTileCacheLimit = kilobytes;
     d->m_model->setVolatileTileCacheLimit( kilobytes );
 }
 
--- trunk/KDE/kdeedu/marble/src/lib/MarbleMap_p.h #1165397:1165398
@@ -22,7 +22,6 @@
 namespace Marble
 {
 
-class FileStorageWatcher;
 class MarbleMap;
 class MarbleModel;
 class TextureColorizer;
@@ -80,11 +79,6 @@
     // Tools
     MeasureTool     *m_measureTool;
 
-    // Cache related
-    FileStorageWatcher  *m_storageWatcher;
-    quint64          m_persistentTileCacheLimit;
-    quint64          m_volatileTileCacheLimit;
-
     const qreal      m_viewAngle;
 
 };
--- trunk/KDE/kdeedu/marble/src/lib/MarbleModel.cpp #1165397:1165398
@@ -45,6 +45,7 @@
 #include "DgmlAuxillaryDictionary.h"
 #include "MarbleClock.h"
 #include "FileStoragePolicy.h"
+#include "FileStorageWatcher.h"
 #include "GeoPainter.h"
 #include "FileViewModel.h"
 #include "SphericalScanlineTextureMapper.h"
@@ -134,8 +135,11 @@
     static TextureColorizer *m_texcolorizer; //left as null if unused
 
     HttpDownloadManager     *m_downloadManager;
+    StackedTileLoader       *m_tileLoader;
 
-    StackedTileLoader       *m_tileLoader;
+    // Cache related
+    FileStorageWatcher      *m_storageWatcher;
+
     AbstractScanlineTextureMapper   *m_texmapper;
 
     static VectorComposer   *m_veccomposer; // FIXME: Make not a pointer.
@@ -195,6 +199,21 @@
 
     d->m_tileLoader = new StackedTileLoader( d->m_mapThemeManager, d->textureLayerProperties(),
                                              d->m_downloadManager, this );
+
+    // A new instance of FileStorageWatcher.
+    // The thread will be started at setting persistent tile cache size.
+    d->m_storageWatcher = new FileStorageWatcher( MarbleDirs::localPath(), this );
+    connect( this, SIGNAL( themeChanged( QString ) ),
+             d->m_storageWatcher, SLOT( updateTheme( QString ) ) );
+    // Setting the theme to the current theme.
+    d->m_storageWatcher->updateTheme( mapThemeId() );
+    // connect the StoragePolicy used by the download manager to the FileStorageWatcher
+    StoragePolicy * const storagePolicy = d->m_downloadManager->storagePolicy();
+    connect( storagePolicy, SIGNAL( cleared() ),
+             d->m_storageWatcher, SLOT( resetCurrentSize() ) );
+    connect( storagePolicy, SIGNAL( sizeChanged( qint64 ) ),
+             d->m_storageWatcher, SLOT( addToCurrentSize( qint64 ) ) );
+
     d->m_texmapper = 0;
 
     d->m_fileManager = new FileManager();
@@ -868,6 +887,11 @@
     return d->m_layerDecorator;
 }
 
+quint64 MarbleModel::persistentTileCacheLimit() const
+{
+    return d->m_storageWatcher->cacheLimit() / 1024;
+}
+
 void MarbleModel::clearVolatileTileCache()
 {
     d->m_tileLoader->update();
@@ -928,6 +952,22 @@
     }
 }
 
+void MarbleModel::setPersistentTileCacheLimit(quint64 kiloBytes)
+{
+    d->m_storageWatcher->setCacheLimit( kiloBytes * 1024 );
+
+    if( kiloBytes != 0 )
+    {
+        if( !d->m_storageWatcher->isRunning() )
+            d->m_storageWatcher->start( QThread::IdlePriority );
+    }
+    else
+    {
+        d->m_storageWatcher->quit();
+    }
+    // TODO: trigger update
+}
+
 void MarbleModel::paintTile( StackedTile* tile, const GeoSceneTexture *textureLayer )
 {
 //    mDebug() << "MarbleModel::paintTile: " << "x: " << x << "y:" << y << "level: " << level
--- trunk/KDE/kdeedu/marble/src/lib/MarbleModel.h #1165397:1165398
@@ -229,7 +229,14 @@
     SunLocator*           sunLocator()     const;
     MergedLayerDecorator* layerDecorator() const;
 
+
     /**
+     * @brief  Returns the limit in kilobytes of the persistent (on hard disc) tile cache.
+     * @return the limit of persistent tile cache in kilobytes.
+     */
+    quint64 persistentTileCacheLimit() const;
+
+    /**
      * @brief  Returns the limit of the volatile (in RAM) tile cache.
      * @return the cache limit in kilobytes
      */
@@ -303,6 +310,7 @@
     BookmarkManager *bookmarkManager() const;
  public Q_SLOTS:
     void clearVolatileTileCache();
+
     /**
      * @brief Set the limit of the volatile (in RAM) tile cache.
      * @param kilobytes The limit in kilobytes.
@@ -311,6 +319,12 @@
 
     void clearPersistentTileCache();
 
+    /**
+     * @brief  Set the limit of the persistent (on hard disc) tile cache.
+     * @param  bytes The limit in kilobytes, 0 means no limit.
+     */
+    void setPersistentTileCacheLimit( quint64 kiloBytes );
+
     void paintTile( StackedTile* tile, const GeoSceneTexture *textureLayer );
 
     /**


More information about the Marble-commits mailing list