summaryrefslogtreecommitdiff
path: root/src/location/maps/qgeotiledmap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/location/maps/qgeotiledmap.cpp')
-rw-r--r--src/location/maps/qgeotiledmap.cpp58
1 files changed, 32 insertions, 26 deletions
diff --git a/src/location/maps/qgeotiledmap.cpp b/src/location/maps/qgeotiledmap.cpp
index 07d117cf..06f5a5e8 100644
--- a/src/location/maps/qgeotiledmap.cpp
+++ b/src/location/maps/qgeotiledmap.cpp
@@ -56,15 +56,8 @@ QGeoTiledMap::QGeoTiledMap(QGeoTiledMappingManagerEngine *engine, QObject *paren
d->m_tileRequests = new QGeoTileRequestManager(this, engine);
- QObject::connect(d->m_mapScene,
- SIGNAL(newTilesVisible(QSet<QGeoTileSpec>)),
- this,
- SLOT(evaluateCopyrights(QSet<QGeoTileSpec>)));
- QObject::connect(engine,
- SIGNAL(mapVersionChanged()),
- this,
- SLOT(updateMapVersion()));
- QMetaObject::invokeMethod(this, "updateMapVersion", Qt::QueuedConnection);
+ QObject::connect(engine,&QGeoTiledMappingManagerEngine::tileVersionChanged,
+ this,&QGeoTiledMap::handleTileVersionChanged);
}
QGeoTiledMap::~QGeoTiledMap()
@@ -110,10 +103,14 @@ void QGeoTiledMap::prefetchData()
d->prefetchTiles();
}
-void QGeoTiledMap::updateMapVersion()
+void QGeoTiledMap::handleTileVersionChanged()
{
Q_D(QGeoTiledMap);
- d->changeMapVersion(mapVersion());
+ if (!d->m_engine.isNull()) {
+ QGeoTiledMappingManagerEngine* engine = qobject_cast<QGeoTiledMappingManagerEngine*>(d->m_engine);
+ Q_ASSERT(engine);
+ d->changeTileVersion(engine->tileVersion());
+ }
}
void QGeoTiledMap::evaluateCopyrights(const QSet<QGeoTileSpec> &visibleTiles)
@@ -160,8 +157,7 @@ QGeoTiledMapPrivate::QGeoTiledMapPrivate(QGeoTiledMappingManagerEngine *engine)
{
m_cameraTiles->setMaximumZoomLevel(static_cast<int>(std::ceil(engine->cameraCapabilities().maximumZoomLevel())));
m_cameraTiles->setTileSize(engine->tileSize().width());
- m_cameraTiles->setPluginString(m_pluginString);
-
+ m_cameraTiles->setPluginString(engine->managerName() + QLatin1Char('_') + QString::number(engine->managerVersion()));
m_mapScene->setTileSize(engine->tileSize().width());
}
@@ -209,22 +205,31 @@ void QGeoTiledMapPrivate::changeCameraData(const QGeoCameraData &oldCameraData)
}
m_cameraTiles->setCameraData(cam);
-
m_mapScene->setCameraData(cam);
- m_mapScene->setVisibleTiles(m_cameraTiles->visibleTiles());
+ updateScene();
+}
- if (m_tileRequests) {
- // don't request tiles that are already built and textured
- QList<QSharedPointer<QGeoTileTexture> > cachedTiles =
- m_tileRequests->requestTiles(m_cameraTiles->visibleTiles() - m_mapScene->texturedTiles());
+void QGeoTiledMapPrivate::updateScene()
+{
+ Q_Q(QGeoTiledMap);
+ // detect if new tiles introduced
+ const QSet<QGeoTileSpec>& tiles = m_cameraTiles->visibleTiles();
+ bool newTilesIntroduced = !m_mapScene->visibleTiles().contains(tiles);
+ m_mapScene->setVisibleTiles(tiles);
- foreach (const QSharedPointer<QGeoTileTexture> &tex, cachedTiles) {
- m_mapScene->addTile(tex->spec, tex);
- }
+ if (newTilesIntroduced)
+ q->evaluateCopyrights(tiles);
- if (!cachedTiles.isEmpty())
- q->update();
+ // don't request tiles that are already built and textured
+ QList<QSharedPointer<QGeoTileTexture> > cachedTiles =
+ m_tileRequests->requestTiles(m_cameraTiles->visibleTiles() - m_mapScene->texturedTiles());
+
+ foreach (const QSharedPointer<QGeoTileTexture> &tex, cachedTiles) {
+ m_mapScene->addTile(tex->spec, tex);
}
+
+ if (!cachedTiles.isEmpty())
+ q->update();
}
void QGeoTiledMapPrivate::changeActiveMapType(const QGeoMapType mapType)
@@ -232,9 +237,10 @@ void QGeoTiledMapPrivate::changeActiveMapType(const QGeoMapType mapType)
m_cameraTiles->setMapType(mapType);
}
-void QGeoTiledMapPrivate::changeMapVersion(int mapVersion)
+void QGeoTiledMapPrivate::changeTileVersion(int version)
{
- m_cameraTiles->setMapVersion(mapVersion);
+ m_cameraTiles->setMapVersion(version);
+ updateScene();
}
void QGeoTiledMapPrivate::mapResized(int width, int height)