diff options
author | Paolo Angelelli <paolo.angelelli@qt.io> | 2017-09-11 17:15:45 +0200 |
---|---|---|
committer | Paolo Angelelli <paolo.angelelli@qt.io> | 2017-09-11 17:16:16 +0200 |
commit | a0c7b93df620d9254aef3136da08adbc70752837 (patch) | |
tree | 0db63a9d7f693d5245056eb41a1128c5fec11187 | |
parent | 3f2c6d8af0367c5e87eb38d348c99e2e2a2f0a76 (diff) | |
parent | b13ff055eb64970f545ba590735a38652de7689b (diff) | |
download | qtlocation-a0c7b93df620d9254aef3136da08adbc70752837.tar.gz |
Merge remote-tracking branch 'origin/5.9' into 5.10v5.10.0-beta1
Change-Id: Ibcf748d5f0d172ad5c77bdcd41806009ff6914e3
-rw-r--r-- | src/location/declarativemaps/qdeclarativegeomapitemview.cpp | 2 | ||||
-rw-r--r-- | src/location/maps/qgeofiletilecache.cpp | 38 | ||||
-rw-r--r-- | src/location/maps/qgeofiletilecache_p.h | 4 | ||||
-rw-r--r-- | src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp | 15 | ||||
-rw-r--r-- | src/plugins/geoservices/osm/qgeotileproviderosm.cpp | 2 | ||||
-rw-r--r-- | tests/auto/declarative_ui/tst_map.qml | 16 |
6 files changed, 45 insertions, 32 deletions
diff --git a/src/location/declarativemaps/qdeclarativegeomapitemview.cpp b/src/location/declarativemaps/qdeclarativegeomapitemview.cpp index d8c19528..24ed6700 100644 --- a/src/location/declarativemaps/qdeclarativegeomapitemview.cpp +++ b/src/location/declarativemaps/qdeclarativegeomapitemview.cpp @@ -378,7 +378,7 @@ void QDeclarativeGeoMapItemView::setAutoFitViewport(const bool &fitViewport) */ void QDeclarativeGeoMapItemView::fitViewport() { - if (!map_ || !fitViewport_ || m_repopulating) + if (!map_ || !map_->mapReady() || !fitViewport_ || m_repopulating) return; if (map_->mapItems().size() > 0) diff --git a/src/location/maps/qgeofiletilecache.cpp b/src/location/maps/qgeofiletilecache.cpp index d40ad825..df89c889 100644 --- a/src/location/maps/qgeofiletilecache.cpp +++ b/src/location/maps/qgeofiletilecache.cpp @@ -88,6 +88,7 @@ QGeoCachedTileDisk::~QGeoCachedTileDisk() QGeoFileTileCache::QGeoFileTileCache(const QString &directory, QObject *parent) : QAbstractGeoTileCache(parent), directory_(directory), minTextureUsage_(0), extraTextureUsage_(0) ,costStrategyDisk_(ByteSize), costStrategyMemory_(ByteSize), costStrategyTexture_(ByteSize) + ,isDiskCostSet_(false), isMemoryCostSet_(false), isTextureCostSet_(false) { } @@ -120,21 +121,21 @@ void QGeoFileTileCache::init() QDir::root().mkpath(directory_); // default values - if (!diskCache_.maxCost()) { // If setMaxDiskUsage has not been called yet + if (!isDiskCostSet_) { // If setMaxDiskUsage has not been called yet if (costStrategyDisk_ == ByteSize) setMaxDiskUsage(50 * 1024 * 1024); else setMaxDiskUsage(1000); } - if (!memoryCache_.maxCost()) { // If setMaxMemoryUsage has not been called yet + if (!isMemoryCostSet_) { // If setMaxMemoryUsage has not been called yet if (costStrategyMemory_ == ByteSize) setMaxMemoryUsage(3 * 1024 * 1024); else setMaxMemoryUsage(100); } - if (!textureCache_.maxCost()) { // If setExtraTextureUsage has not been called yet + if (!isTextureCostSet_) { // If setExtraTextureUsage has not been called yet if (costStrategyTexture_ == ByteSize) setExtraTextureUsage(6 * 1024 * 1024); else @@ -240,6 +241,7 @@ void QGeoFileTileCache::printStats() void QGeoFileTileCache::setMaxDiskUsage(int diskUsage) { diskCache_.setMaxCost(diskUsage); + isDiskCostSet_ = true; } int QGeoFileTileCache::maxDiskUsage() const @@ -255,6 +257,7 @@ int QGeoFileTileCache::diskUsage() const void QGeoFileTileCache::setMaxMemoryUsage(int memoryUsage) { memoryCache_.setMaxCost(memoryUsage); + isMemoryCostSet_ = true; } int QGeoFileTileCache::maxMemoryUsage() const @@ -271,6 +274,7 @@ void QGeoFileTileCache::setExtraTextureUsage(int textureUsage) { extraTextureUsage_ = textureUsage; textureCache_.setMaxCost(minTextureUsage_ + extraTextureUsage_); + isTextureCostSet_ = true; } void QGeoFileTileCache::setMinTextureUsage(int textureUsage) @@ -384,12 +388,7 @@ void QGeoFileTileCache::insert(const QGeoTileSpec &spec, if (areas & QAbstractGeoTileCache::DiskCache) { QString filename = tileSpecToFilename(spec, format, directory_); - QFile file(filename); - file.open(QIODevice::WriteOnly); - file.write(bytes); - file.close(); - - addToDiskCache(spec, filename); + addToDiskCache(spec, filename, bytes); } if (areas & QAbstractGeoTileCache::MemoryCache) { @@ -491,6 +490,27 @@ QSharedPointer<QGeoCachedTileDisk> QGeoFileTileCache::addToDiskCache(const QGeoT return td; } +bool QGeoFileTileCache::addToDiskCache(const QGeoTileSpec &spec, const QString &filename, const QByteArray &bytes) +{ + QSharedPointer<QGeoCachedTileDisk> td(new QGeoCachedTileDisk); + td->spec = spec; + td->filename = filename; + td->cache = this; + + int cost = 1; + if (costStrategyDisk_ == ByteSize) + cost = bytes.size(); + + if (diskCache_.insert(spec, td, cost)) { + QFile file(filename); + file.open(QIODevice::WriteOnly); + file.write(bytes); + file.close(); + return true; + } + return false; +} + void QGeoFileTileCache::addToMemoryCache(const QGeoTileSpec &spec, const QByteArray &bytes, const QString &format) { if (isTileBogus(bytes)) diff --git a/src/location/maps/qgeofiletilecache_p.h b/src/location/maps/qgeofiletilecache_p.h index e319e2a2..1712a9e3 100644 --- a/src/location/maps/qgeofiletilecache_p.h +++ b/src/location/maps/qgeofiletilecache_p.h @@ -147,6 +147,7 @@ protected: QString directory() const; QSharedPointer<QGeoCachedTileDisk> addToDiskCache(const QGeoTileSpec &spec, const QString &filename); + bool addToDiskCache(const QGeoTileSpec &spec, const QString &filename, const QByteArray &bytes); void addToMemoryCache(const QGeoTileSpec &spec, const QByteArray &bytes, const QString &format); QSharedPointer<QGeoTileTexture> addToTextureCache(const QGeoTileSpec &spec, const QImage &image); QSharedPointer<QGeoTileTexture> getFromMemory(const QGeoTileSpec &spec); @@ -167,6 +168,9 @@ protected: CostStrategy costStrategyDisk_; CostStrategy costStrategyMemory_; CostStrategy costStrategyTexture_; + bool isDiskCostSet_; + bool isMemoryCostSet_; + bool isTextureCostSet_; }; QT_END_NAMESPACE diff --git a/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp b/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp index 3f0062c0..9174ad62 100644 --- a/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp +++ b/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp @@ -220,15 +220,16 @@ QGeoTiledMappingManagerEngineOsm::QGeoTiledMappingManagerEngineOsm(const QVarian if (parameters.contains(QStringLiteral("osm.mapping.providersrepository.disabled"))) disableRedirection = parameters.value(QStringLiteral("osm.mapping.providersrepository.disabled")).toBool(); - foreach (QGeoTileProviderOsm * provider, m_providers) { + for (QGeoTileProviderOsm * provider: qAsConst(m_providers)) { // Providers are parented inside QGeoFileTileCacheOsm, as they are used in its destructor. - if (disableRedirection) + if (disableRedirection) { provider->disableRedirection(); - - connect(provider, &QGeoTileProviderOsm::resolutionFinished, - this, &QGeoTiledMappingManagerEngineOsm::onProviderResolutionFinished); - connect(provider, &QGeoTileProviderOsm::resolutionError, - this, &QGeoTiledMappingManagerEngineOsm::onProviderResolutionError); + } else { + connect(provider, &QGeoTileProviderOsm::resolutionFinished, + this, &QGeoTiledMappingManagerEngineOsm::onProviderResolutionFinished); + connect(provider, &QGeoTileProviderOsm::resolutionError, + this, &QGeoTiledMappingManagerEngineOsm::onProviderResolutionError); + } } updateMapTypes(); diff --git a/src/plugins/geoservices/osm/qgeotileproviderosm.cpp b/src/plugins/geoservices/osm/qgeotileproviderosm.cpp index 95e5d44b..f7ab8c99 100644 --- a/src/plugins/geoservices/osm/qgeotileproviderosm.cpp +++ b/src/plugins/geoservices/osm/qgeotileproviderosm.cpp @@ -174,11 +174,11 @@ void QGeoTileProviderOsm::disableRedirection() if (p->isValid() && !found) { m_provider = p; m_providerId = m_providerList.indexOf(p); - m_status = Resolved; found = true; } p->disconnect(this); } + m_status = Resolved; } void QGeoTileProviderOsm::onResolutionFinished(TileProvider *provider) diff --git a/tests/auto/declarative_ui/tst_map.qml b/tests/auto/declarative_ui/tst_map.qml index 52dcac11..8b101bf1 100644 --- a/tests/auto/declarative_ui/tst_map.qml +++ b/tests/auto/declarative_ui/tst_map.qml @@ -38,18 +38,6 @@ Item { // General-purpose elements for the test: Plugin { id: testPlugin; name: "qmlgeo.test.plugin"; allowExperimental: true } Plugin { id: testPlugin2; name: "gmlgeo.test.plugin"; allowExperimental: true } - Plugin { id: herePlugin; name: "here"; - parameters: [ - PluginParameter { - name: "here.app_id" - value: "stub" - }, - PluginParameter { - name: "here.token" - value: "stub" - } - ] - } Plugin { id: testPluginLazyParameter; name: "qmlgeo.test.plugin" @@ -111,13 +99,13 @@ Item { Map {id: mapPar; plugin: testPlugin; center: coordinate1; width: 512; height: 512} - Map {id: coordinateMap; plugin: herePlugin; center: coordinate3; + Map {id: coordinateMap; plugin: testPlugin; center: coordinate3; width: 1000; height: 1000; zoomLevel: 15 } Map {id: mapTiltBearing; plugin: testPlugin; center: coordinate1; width: 1000; height: 1000; zoomLevel: 4; bearing: 45.0; tilt: 25.0 } - Map {id: mapTiltBearingHere; plugin: herePlugin; center: coordinate1; + Map {id: mapTiltBearingHere; plugin: testPlugin; center: coordinate1; width: 1000; height: 1000; zoomLevel: 4; bearing: 45.0; tilt: 25.0 } Map { |