diff options
Diffstat (limited to 'src/location/maps')
-rw-r--r-- | src/location/maps/maps.pri | 6 | ||||
-rw-r--r-- | src/location/maps/qabstractgeotilecache.cpp | 147 | ||||
-rw-r--r-- | src/location/maps/qabstractgeotilecache_p.h | 123 | ||||
-rw-r--r-- | src/location/maps/qgeofiletilecache.cpp (renamed from src/location/maps/qgeotilecache.cpp) | 112 | ||||
-rw-r--r-- | src/location/maps/qgeofiletilecache_p.h (renamed from src/location/maps/qgeotilecache_p.h) | 45 | ||||
-rw-r--r-- | src/location/maps/qgeomapscene.cpp | 2 | ||||
-rw-r--r-- | src/location/maps/qgeotiledmap.cpp | 4 | ||||
-rw-r--r-- | src/location/maps/qgeotiledmap_p.h | 4 | ||||
-rw-r--r-- | src/location/maps/qgeotiledmap_p_p.h | 4 | ||||
-rw-r--r-- | src/location/maps/qgeotiledmappingmanagerengine.cpp | 12 | ||||
-rw-r--r-- | src/location/maps/qgeotiledmappingmanagerengine_p.h | 6 | ||||
-rw-r--r-- | src/location/maps/qgeotiledmappingmanagerengine_p_p.h | 4 | ||||
-rw-r--r-- | src/location/maps/qgeotilefetcher_p_p.h | 1 | ||||
-rw-r--r-- | src/location/maps/qgeotilerequestmanager.cpp | 2 | ||||
-rw-r--r-- | src/location/maps/qgeotilerequestmanager_p.h | 1 |
15 files changed, 338 insertions, 135 deletions
diff --git a/src/location/maps/maps.pri b/src/location/maps/maps.pri index 43e0f747..93af4f4d 100644 --- a/src/location/maps/maps.pri +++ b/src/location/maps/maps.pri @@ -49,7 +49,8 @@ PRIVATE_HEADERS += \ maps/qgeoroutingmanagerengine_p.h \ maps/qgeoroutingmanager_p.h \ maps/qgeoserviceprovider_p.h \ - maps/qgeotilecache_p.h \ + maps/qabstractgeotilecache_p.h \ + maps/qgeofiletilecache_p.h \ maps/qgeotiledmapreply_p.h \ maps/qgeotiledmapreply_p_p.h \ maps/qgeotilespec_p.h \ @@ -81,7 +82,8 @@ SOURCES += \ maps/qgeoroutingmanagerengine.cpp \ maps/qgeoserviceprovider.cpp \ maps/qgeoserviceproviderfactory.cpp \ - maps/qgeotilecache.cpp \ + maps/qabstractgeotilecache.cpp \ + maps/qgeofiletilecache.cpp \ maps/qgeotiledmapreply.cpp \ maps/qgeotilespec.cpp \ maps/qgeotiledmap.cpp diff --git a/src/location/maps/qabstractgeotilecache.cpp b/src/location/maps/qabstractgeotilecache.cpp new file mode 100644 index 00000000..739123db --- /dev/null +++ b/src/location/maps/qabstractgeotilecache.cpp @@ -0,0 +1,147 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtLocation module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include "qabstractgeotilecache_p.h" + +#include "qgeotilespec_p.h" + +#include "qgeomappingmanager_p.h" + +#include <QDir> +#include <QStandardPaths> +#include <QMetaType> +#include <QPixmap> +#include <QDebug> + +Q_DECLARE_METATYPE(QList<QGeoTileSpec>) +Q_DECLARE_METATYPE(QSet<QGeoTileSpec>) + +QT_BEGIN_NAMESPACE + +QGeoTileTexture::QGeoTileTexture() + : textureBound(false) {} + +QGeoTileTexture::~QGeoTileTexture() +{ +} + +QAbstractGeoTileCache::QAbstractGeoTileCache(QObject *parent) + : QObject(parent) +{ + qRegisterMetaType<QGeoTileSpec>(); + qRegisterMetaType<QList<QGeoTileSpec> >(); + qRegisterMetaType<QSet<QGeoTileSpec> >(); +} + +QAbstractGeoTileCache::~QAbstractGeoTileCache() +{ +} + +void QAbstractGeoTileCache::printStats() +{ +} + +void QAbstractGeoTileCache::handleError(const QGeoTileSpec &, const QString &error) +{ + qWarning() << "tile request error " << error; +} + +void QAbstractGeoTileCache::setMaxDiskUsage(int diskUsage) +{ + Q_UNUSED(diskUsage); +} + +int QAbstractGeoTileCache::maxDiskUsage() const +{ + return 0; +} + +int QAbstractGeoTileCache::diskUsage() const +{ + return 0; +} + +void QAbstractGeoTileCache::setMaxMemoryUsage(int memoryUsage) +{ + Q_UNUSED(memoryUsage); +} + +int QAbstractGeoTileCache::maxMemoryUsage() const +{ + return 0; +} + +int QAbstractGeoTileCache::memoryUsage() const +{ + return 0; +} + +QString QAbstractGeoTileCache::baseCacheDirectory() +{ + QString dir; + + // Try the shared cache first and use a specific directory. (e.g. ~/.cache/QtLocation) + // If this is not supported by the platform, use the application-specific cache + // location. (e.g. ~/.cache/<app_name>/QtLocation) + dir = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation); + + if (!dir.isEmpty()) { + // The shared cache may not be writable when application isolation is enforced. + static bool writable = false; + static bool writableChecked = false; + if (!writableChecked) { + writableChecked = true; + QDir::root().mkpath(dir); + QFile writeTestFile(QDir(dir).filePath(QStringLiteral("qt_cache_check"))); + writable = writeTestFile.open(QIODevice::WriteOnly); + if (writable) + writeTestFile.remove(); + } + if (!writable) + dir = QString(); + } + + if (dir.isEmpty()) + dir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); + + if (!dir.endsWith(QLatin1Char('/'))) + dir += QLatin1Char('/'); + + dir += QLatin1String("QtLocation/"); + + return dir; +} + +QT_END_NAMESPACE diff --git a/src/location/maps/qabstractgeotilecache_p.h b/src/location/maps/qabstractgeotilecache_p.h new file mode 100644 index 00000000..a679b430 --- /dev/null +++ b/src/location/maps/qabstractgeotilecache_p.h @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtLocation module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QABSTRACTGEOTILECACHE_P_H +#define QABSTRACTGEOTILECACHE_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include <QtLocation/qlocationglobal.h> + +#include <QObject> +#include <QCache> +#include "qcache3q_p.h" +#include <QSet> +#include <QMutex> +#include <QTimer> + +#include "qgeotilespec_p.h" +#include "qgeotiledmappingmanagerengine_p.h" + +#include <QImage> + +QT_BEGIN_NAMESPACE + +class QGeoMappingManager; + +class QGeoTile; +class QAbstractGeoTileCache; + +class QThread; + +/* This is also used in the mapgeometry */ +class Q_LOCATION_EXPORT QGeoTileTexture +{ +public: + + QGeoTileTexture(); + ~QGeoTileTexture(); + + QGeoTileSpec spec; + QImage image; + bool textureBound; +}; + +class Q_LOCATION_EXPORT QAbstractGeoTileCache : public QObject +{ + Q_OBJECT +public: + QAbstractGeoTileCache(QObject *parent = 0); + virtual ~QAbstractGeoTileCache(); + + virtual void setMaxDiskUsage(int diskUsage); + virtual int maxDiskUsage() const; + virtual int diskUsage() const; + + virtual void setMaxMemoryUsage(int memoryUsage); + virtual int maxMemoryUsage() const; + virtual int memoryUsage() const; + + virtual void setMinTextureUsage(int textureUsage) = 0; + virtual void setExtraTextureUsage(int textureUsage) = 0; + virtual int maxTextureUsage() const = 0; + virtual int minTextureUsage() const = 0; + virtual int textureUsage() const = 0; + + virtual QSharedPointer<QGeoTileTexture> get(const QGeoTileSpec &spec) = 0; + + virtual void insert(const QGeoTileSpec &spec, + const QByteArray &bytes, + const QString &format, + QGeoTiledMappingManagerEngine::CacheAreas areas = QGeoTiledMappingManagerEngine::AllCaches) = 0; + virtual void handleError(const QGeoTileSpec &spec, const QString &errorString); + + static QString baseCacheDirectory(); + +protected: + virtual void printStats() = 0; +}; + +QT_END_NAMESPACE + +#endif // QABSTRACTGEOTILECACHE_P_H diff --git a/src/location/maps/qgeotilecache.cpp b/src/location/maps/qgeofiletilecache.cpp index 01cfcba4..4efe9696 100644 --- a/src/location/maps/qgeotilecache.cpp +++ b/src/location/maps/qgeofiletilecache.cpp @@ -33,7 +33,7 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#include "qgeotilecache_p.h" +#include "qgeofiletilecache_p.h" #include "qgeotilespec_p.h" @@ -60,14 +60,11 @@ public: } QGeoTileSpec spec; - QGeoTileCache *cache; + QGeoFileTileCache *cache; QByteArray bytes; QString format; }; -QGeoTileTexture::QGeoTileTexture() - : textureBound(false) {} - void QCache3QTileEvictionPolicy::aboutToBeRemoved(const QGeoTileSpec &key, QSharedPointer<QGeoCachedTileDisk> obj) { Q_UNUSED(key); @@ -88,18 +85,10 @@ QGeoCachedTileDisk::~QGeoCachedTileDisk() cache->evictFromDiskCache(this); } -QGeoTileTexture::~QGeoTileTexture() -{ -} - -QGeoTileCache::QGeoTileCache(const QString &directory, QObject *parent) - : QObject(parent), directory_(directory), +QGeoFileTileCache::QGeoFileTileCache(const QString &directory, QObject *parent) + : QAbstractGeoTileCache(parent), directory_(directory), minTextureUsage_(0), extraTextureUsage_(0) { - qRegisterMetaType<QGeoTileSpec>(); - qRegisterMetaType<QList<QGeoTileSpec> >(); - qRegisterMetaType<QSet<QGeoTileSpec> >(); - const QString basePath = baseCacheDirectory(); // delete old tiles from QtLocation 5.4 or prior @@ -114,7 +103,7 @@ QGeoTileCache::QGeoTileCache(const QString &directory, QObject *parent) if (directory_.isEmpty()) { directory_ = basePath; - qWarning() << "Plugin uses uninitialized QGeoTileCache directory which was deleted during startup"; + qWarning() << "Plugin uses uninitialized QGeoFileTileCache directory which was deleted during startup"; } QDir::root().mkpath(directory_); @@ -127,7 +116,7 @@ QGeoTileCache::QGeoTileCache(const QString &directory, QObject *parent) loadTiles(); } -void QGeoTileCache::loadTiles() +void QGeoFileTileCache::loadTiles() { QStringList formats; formats << QLatin1String("*.*"); @@ -181,7 +170,7 @@ void QGeoTileCache::loadTiles() } } -QGeoTileCache::~QGeoTileCache() +QGeoFileTileCache::~QGeoFileTileCache() { // write disk cache queues to disk QDir dir(directory_); @@ -207,72 +196,72 @@ QGeoTileCache::~QGeoTileCache() } } -void QGeoTileCache::printStats() +void QGeoFileTileCache::printStats() { textureCache_.printStats(); memoryCache_.printStats(); diskCache_.printStats(); } -void QGeoTileCache::setMaxDiskUsage(int diskUsage) +void QGeoFileTileCache::setMaxDiskUsage(int diskUsage) { diskCache_.setMaxCost(diskUsage); } -int QGeoTileCache::maxDiskUsage() const +int QGeoFileTileCache::maxDiskUsage() const { return diskCache_.maxCost(); } -int QGeoTileCache::diskUsage() const +int QGeoFileTileCache::diskUsage() const { return diskCache_.totalCost(); } -void QGeoTileCache::setMaxMemoryUsage(int memoryUsage) +void QGeoFileTileCache::setMaxMemoryUsage(int memoryUsage) { memoryCache_.setMaxCost(memoryUsage); } -int QGeoTileCache::maxMemoryUsage() const +int QGeoFileTileCache::maxMemoryUsage() const { return memoryCache_.maxCost(); } -int QGeoTileCache::memoryUsage() const +int QGeoFileTileCache::memoryUsage() const { return memoryCache_.totalCost(); } -void QGeoTileCache::setExtraTextureUsage(int textureUsage) +void QGeoFileTileCache::setExtraTextureUsage(int textureUsage) { extraTextureUsage_ = textureUsage; textureCache_.setMaxCost(minTextureUsage_ + extraTextureUsage_); } -void QGeoTileCache::setMinTextureUsage(int textureUsage) +void QGeoFileTileCache::setMinTextureUsage(int textureUsage) { minTextureUsage_ = textureUsage; textureCache_.setMaxCost(minTextureUsage_ + extraTextureUsage_); } -int QGeoTileCache::maxTextureUsage() const +int QGeoFileTileCache::maxTextureUsage() const { return textureCache_.maxCost(); } -int QGeoTileCache::minTextureUsage() const +int QGeoFileTileCache::minTextureUsage() const { return minTextureUsage_; } -int QGeoTileCache::textureUsage() const +int QGeoFileTileCache::textureUsage() const { return textureCache_.totalCost(); } -QSharedPointer<QGeoTileTexture> QGeoTileCache::get(const QGeoTileSpec &spec) +QSharedPointer<QGeoTileTexture> QGeoFileTileCache::get(const QGeoTileSpec &spec) { QSharedPointer<QGeoTileTexture> tt = textureCache_.object(spec); if (tt) @@ -313,12 +302,7 @@ QSharedPointer<QGeoTileTexture> QGeoTileCache::get(const QGeoTileSpec &spec) return QSharedPointer<QGeoTileTexture>(); } -QString QGeoTileCache::directory() const -{ - return directory_; -} - -void QGeoTileCache::insert(const QGeoTileSpec &spec, +void QGeoFileTileCache::insert(const QGeoTileSpec &spec, const QByteArray &bytes, const QString &format, QGeoTiledMappingManagerEngine::CacheAreas areas) @@ -342,16 +326,16 @@ void QGeoTileCache::insert(const QGeoTileSpec &spec, * and act as a poison */ } -void QGeoTileCache::evictFromDiskCache(QGeoCachedTileDisk *td) +void QGeoFileTileCache::evictFromDiskCache(QGeoCachedTileDisk *td) { QFile::remove(td->filename); } -void QGeoTileCache::evictFromMemoryCache(QGeoCachedTileMemory * /* tm */) +void QGeoFileTileCache::evictFromMemoryCache(QGeoCachedTileMemory * /* tm */) { } -QSharedPointer<QGeoCachedTileDisk> QGeoTileCache::addToDiskCache(const QGeoTileSpec &spec, const QString &filename) +QSharedPointer<QGeoCachedTileDisk> QGeoFileTileCache::addToDiskCache(const QGeoTileSpec &spec, const QString &filename) { QSharedPointer<QGeoCachedTileDisk> td(new QGeoCachedTileDisk); td->spec = spec; @@ -364,7 +348,7 @@ QSharedPointer<QGeoCachedTileDisk> QGeoTileCache::addToDiskCache(const QGeoTileS return td; } -QSharedPointer<QGeoCachedTileMemory> QGeoTileCache::addToMemoryCache(const QGeoTileSpec &spec, const QByteArray &bytes, const QString &format) +QSharedPointer<QGeoCachedTileMemory> QGeoFileTileCache::addToMemoryCache(const QGeoTileSpec &spec, const QByteArray &bytes, const QString &format) { QSharedPointer<QGeoCachedTileMemory> tm(new QGeoCachedTileMemory); tm->spec = spec; @@ -378,7 +362,7 @@ QSharedPointer<QGeoCachedTileMemory> QGeoTileCache::addToMemoryCache(const QGeoT return tm; } -QSharedPointer<QGeoTileTexture> QGeoTileCache::addToTextureCache(const QGeoTileSpec &spec, const QPixmap &pixmap) +QSharedPointer<QGeoTileTexture> QGeoFileTileCache::addToTextureCache(const QGeoTileSpec &spec, const QPixmap &pixmap) { QSharedPointer<QGeoTileTexture> tt(new QGeoTileTexture); tt->spec = spec; @@ -390,12 +374,7 @@ QSharedPointer<QGeoTileTexture> QGeoTileCache::addToTextureCache(const QGeoTileS return tt; } -void QGeoTileCache::handleError(const QGeoTileSpec &, const QString &error) -{ - qWarning() << "tile request error " << error; -} - -QString QGeoTileCache::tileSpecToFilename(const QGeoTileSpec &spec, const QString &format, const QString &directory) +QString QGeoFileTileCache::tileSpecToFilename(const QGeoTileSpec &spec, const QString &format, const QString &directory) { QString filename = spec.plugin(); filename += QLatin1String("-"); @@ -421,7 +400,7 @@ QString QGeoTileCache::tileSpecToFilename(const QGeoTileSpec &spec, const QStrin return dir.filePath(filename); } -QGeoTileSpec QGeoTileCache::filenameToTileSpec(const QString &filename) +QGeoTileSpec QGeoFileTileCache::filenameToTileSpec(const QString &filename) { QGeoTileSpec emptySpec; @@ -460,40 +439,9 @@ QGeoTileSpec QGeoTileCache::filenameToTileSpec(const QString &filename) numbers.at(4)); } -QString QGeoTileCache::baseCacheDirectory() +QString QGeoFileTileCache::directory() const { - QString dir; - - // Try the shared cache first and use a specific directory. (e.g. ~/.cache/QtLocation) - // If this is not supported by the platform, use the application-specific cache - // location. (e.g. ~/.cache/<app_name>/QtLocation) - dir = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation); - - if (!dir.isEmpty()) { - // The shared cache may not be writable when application isolation is enforced. - static bool writable = false; - static bool writableChecked = false; - if (!writableChecked) { - writableChecked = true; - QDir::root().mkpath(dir); - QFile writeTestFile(QDir(dir).filePath(QStringLiteral("qt_cache_check"))); - writable = writeTestFile.open(QIODevice::WriteOnly); - if (writable) - writeTestFile.remove(); - } - if (!writable) - dir = QString(); - } - - if (dir.isEmpty()) - dir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); - - if (!dir.endsWith(QLatin1Char('/'))) - dir += QLatin1Char('/'); - - dir += QLatin1String("QtLocation/"); - - return dir; + return directory_; } QT_END_NAMESPACE diff --git a/src/location/maps/qgeotilecache_p.h b/src/location/maps/qgeofiletilecache_p.h index d9f7bce9..1ed2aabc 100644 --- a/src/location/maps/qgeotilecache_p.h +++ b/src/location/maps/qgeofiletilecache_p.h @@ -33,8 +33,8 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ -#ifndef QGEOTILECACHE_P_H -#define QGEOTILECACHE_P_H +#ifndef QGEOFILETILECACHE_P_H +#define QGEOFILETILECACHE_P_H // // W A R N I N G @@ -58,6 +58,7 @@ #include "qgeotilespec_p.h" #include "qgeotiledmappingmanagerengine_p.h" +#include "qabstractgeotilecache_p.h" #include <QImage> @@ -67,12 +68,12 @@ class QGeoMappingManager; class QGeoTile; class QGeoCachedTileMemory; -class QGeoTileCache; +class QGeoFileTileCache; class QPixmap; class QThread; -/* This would be internal to qgeotilecache.cpp except that the eviction +/* This would be internal to qgeofiletilecache.cpp except that the eviction * policy can't be defined without it being concrete here */ class QGeoCachedTileDisk { @@ -82,20 +83,7 @@ public: QGeoTileSpec spec; QString filename; QString format; - QGeoTileCache *cache; -}; - -/* This is also used in the mapgeometry */ -class Q_LOCATION_EXPORT QGeoTileTexture -{ -public: - - QGeoTileTexture(); - ~QGeoTileTexture(); - - QGeoTileSpec spec; - QImage image; - bool textureBound; + QGeoFileTileCache *cache; }; /* Custom eviction policy for the disk cache, to avoid deleting all the files @@ -107,12 +95,12 @@ protected: void aboutToBeEvicted(const QGeoTileSpec &key, QSharedPointer<QGeoCachedTileDisk> obj); }; -class Q_LOCATION_EXPORT QGeoTileCache : public QObject +class Q_LOCATION_EXPORT QGeoFileTileCache : public QAbstractGeoTileCache { Q_OBJECT public: - QGeoTileCache(const QString &directory = QString(), QObject *parent = 0); - ~QGeoTileCache(); + QGeoFileTileCache(const QString &directory = QString(), QObject *parent = 0); + ~QGeoFileTileCache(); void setMaxDiskUsage(int diskUsage); int maxDiskUsage() const; @@ -129,7 +117,6 @@ public: int textureUsage() const; QSharedPointer<QGeoTileTexture> get(const QGeoTileSpec &spec); - QString directory() const; // can be called without a specific tileCache pointer static void evictFromDiskCache(QGeoCachedTileDisk *td); @@ -139,16 +126,13 @@ public: const QByteArray &bytes, const QString &format, QGeoTiledMappingManagerEngine::CacheAreas areas = QGeoTiledMappingManagerEngine::AllCaches); - void handleError(const QGeoTileSpec &spec, const QString &errorString); - - static QString baseCacheDirectory(); - -public Q_SLOTS: - void printStats(); private: + void printStats(); void loadTiles(); + QString directory() const; + QSharedPointer<QGeoCachedTileDisk> addToDiskCache(const QGeoTileSpec &spec, const QString &filename); QSharedPointer<QGeoCachedTileMemory> addToMemoryCache(const QGeoTileSpec &spec, const QByteArray &bytes, const QString &format); QSharedPointer<QGeoTileTexture> addToTextureCache(const QGeoTileSpec &spec, const QPixmap &pixmap); @@ -156,15 +140,16 @@ private: static QString tileSpecToFilename(const QGeoTileSpec &spec, const QString &format, const QString &directory); static QGeoTileSpec filenameToTileSpec(const QString &filename); - QString directory_; QCache3Q<QGeoTileSpec, QGeoCachedTileDisk, QCache3QTileEvictionPolicy > diskCache_; QCache3Q<QGeoTileSpec, QGeoCachedTileMemory > memoryCache_; QCache3Q<QGeoTileSpec, QGeoTileTexture > textureCache_; int minTextureUsage_; int extraTextureUsage_; + + QString directory_; }; QT_END_NAMESPACE -#endif // QGEOTILECACHE_P_H +#endif // QGEOFILETILECACHE_P_H diff --git a/src/location/maps/qgeomapscene.cpp b/src/location/maps/qgeomapscene.cpp index a25405ec..4a457005 100644 --- a/src/location/maps/qgeomapscene.cpp +++ b/src/location/maps/qgeomapscene.cpp @@ -36,7 +36,7 @@ ****************************************************************************/ #include "qgeomapscene_p.h" #include "qgeocameradata_p.h" -#include "qgeotilecache_p.h" +#include "qabstractgeotilecache_p.h" #include "qgeotilespec_p.h" #include <QtPositioning/private/qdoublevector3d_p.h> #include <QtCore/private/qobject_p.h> diff --git a/src/location/maps/qgeotiledmap.cpp b/src/location/maps/qgeotiledmap.cpp index 06f5a5e8..d561c011 100644 --- a/src/location/maps/qgeotiledmap.cpp +++ b/src/location/maps/qgeotiledmap.cpp @@ -37,7 +37,7 @@ #include "qgeotiledmap_p_p.h" #include "qgeotiledmappingmanagerengine_p.h" -#include "qgeotilecache_p.h" +#include "qabstractgeotilecache_p.h" #include "qgeotilespec_p.h" #include "qgeocameratiles_p.h" @@ -85,7 +85,7 @@ void QGeoTiledMap::updateTile(const QGeoTileSpec &spec) d->updateTile(spec); } -QGeoTileCache *QGeoTiledMap::tileCache() +QAbstractGeoTileCache *QGeoTiledMap::tileCache() { Q_D(QGeoTiledMap); return d->m_cache; diff --git a/src/location/maps/qgeotiledmap_p.h b/src/location/maps/qgeotiledmap_p.h index 2afbc5c9..111056d2 100644 --- a/src/location/maps/qgeotiledmap_p.h +++ b/src/location/maps/qgeotiledmap_p.h @@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE class QGeoTileSpec; class QGeoTileTexture; -class QGeoTileCache; +class QAbstractGeoTileCache; class QGeoTiledMapPrivate; class QGeoTiledMappingManagerEngine; class QGeoTileRequestManager; @@ -79,7 +79,7 @@ public: QGeoTiledMap(QGeoTiledMappingManagerEngine *engine, QObject *parent); virtual ~QGeoTiledMap(); - QGeoTileCache *tileCache(); + QAbstractGeoTileCache *tileCache(); QGeoTileRequestManager *requestManager(); void updateTile(const QGeoTileSpec &spec); diff --git a/src/location/maps/qgeotiledmap_p_p.h b/src/location/maps/qgeotiledmap_p_p.h index 95a61a2b..2e93a006 100644 --- a/src/location/maps/qgeotiledmap_p_p.h +++ b/src/location/maps/qgeotiledmap_p_p.h @@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE class QGeoCameraTiles; class QGeoMapScene; -class QGeoTileCache; +class QAbstractGeoTileCache; class QGeoTiledMappingManagerEngine; class QGeoTiledMap; class QGeoTileRequestManager; @@ -92,7 +92,7 @@ private: void updateScene(); private: - QGeoTileCache *m_cache; + QAbstractGeoTileCache *m_cache; QGeoCameraTiles *m_cameraTiles; QGeoMapScene *m_mapScene; QGeoTileRequestManager *m_tileRequests; diff --git a/src/location/maps/qgeotiledmappingmanagerengine.cpp b/src/location/maps/qgeotiledmappingmanagerengine.cpp index 43f56872..1c61305b 100644 --- a/src/location/maps/qgeotiledmappingmanagerengine.cpp +++ b/src/location/maps/qgeotiledmappingmanagerengine.cpp @@ -41,7 +41,7 @@ #include "qgeotiledmap_p.h" #include "qgeotilerequestmanager_p.h" -#include "qgeotilecache_p.h" +#include "qgeofiletilecache_p.h" #include "qgeotilespec_p.h" #include <QTimer> @@ -275,22 +275,22 @@ void QGeoTiledMappingManagerEngine::setCacheHint(QGeoTiledMappingManagerEngine:: d->cacheHint_ = cacheHint; } -QGeoTileCache *QGeoTiledMappingManagerEngine::createTileCacheWithDir(const QString &cacheDirectory) +QAbstractGeoTileCache *QGeoTiledMappingManagerEngine::createTileCacheWithDir(const QString &cacheDirectory) { Q_D(QGeoTiledMappingManagerEngine); Q_ASSERT_X(!d->tileCache_, Q_FUNC_INFO, "This should be called only once"); - d->tileCache_ = new QGeoTileCache(cacheDirectory); + d->tileCache_ = new QGeoFileTileCache(cacheDirectory); return d->tileCache_; } -QGeoTileCache *QGeoTiledMappingManagerEngine::tileCache() +QAbstractGeoTileCache *QGeoTiledMappingManagerEngine::tileCache() { Q_D(QGeoTiledMappingManagerEngine); if (!d->tileCache_) { QString cacheDirectory; if (!managerName().isEmpty()) - cacheDirectory = QGeoTileCache::baseCacheDirectory() + managerName(); - d->tileCache_ = new QGeoTileCache(cacheDirectory); + cacheDirectory = QAbstractGeoTileCache::baseCacheDirectory() + managerName(); + d->tileCache_ = new QGeoFileTileCache(cacheDirectory); } return d->tileCache_; } diff --git a/src/location/maps/qgeotiledmappingmanagerengine_p.h b/src/location/maps/qgeotiledmappingmanagerengine_p.h index 12b43c40..b4ce173b 100644 --- a/src/location/maps/qgeotiledmappingmanagerengine_p.h +++ b/src/location/maps/qgeotiledmappingmanagerengine_p.h @@ -64,7 +64,7 @@ class QGeoTileTexture; class QGeoTileSpec; class QGeoTiledMap; -class QGeoTileCache; +class QAbstractGeoTileCache; class Q_LOCATION_EXPORT QGeoTiledMappingManagerEngine : public QGeoMappingManagerEngine { @@ -93,7 +93,7 @@ public: const QSet<QGeoTileSpec> &tilesAdded, const QSet<QGeoTileSpec> &tilesRemoved); - QGeoTileCache *tileCache(); // TODO: check this is still used + QAbstractGeoTileCache *tileCache(); // TODO: check this is still used QSharedPointer<QGeoTileTexture> getTileTexture(const QGeoTileSpec &spec); @@ -113,7 +113,7 @@ protected: void setTileVersion(int version); void setCacheHint(QGeoTiledMappingManagerEngine::CacheAreas cacheHint); - QGeoTileCache *createTileCacheWithDir(const QString &cacheDirectory); + QAbstractGeoTileCache *createTileCacheWithDir(const QString &cacheDirectory); private: QGeoTiledMappingManagerEnginePrivate *d_ptr; diff --git a/src/location/maps/qgeotiledmappingmanagerengine_p_p.h b/src/location/maps/qgeotiledmappingmanagerengine_p_p.h index 7fb08e75..86ad0f08 100644 --- a/src/location/maps/qgeotiledmappingmanagerengine_p_p.h +++ b/src/location/maps/qgeotiledmappingmanagerengine_p_p.h @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE class QGeoTiledMap; -class QGeoTileCache; +class QAbstractGeoTileCache; class QGeoTileSpec; class QGeoTileFetcher; @@ -72,7 +72,7 @@ public: QHash<QGeoTiledMap *, QSet<QGeoTileSpec> > mapHash_; QHash<QGeoTileSpec, QSet<QGeoTiledMap *> > tileHash_; QGeoTiledMappingManagerEngine::CacheAreas cacheHint_; - QGeoTileCache *tileCache_; + QAbstractGeoTileCache *tileCache_; QGeoTileFetcher *fetcher_; private: diff --git a/src/location/maps/qgeotilefetcher_p_p.h b/src/location/maps/qgeotilefetcher_p_p.h index ce2a5481..acd7288e 100644 --- a/src/location/maps/qgeotilefetcher_p_p.h +++ b/src/location/maps/qgeotilefetcher_p_p.h @@ -62,7 +62,6 @@ QT_BEGIN_NAMESPACE class QGeoTileSpec; class QGeoTiledMapReply; -class QGeoTileCache; class QGeoTiledMappingManagerEngine; class QGeoTileFetcherPrivate diff --git a/src/location/maps/qgeotilerequestmanager.cpp b/src/location/maps/qgeotilerequestmanager.cpp index 8857671d..1409856a 100644 --- a/src/location/maps/qgeotilerequestmanager.cpp +++ b/src/location/maps/qgeotilerequestmanager.cpp @@ -37,7 +37,7 @@ #include "qgeotilespec_p.h" #include "qgeotiledmap_p.h" #include "qgeotiledmappingmanagerengine_p.h" -#include "qgeotilecache_p.h" +#include "qabstractgeotilecache_p.h" #include <QtCore/QPointer> QT_BEGIN_NAMESPACE diff --git a/src/location/maps/qgeotilerequestmanager_p.h b/src/location/maps/qgeotilerequestmanager_p.h index 8ae7360a..66d2251e 100644 --- a/src/location/maps/qgeotilerequestmanager_p.h +++ b/src/location/maps/qgeotilerequestmanager_p.h @@ -54,7 +54,6 @@ QT_BEGIN_NAMESPACE class QGeoTiledMap; class QGeoTiledMappingManagerEngine; class QGeoTileSpec; -class QGeoTileCache; class QGeoTileTexture; class QGeoTileRequestManagerPrivate; |