summaryrefslogtreecommitdiff
path: root/src/location/maps/qgeomappingmanagerengine.cpp
diff options
context:
space:
mode:
authorDavid Laing <david.laing@nokia.com>2011-12-19 15:54:34 +1000
committerQt by Nokia <qt-info@nokia.com>2011-12-19 15:38:19 +0100
commitc0bab81c8a47d4a4f20d31f7d861c86c59235503 (patch)
tree1fc0db40c2b41e4afc072caf80d53111a78e7d0e /src/location/maps/qgeomappingmanagerengine.cpp
parent8144d76e7ea855b3fbba5938f6815175c87b9acc (diff)
downloadqtlocation-c0bab81c8a47d4a4f20d31f7d861c86c59235503.tar.gz
Refactors the caching and tile fetching code.
The code now supports - multiple Maps sharing a QGeoMappingManager instance - several Maps can share a cache - plugins providing a hint to the cache about where the tiles should be stored (combinations of disk / memory / texture cache) Change-Id: I2dad40401d2bf06bfa142d2c51b804e1c35bfa61 Reviewed-by: Juha Vuolle <juha.vuolle@nokia.com>
Diffstat (limited to 'src/location/maps/qgeomappingmanagerengine.cpp')
-rw-r--r--src/location/maps/qgeomappingmanagerengine.cpp59
1 files changed, 38 insertions, 21 deletions
diff --git a/src/location/maps/qgeomappingmanagerengine.cpp b/src/location/maps/qgeomappingmanagerengine.cpp
index 5d64e0fa..63752f34 100644
--- a/src/location/maps/qgeomappingmanagerengine.cpp
+++ b/src/location/maps/qgeomappingmanagerengine.cpp
@@ -155,32 +155,41 @@ void QGeoMappingManagerEngine::threadFinished()
this->deleteLater();
}
-void QGeoMappingManagerEngine::requestTiles(const QList<TileSpec> &tiles)
+void QGeoMappingManagerEngine::updateTileRequests(const QSet<TileSpec> &tilesAdded,
+ const QSet<TileSpec> &tilesRemoved)
{
Q_D(QGeoMappingManagerEngine);
if (d->stopped_)
return;
- if (!d->started_) {
- d->queue_ = tiles;
- return;
- }
+ cancelTileRequests(tilesRemoved);
+
+ d->queue_ = tilesAdded.toList();
+
+ if (!d->queue_.empty())
+ d->timer_->start();
+}
- for (int i = 0; i < d->queue_.size(); ++i) {
- QGeoTiledMapReply* reply = d->invmap_.value(d->queue_.at(i), 0);
+void QGeoMappingManagerEngine::cancelTileRequests(const QSet<TileSpec> &tiles)
+{
+ Q_D(QGeoMappingManagerEngine);
+
+ typedef QSet<TileSpec>::const_iterator tile_iter;
+ tile_iter tile = tiles.constBegin();
+ tile_iter end = tiles.constEnd();
+ for (; tile != end; ++tile) {
+ QGeoTiledMapReply* reply = d->invmap_.value(*tile, 0);
if (reply) {
+ d->invmap_.remove(*tile);
reply->abort();
- d->map_.remove(reply);
- d->invmap_.remove(d->queue_.at(i));
reply->deleteLater();
}
+ d->queue_.removeAll(*tile);
}
- d->queue_ = tiles;
-
- if (!d->queue_.empty())
- d->timer_->start();
+ if (d->queue_.isEmpty())
+ d->timer_->stop();
}
void QGeoMappingManagerEngine::requestNextTile()
@@ -202,7 +211,6 @@ void QGeoMappingManagerEngine::requestNextTile()
this,
SLOT(finished()));
- d->map_.insert(reply, ts);
d->invmap_.insert(ts, reply);
}
@@ -218,14 +226,13 @@ void QGeoMappingManagerEngine::finished()
if (!reply)
return;
- if (!d->map_.contains(reply)) {
+ TileSpec spec = reply->tileSpec();
+
+ if (!d->invmap_.contains(spec)) {
reply->deleteLater();
return;
}
- TileSpec spec = d->map_.value(reply);
-
- d->map_.remove(reply);
d->invmap_.remove(spec);
handleReply(reply, spec);
@@ -247,9 +254,6 @@ void QGeoMappingManagerEngine::handleReply(QGeoTiledMapReply *reply, const TileS
emit tileError(spec, reply->errorString());
}
- if (d->queue_.isEmpty())
- emit queueFinished();
-
reply->deleteLater();
}
@@ -555,6 +559,18 @@ QLocale QGeoMappingManagerEngine::locale() const
return d_ptr->locale;
}
+TileCache::CacheAreas QGeoMappingManagerEngine::cacheHint() const
+{
+ Q_D(const QGeoMappingManagerEngine);
+ return d->cacheHint;
+}
+
+void QGeoMappingManagerEngine::setCacheHint(TileCache::CacheAreas cacheHint)
+{
+ Q_D(QGeoMappingManagerEngine);
+ d->cacheHint = cacheHint;
+}
+
/*******************************************************************************
*******************************************************************************/
@@ -566,6 +582,7 @@ QGeoMappingManagerEnginePrivate::QGeoMappingManagerEnginePrivate()
supportsTilting(false),
minimumTilt(0.0),
maximumTilt(0.0),
+ cacheHint(TileCache::AllCaches),
started_(false),
stopped_(false) {}