20 #include <QAbstractNetworkCache>
24 QCache<QUrl, QImage> QgsTileCache::sTileCache( 256 );
25 QMutex QgsTileCache::sTileCacheMutex;
30 QMutexLocker locker( &sTileCacheMutex );
31 sTileCache.insert( url,
new QImage( image ) );
36 QMutexLocker locker( &sTileCacheMutex );
38 if ( QImage *i = sTileCache.object( url ) )
47 QByteArray imageData = data->readAll();
50 image = QImage::fromData( imageData );
54 if ( ! image.isNull( ) )
56 sTileCache.insert( url,
new QImage( image ) );
66 QMutexLocker locker( &sTileCacheMutex );
67 return sTileCache.totalCost();
72 QMutexLocker locker( &sTileCacheMutex );
73 return sTileCache.maxCost();
static QgsNetworkAccessManager * instance(Qt::ConnectionType connectionType=Qt::BlockingQueuedConnection)
Returns a pointer to the active QgsNetworkAccessManager for the current thread.
static bool tile(const QUrl &url, QImage &image)
Try to access a tile and load it into "image" argument.
static int totalCost()
how many tiles are stored in the in-memory cache
static void insertTile(const QUrl &url, const QImage &image)
Add a tile image with given URL to the cache.
static int maxCost()
how many tiles can be stored in the in-memory cache