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

Jens-Michael Hoffmann jensmh at gmx.de
Tue Apr 20 22:56:46 CEST 2010


SVN commit 1117009 by jmhoffmann:

Add DownloadUsage parameter to StackedTileLoader/TileLoder methods
which deal with downloading tiles.

This is needed for "Download region".

 M  +5 -3      AbstractScanlineTextureMapper.cpp  
 M  +4 -1      MarbleModel.cpp  
 M  +1 -1      MergedLayerDecorator.cpp  
 M  +12 -8     StackedTileLoader.cpp  
 M  +4 -3      StackedTileLoader.h  
 M  +13 -9     TileLoader.cpp  
 M  +6 -4      TileLoader.h  


--- trunk/KDE/kdeedu/marble/src/lib/AbstractScanlineTextureMapper.cpp #1117008:1117009
@@ -529,7 +529,8 @@
     int tileCol = lon / m_tileSize.width();
     int tileRow = lat / m_tileSize.height();
 
-    m_tile = m_tileLoader->loadTile( TileId( m_mapThemeIdHash, m_tileLevel, tileCol, tileRow ));
+    m_tile = m_tileLoader->loadTile( TileId( m_mapThemeIdHash, m_tileLevel, tileCol, tileRow ),
+                                     DownloadBrowse );
     m_tile->setUsed( true );
 
     // Update position variables:
@@ -565,7 +566,8 @@
     int tileCol = lon / m_tileSize.width();
     int tileRow = lat / m_tileSize.height();
 
-    m_tile = m_tileLoader->loadTile( TileId( m_mapThemeIdHash, m_tileLevel, tileCol, tileRow ));
+    m_tile = m_tileLoader->loadTile( TileId( m_mapThemeIdHash, m_tileLevel, tileCol, tileRow ),
+                                     DownloadBrowse );
     m_tile->setUsed( true );
 
     // Update position variables:
@@ -615,7 +617,7 @@
     Q_ASSERT( m_textureLayer );
     Q_ASSERT( m_tileLoader );
     TileId id( m_textureLayer->sourceDir(), 0, 0, 0 );
-    StackedTile * const testTile = m_tileLoader->loadTile( id );
+    StackedTile * const testTile = m_tileLoader->loadTile( id, DownloadBrowse );
     Q_ASSERT( testTile );
     m_tileSize = testTile->resultTile()->size();
     Q_ASSERT( !m_tileSize.isEmpty() );
--- trunk/KDE/kdeedu/marble/src/lib/MarbleModel.cpp #1117008:1117009
@@ -916,7 +916,10 @@
     QList<TileId>::const_iterator pos = displayed.constBegin();
     QList<TileId>::const_iterator const end = displayed.constEnd();
     for (; pos != end; ++pos ) {
-        d->m_tileLoader->reloadTile( *pos );
+        // it's debatable here, whether DownloadBulk or DownloadBrowse should be used
+        // but since "reload" or "refresh" seems to be a common action of a browser and it
+        // allows for more connections (in our model), use "DownloadBrowse"
+        d->m_tileLoader->reloadTile( *pos, DownloadBrowse );
     }
 }
 
--- trunk/KDE/kdeedu/marble/src/lib/MergedLayerDecorator.cpp #1117008:1117009
@@ -100,7 +100,7 @@
 StackedTile * MergedLayerDecorator::loadDataset( GeoSceneTexture *textureLayer )
 {
     const TileId decorationTileId( textureLayer->sourceDir(), m_id.zoomLevel(), m_id.x(), m_id.y());
-    StackedTile * const tile = m_tileLoader->loadTile( decorationTileId, true );
+    StackedTile * const tile = m_tileLoader->loadTile( decorationTileId, DownloadBrowse, true );
     tile->setUsed( true );
     return tile;
 }
--- trunk/KDE/kdeedu/marble/src/lib/StackedTileLoader.cpp #1117008:1117009
@@ -175,7 +175,7 @@
     d->m_tilesOnDisplay.clear();
 }
 
-StackedTile* StackedTileLoader::loadTile( TileId const & stackedTileId,
+StackedTile* StackedTileLoader::loadTile( TileId const & stackedTileId, DownloadUsage const usage,
                                           bool const forMergedLayerDecorator )
 {
     // check if the tile is in the hash
@@ -221,7 +221,8 @@
                              stackedTileId.x(), stackedTileId.y() );
         mDebug() << "StackedTileLoader::loadTile: tile" << textureLayer->sourceDir()
                  << tileId.toString();
-        QSharedPointer<TextureTile> const tile = d->m_tileLoader->loadTile( stackedTileId, tileId );
+        QSharedPointer<TextureTile> const tile = d->m_tileLoader->loadTile( stackedTileId, tileId,
+                                                                            usage );
         if ( tile ) {
             tile->setBlending( textureLayer->blending() );
             stackedTile->addTile( tile );
@@ -240,11 +241,12 @@
 // 1) in the "hash" (m_tilesOnDisplay), which means it is currently displayed
 // 2) not in the hash, but in the "cache", which means it is not currently displayed
 // 3) neither in "hash" nor in "cache"
-StackedTile* StackedTileLoader::reloadTile( TileId const & stackedTileId )
+StackedTile* StackedTileLoader::reloadTile( TileId const & stackedTileId,
+                                            DownloadUsage const usage )
 {
     StackedTile * const displayedTile = d->m_tilesOnDisplay.value( stackedTileId, 0 );
     if ( displayedTile ) {
-        reloadCachedTile( displayedTile );
+        reloadCachedTile( displayedTile, usage );
         return displayedTile;
     }
     StackedTile * const cachedTile = d->m_tileCache.object( stackedTileId );
@@ -256,7 +258,7 @@
         // So, all in all it might be better to take the tile out of the cache before calling
         // reloadCachedTile and put it in again afterwards.
         // FIXME: discuss/decide
-        reloadCachedTile( cachedTile );
+        reloadCachedTile( cachedTile, usage );
         return cachedTile;
     }
 
@@ -270,7 +272,8 @@
         GeoSceneTexture const * const textureLayer = *pos;
         TileId const tileId( textureLayer->sourceDir(), stackedTileId.zoomLevel(),
                              stackedTileId.x(), stackedTileId.y() );
-        QSharedPointer<TextureTile> const tile = d->m_tileLoader->reloadTile( stackedTileId, tileId );
+        QSharedPointer<TextureTile> const tile = d->m_tileLoader->reloadTile( stackedTileId, tileId,
+                                                                              usage );
         if ( tile ) {
             tile->setBlending( textureLayer->blending() );
             stackedTile->addTile( tile );
@@ -506,14 +509,15 @@
 // This method should not alter m_tileCache, as the given tile is managed
 // by the cache and may be evicted at any time (that is usually when inserting
 // other tiles in the cache)
-void StackedTileLoader::reloadCachedTile( StackedTile * const cachedTile )
+void StackedTileLoader::reloadCachedTile( StackedTile * const cachedTile,
+                                          DownloadUsage const usage )
 {
     Q_ASSERT( cachedTile );
     QVector<QSharedPointer<TextureTile> > * tiles = cachedTile->tiles();
     QVector<QSharedPointer<TextureTile> >::const_iterator pos = tiles->constBegin();
     QVector<QSharedPointer<TextureTile> >::const_iterator const end = tiles->constEnd();
     for (; pos != end; ++pos ) {
-        d->m_tileLoader->reloadTile( *pos );
+        d->m_tileLoader->reloadTile( *pos, usage );
     }
     cachedTile->deriveCompletionState();
     cachedTile->initResultTile();
--- trunk/KDE/kdeedu/marble/src/lib/StackedTileLoader.h #1117008:1117009
@@ -27,6 +27,7 @@
 #include <QtCore/QObject>
 
 #include "TileId.h"
+#include "global.h"
 
 class QString;
 
@@ -85,10 +86,10 @@
          * @param stackedTileId The Id of the requested tile, containing the x and y coordinate
          *                      and the zoom level.
          */
-        StackedTile* loadTile( TileId const &stackedTileId,
+        StackedTile* loadTile( TileId const &stackedTileId, DownloadUsage const,
                                bool const forMergedLayerDecorator = false );
 
-        StackedTile* reloadTile( TileId const & stackedTileId );
+        StackedTile* reloadTile( TileId const & stackedTileId, DownloadUsage const );
 
         /**
          * Resets the internal tile hash.
@@ -171,7 +172,7 @@
         QVector<GeoSceneTexture const *>
             findRelevantTextureLayers( TileId const & stackedTileId ) const;
         void mergeDecorations( StackedTile * const, GeoSceneTexture * const ) const;
-        void reloadCachedTile( StackedTile * const cachedTile );
+        void reloadCachedTile( StackedTile * const cachedTile, DownloadUsage const );
 
         StackedTileLoaderPrivate* const d;
         MarbleModel* m_parent;
--- trunk/KDE/kdeedu/marble/src/lib/TileLoader.cpp #1117008:1117009
@@ -42,7 +42,9 @@
 //     - if not expired: create TextureTile, set state to "uptodate", return it => done
 //     - if expired: create TextureTile, state is set to Expired by default, trigger dl,
 
-QSharedPointer<TextureTile> TileLoader::loadTile( TileId const & stackedTileId, TileId const & tileId )
+QSharedPointer<TextureTile> TileLoader::loadTile( TileId const & stackedTileId,
+                                                  TileId const & tileId,
+                                                  DownloadUsage const usage )
 {
     QString const fileName = tileFileName( tileId );
     QFileInfo const fileInfo( fileName );
@@ -61,7 +63,7 @@
         } else {
             mDebug() << "TileLoader::loadTile" << tileId.toString() << "StateExpired";
             m_waitingForUpdate.insert( tileId, tile );
-            triggerDownload( tileId );
+            triggerDownload( tileId, usage );
         }
         return tile;
     }
@@ -71,7 +73,7 @@
     QSharedPointer<TextureTile> const tile( new TextureTile( tileId ));
     tile->setStackedTileId( stackedTileId );
     m_waitingForUpdate.insert( tileId, tile );
-    triggerDownload( tileId );
+    triggerDownload( tileId, usage );
     QImage * const replacementTile = scaledLowerLevelTile( tileId );
     if ( replacementTile ) {
         mDebug() << "TileLoader::loadTile" << tileId.toString() << "StateScaled";
@@ -93,7 +95,9 @@
 // post condition
 //     - tile object is being returned, with download triggered,
 //       pointer is kept in m_waitingForUpdate until tile is downloaded
-QSharedPointer<TextureTile> TileLoader::reloadTile( TileId const & stackedTileId, TileId const & tileId )
+QSharedPointer<TextureTile> TileLoader::reloadTile( TileId const & stackedTileId,
+                                                    TileId const & tileId,
+                                                    DownloadUsage const usage )
 {
     QSharedPointer<TextureTile> tile =
         m_waitingForUpdate.value( tileId, QSharedPointer<TextureTile>() );
@@ -121,7 +125,7 @@
     tile->setExpireSecs( textureLayer->expire() );
     tile->setStackedTileId( stackedTileId );
     m_waitingForUpdate.insert( tileId, tile );
-    triggerDownload( tileId );
+    triggerDownload( tileId, usage );
     return tile;
 }
 
@@ -132,13 +136,13 @@
 // post condition
 //     - download is triggered, but only if not in progress (indicated by
 //       m_waitingForUpdate)
-void TileLoader::reloadTile( QSharedPointer<TextureTile> const & tile )
+void TileLoader::reloadTile( QSharedPointer<TextureTile> const & tile, DownloadUsage const usage )
 {
     if ( m_waitingForUpdate.contains( tile->id() ))
         return;
     tile->setState( TextureTile::StateExpired );
     m_waitingForUpdate.insert( tile->id(), tile );
-    triggerDownload( tile->id() );
+    triggerDownload( tile->id(), usage );
 }
 
 void TileLoader::updateTile( QByteArray const & data, QString const & tileId )
@@ -179,14 +183,14 @@
                              ( textureLayer, tileId.zoomLevel(), tileId.x(), tileId.y() ));
 }
 
-void TileLoader::triggerDownload( TileId const & id )
+void TileLoader::triggerDownload( TileId const & id, DownloadUsage const usage )
 {
     GeoSceneTexture * const textureLayer = findTextureLayer( id );
     QUrl const sourceUrl = TileLoaderHelper::downloadUrl( textureLayer, id.zoomLevel(), id.x(),
                                                           id.y() );
     QString const destFileName = TileLoaderHelper::relativeTileFileName( textureLayer, id.zoomLevel(),
                                                                          id.x(), id.y() );
-    emit downloadTile( sourceUrl, destFileName, id.toString(), DownloadBrowse );
+    emit downloadTile( sourceUrl, destFileName, id.toString(), usage );
 }
 
     // TODO: get lastModified time stamp into the TextureTile
--- trunk/KDE/kdeedu/marble/src/lib/TileLoader.h #1117008:1117009
@@ -42,9 +42,11 @@
  public:
     TileLoader( MapThemeManager const * const, HttpDownloadManager * const );
 
-    QSharedPointer<TextureTile> loadTile( TileId const & stackedTileId, TileId const & tileId );
-    QSharedPointer<TextureTile> reloadTile( TileId const & stackedTileId, TileId const & tileId );
-    void reloadTile( QSharedPointer<TextureTile> const & tile );
+    QSharedPointer<TextureTile> loadTile( TileId const & stackedTileId, TileId const & tileId,
+                                          DownloadUsage const );
+    QSharedPointer<TextureTile> reloadTile( TileId const & stackedTileId, TileId const & tileId,
+                                            DownloadUsage const );
+    void reloadTile( QSharedPointer<TextureTile> const & tile, DownloadUsage const );
 
     void setTextureLayers( QHash<uint, GeoSceneTexture*> const & );
 
@@ -63,7 +65,7 @@
     GeoSceneTexture const * findTextureLayer( TileId const & ) const;
     GeoSceneTexture * findTextureLayer( TileId const & );
     QString tileFileName( TileId const & ) const;
-    void triggerDownload( TileId const & );
+    void triggerDownload( TileId const &, DownloadUsage const );
     QImage * scaledLowerLevelTile( TileId const & );
 
     // TODO: comment about uint hash key


More information about the Marble-commits mailing list