diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/location/doc/src/plugins/nokia.qdoc | 4 | ||||
-rw-r--r-- | src/location/doc/src/plugins/osm.qdoc | 8 | ||||
-rw-r--r-- | src/location/maps/qgeotilecache.cpp | 30 | ||||
-rw-r--r-- | src/location/maps/qgeotilecache_p.h | 2 | ||||
-rw-r--r-- | src/location/maps/qgeotiledmappingmanagerengine.cpp | 6 | ||||
-rw-r--r-- | src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp | 3 |
6 files changed, 38 insertions, 15 deletions
diff --git a/src/location/doc/src/plugins/nokia.qdoc b/src/location/doc/src/plugins/nokia.qdoc index f1a6828a..1ed5e6e1 100644 --- a/src/location/doc/src/plugins/nokia.qdoc +++ b/src/location/doc/src/plugins/nokia.qdoc @@ -92,7 +92,9 @@ a prefix. \li here.mapping.cache.directory \li Absolute path to map tile cache directory used as network disk cache. - Default place for the cache is "QtLocation" directory in \l {QStandardPaths::writableLocation()} {QStandardPaths::writableLocation}(\l{QStandardPaths::GenericCacheLocation}). + The default place for the cache is \c{QtLocation/here} directory in \l {QStandardPaths::writableLocation()} {QStandardPaths::writableLocation}(\l{QStandardPaths::GenericCacheLocation}). + On systems that have no concept of a shared cache, the application-specific \l{QStandardPaths::CacheLocation} is used instead. + \row \li here.mapping.cache.disk.size \li Map tile disk cache size in bytes. Default size of the cache is 20MB. diff --git a/src/location/doc/src/plugins/osm.qdoc b/src/location/doc/src/plugins/osm.qdoc index f6de9c20..1c924fd3 100644 --- a/src/location/doc/src/plugins/osm.qdoc +++ b/src/location/doc/src/plugins/osm.qdoc @@ -106,4 +106,12 @@ Plugin { PluginParameter { name: "osm.geocoding.host"; value: "http://geocoding.server.address" } } \endcode + +\section1 Other Plugin-specific Information + +\section2 Tile cache + +The tiles are cached in a \c{QtLocation/osm} directory in \l {QStandardPaths::writableLocation()}{QStandardPaths::writableLocation} +(\l{QStandardPaths::GenericCacheLocation}). On systems that have no concept of a shared cache, the application-specific +\l{QStandardPaths::CacheLocation} is used instead. */ diff --git a/src/location/maps/qgeotilecache.cpp b/src/location/maps/qgeotilecache.cpp index 4e15504d..3da2865b 100644 --- a/src/location/maps/qgeotilecache.cpp +++ b/src/location/maps/qgeotilecache.cpp @@ -100,14 +100,10 @@ QGeoTileCache::QGeoTileCache(const QString &directory, QObject *parent) qRegisterMetaType<QList<QGeoTileSpec> >(); qRegisterMetaType<QSet<QGeoTileSpec> >(); - // We keep default values here so that they are in one place - // rather than in each individual plugin (the plugins can - // of course override them) - - const QString basePath = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) - + QLatin1String("/QtLocation"); + const QString basePath = baseCacheDirectory(); // delete old tiles from QtLocation 5.4 or prior + // Newer version use plugin-specific subdirectories so those are not affected. // TODO Remove cache cleanup in Qt 6 QDir baseDir(basePath); if (baseDir.exists()) { @@ -118,8 +114,7 @@ QGeoTileCache::QGeoTileCache(const QString &directory, QObject *parent) if (directory_.isEmpty()) { directory_ = basePath; - qWarning() << "Plugin uses uninitialized directory for QGeoTileCache" - " which will was deleted during startup"; + qWarning() << "Plugin uses uninitialized QGeoTileCache directory which was deleted during startup"; } QDir::root().mkpath(directory_); @@ -465,4 +460,23 @@ QGeoTileSpec QGeoTileCache::filenameToTileSpec(const QString &filename) numbers.at(4)); } +QString QGeoTileCache::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()) + 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/qgeotilecache_p.h b/src/location/maps/qgeotilecache_p.h index 9cf31db0..d9f7bce9 100644 --- a/src/location/maps/qgeotilecache_p.h +++ b/src/location/maps/qgeotilecache_p.h @@ -141,6 +141,8 @@ public: QGeoTiledMappingManagerEngine::CacheAreas areas = QGeoTiledMappingManagerEngine::AllCaches); void handleError(const QGeoTileSpec &spec, const QString &errorString); + static QString baseCacheDirectory(); + public Q_SLOTS: void printStats(); diff --git a/src/location/maps/qgeotiledmappingmanagerengine.cpp b/src/location/maps/qgeotiledmappingmanagerengine.cpp index b9322c13..43f56872 100644 --- a/src/location/maps/qgeotiledmappingmanagerengine.cpp +++ b/src/location/maps/qgeotiledmappingmanagerengine.cpp @@ -288,10 +288,8 @@ QGeoTileCache *QGeoTiledMappingManagerEngine::tileCache() Q_D(QGeoTiledMappingManagerEngine); if (!d->tileCache_) { QString cacheDirectory; - if (!managerName().isEmpty()) { - cacheDirectory = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) - + QLatin1String("/QtLocation/") + managerName(); - } + if (!managerName().isEmpty()) + cacheDirectory = QGeoTileCache::baseCacheDirectory() + managerName(); d->tileCache_ = new QGeoTileCache(cacheDirectory); } return d->tileCache_; diff --git a/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp b/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp index 54bf29af..1b1163a6 100644 --- a/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp +++ b/src/plugins/geoservices/nokia/qgeotiledmappingmanagerengine_nokia.cpp @@ -106,8 +106,7 @@ QGeoTiledMappingManagerEngineNokia::QGeoTiledMappingManagerEngineNokia( cacheDir = parameters.value(QStringLiteral("here.mapping.cache.directory")).toString(); } else { // managerName() is not yet set, we have to hardcode the plugin name below - cacheDir = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) - + QLatin1String("/QtLocation/here"); + cacheDir = QGeoTileCache::baseCacheDirectory() + QLatin1String("here"); } QGeoTileCache *tileCache = createTileCacheWithDir(cacheDir); |