fix MapView, so tile provider can be accessible
add MapViewTileProviderBase::maximumLevel()
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
|
||||
|
||||
MapViewTileCache::MapViewTileCache(MapView * p): QThread() {
|
||||
qRegisterMetaType<OSM::TileIndex>();
|
||||
qRegisterMetaType<OSM::TilePixmap>();
|
||||
qRegisterMetaType<MapViewTypes::TileIndex>();
|
||||
qRegisterMetaType<MapViewTypes::TilePixmap>();
|
||||
parent = p;
|
||||
setCacheRoot(QAD::userPath(QAD::ltCache, "mapview") + "/");
|
||||
setAdditionalCacheSize(64);
|
||||
@@ -21,16 +21,16 @@ MapViewTileCache::~MapViewTileCache() {
|
||||
}
|
||||
|
||||
|
||||
void MapViewTileCache::tileDownloaded(OSM::TileIndex index, const QPixmap & pixmap) {
|
||||
auto * tile = new OSM::TilePixmap();
|
||||
void MapViewTileCache::tileDownloaded(MapViewTypes::TileIndex index, const QPixmap & pixmap) {
|
||||
auto * tile = new MapViewTypes::TilePixmap();
|
||||
tile->index = index;
|
||||
tile->pixmap = pixmap;
|
||||
saveTile(tile);
|
||||
}
|
||||
|
||||
|
||||
OSM::TilePixmap MapViewTileCache::getTile(OSM::TileIndex index, QRectF & rect_src) {
|
||||
OSM::TilePixmap ret = getTileFromCache(index);
|
||||
MapViewTypes::TilePixmap MapViewTileCache::getTile(MapViewTypes::TileIndex index, QRectF & rect_src) {
|
||||
MapViewTypes::TilePixmap ret = getTileFromCache(index);
|
||||
if (ret.isEmpty() || ret.obsolete) {
|
||||
if (!is_offline) parent->downloader->queueTile(index);
|
||||
}
|
||||
@@ -61,7 +61,7 @@ void MapViewTileCache::clearCache() {
|
||||
}
|
||||
|
||||
|
||||
bool MapViewTileCache::isTileFileExists(OSM::TileIndex index) const {
|
||||
bool MapViewTileCache::isTileFileExists(MapViewTypes::TileIndex index) const {
|
||||
QString hashdir = index.cacheDir();
|
||||
if (!cache_dir.exists(hashdir)) return false;
|
||||
QString hashname = hashdir + "/" + index.hashName();
|
||||
@@ -91,8 +91,8 @@ void MapViewTileCache::setOfflineMode(bool yes) {
|
||||
}
|
||||
|
||||
|
||||
OSM::TilePixmap MapViewTileCache::getTileFromCache(OSM::TileIndex index) {
|
||||
OSM::TilePixmap ret;
|
||||
MapViewTypes::TilePixmap MapViewTileCache::getTileFromCache(MapViewTypes::TileIndex index) {
|
||||
MapViewTypes::TilePixmap ret;
|
||||
ret.index = index;
|
||||
auto * tile = tile_cache[index.hash()];
|
||||
if (tile) {
|
||||
@@ -104,7 +104,7 @@ OSM::TilePixmap MapViewTileCache::getTileFromCache(OSM::TileIndex index) {
|
||||
if (cache_dir.exists(hashname)) {
|
||||
QString fname = cache_dir.absoluteFilePath(hashname);
|
||||
ret.pixmap.load(fname, "png");
|
||||
tile = new OSM::TilePixmap();
|
||||
tile = new MapViewTypes::TilePixmap();
|
||||
tile->index = index;
|
||||
tile->pixmap = ret.pixmap;
|
||||
if (secs_obsolete > 0) {
|
||||
@@ -125,7 +125,7 @@ void MapViewTileCache::updateCacheSize() {
|
||||
}
|
||||
|
||||
|
||||
void MapViewTileCache::saveTile(OSM::TilePixmap * tile) {
|
||||
void MapViewTileCache::saveTile(MapViewTypes::TilePixmap * tile) {
|
||||
tile_cache.insert(tile->index.hash(), tile, tile->pixmapBytes());
|
||||
emit tileReady(*tile);
|
||||
cond_mutex.lock();
|
||||
@@ -137,7 +137,7 @@ void MapViewTileCache::saveTile(OSM::TilePixmap * tile) {
|
||||
}
|
||||
|
||||
|
||||
void MapViewTileCache::writeToDisk(const OSM::TilePixmap & tile) {
|
||||
void MapViewTileCache::writeToDisk(const MapViewTypes::TilePixmap & tile) {
|
||||
QString hashdir = tile.index.cacheDir();
|
||||
if (!cache_dir.exists(hashdir)) cache_dir.mkdir(hashdir);
|
||||
QFile f(cache_dir.absoluteFilePath(hashdir + "/" + tile.index.hashName()));
|
||||
@@ -149,7 +149,7 @@ void MapViewTileCache::writeToDisk(const OSM::TilePixmap & tile) {
|
||||
|
||||
void MapViewTileCache::run() {
|
||||
while (!isInterruptionRequested()) {
|
||||
OSM::TilePixmap tile;
|
||||
MapViewTypes::TilePixmap tile;
|
||||
cond_mutex.lock();
|
||||
if (queue.isEmpty()) {
|
||||
cond.wait(&cond_mutex);
|
||||
|
||||
Reference in New Issue
Block a user