Esempio n. 1
0
    QPixmap ImageManager::getImage(const QString& host, const QString& url)
    {
        //qDebug() << "ImageManager::getImage";
        QPixmap pm;
        //pm.fill(Qt::black);

        //is image cached (memory) or currently loading?
        if (!QPixmapCache::find(url, pm) && !net->imageIsLoading(url))
            //	if (!images.contains(url) && !net->imageIsLoading(url))
        {
            //image cached (persistent)?
            if (doPersistentCaching && tileExist(url))
            {
                loadTile(url,pm);
                QPixmapCache::insert(url.toAscii().toBase64(), pm);
            }
            else
            {
                //load from net, add empty image
                net->loadImage(host, url);
                //QPixmapCache::insert(url, emptyPixmap);
                return emptyPixmap;
            }
        }
        return pm;
    }
Esempio n. 2
0
    QPixmap ImageManager::getImage(const QString& host, const QString& url)
    {
        //qDebug() << "ImageManager::getImage";
        QPixmap pm;

        if ( net->imageIsLoading(url) )
        {
            //currently loading an image
            return loadingPixmap;
        }
        else if ( QPixmapCache::find( md5hex(url), &pm) )
        {
           //image found in cache, use this version
            return pm;
        }
        else if ( doPersistentCaching ) //image disk-caching (persistent) enabled 
                  
        {
            if ( tileExist(url) && 
                  !tileCacheExpired(url) )
            {
                loadTile(url,pm);
                QPixmapCache::insert(md5hex(url), pm);
                return pm;
            }
            else
            {
                //no file yet, go and request an image
                net->loadImage(host, url);
            }
        }
        //is image cached (memory)
        else if ( QPixmapCache::find(md5hex(url), &pm) && 
                  !pm.isNull() )
        {
            //we had a valid copy cached in memory (not disk) so return this
            return pm;
        }
        else
        {
            //load from net, add empty image
            net->loadImage(host, url);
        }
        return emptyPixmap;
    }
bool MapDownloader::downloadTile(int x,int y, int z)
{
    if( mapAdapter->isValid(x,y,z) ) 
    {
        if (tileExist( mapAdapter->query(x, y, z)) )
             return true;

        downloadListx->append(x);
        downloadListy->append(y);
        downloadListz->append(z);
        tilesDownloadCount++;
        return true;
    }
    else
    {
        qDebug()<<"error download tile "<<mapAdapter->query(x, y, z);
        return false;
    }
}
Esempio n. 4
0
    void ImageManager::receivedImage(const QPixmap pixmap, const QString& url)
    {
        //qDebug() << "ImageManager::receivedImage";
        QPixmapCache::insert(md5hex(url), pixmap);

        if (doPersistentCaching && !tileExist(url))
        {
            saveTile(url,pixmap);
        }

        if (!prefetch.contains(url))
        {
            emit(imageReceived());
        }
        else
        {

#if defined Q_WS_QWS || defined Q_WS_MAEMO_5 || defined Q_WS_S60
            prefetch.remove(prefetch.indexOf(url));
#endif
        }
    }
Esempio n. 5
0
    void ImageManager::receivedImage(const QPixmap pixmap, const QString& url)
    {
        //qDebug() << "ImageManager::receivedImage";
        QPixmapCache::insert(url, pixmap);
        //images[url] = pixmap;

        // needed?
        if (doPersistentCaching && !tileExist(url) )
            saveTile(url,pixmap);

        //((Layer*)this->parent())->imageReceived();

        if (!prefetch.contains(url))
        {
            emit(imageReceived());
        }
        else
        {

#if defined Q_WS_QWS || defined Q_WS_MAEMO_5 || defined Q_WS_S60
            prefetch.remove(prefetch.indexOf(url));
#endif
        }
    }