20#include <QAbstractNetworkCache> 
   24QCache<QUrl, QImage> QgsTileCache::sTileCache( 256 );
 
   25QMutex QgsTileCache::sTileCacheMutex;
 
   30  const QMutexLocker locker( &sTileCacheMutex );
 
   31  sTileCache.insert( url, 
new QImage( image ) );
 
 
   36  QNetworkRequest req( url );
 
   39  const QUrl adjUrl = req.url();
 
   41  const QMutexLocker locker( &sTileCacheMutex );
 
   43  if ( QImage *i = sTileCache.object( adjUrl ) )
 
   52      const QByteArray imageData = data->readAll();
 
   55      image = QImage::fromData( imageData );
 
   59      if ( ! image.isNull( ) )
 
   61        sTileCache.insert( adjUrl, 
new QImage( image ) );
 
 
   71  const QMutexLocker locker( &sTileCacheMutex );
 
   72  return sTileCache.totalCost();
 
 
   77  const QMutexLocker locker( &sTileCacheMutex );
 
   78  return sTileCache.maxCost();
 
 
void preprocessRequest(QNetworkRequest *req) const
Preprocesses request.
 
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