|
|
@ -62,7 +62,15 @@ QGeoTiledMapReplyQGC::QGeoTiledMapReplyQGC(QNetworkAccessManager *networkManager |
|
|
|
, _networkManager(networkManager) |
|
|
|
, _networkManager(networkManager) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(_request.url().isEmpty()) { |
|
|
|
if(_request.url().isEmpty()) { |
|
|
|
_returnBadTile(); |
|
|
|
if(!_badMapBox.size()) { |
|
|
|
|
|
|
|
QFile b(":/res/notile.png"); |
|
|
|
|
|
|
|
if(b.open(QFile::ReadOnly)) |
|
|
|
|
|
|
|
_badMapBox = b.readAll(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
setMapImageData(_badMapBox); |
|
|
|
|
|
|
|
setMapImageFormat("png"); |
|
|
|
|
|
|
|
setFinished(true); |
|
|
|
|
|
|
|
setCached(false); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
QGCFetchTileTask* task = getQGCMapEngine()->createFetchTileTask((UrlFactory::MapType)spec.mapId(), spec.x(), spec.y(), spec.zoom()); |
|
|
|
QGCFetchTileTask* task = getQGCMapEngine()->createFetchTileTask((UrlFactory::MapType)spec.mapId(), spec.x(), spec.y(), spec.zoom()); |
|
|
|
connect(task, &QGCFetchTileTask::tileFetched, this, &QGeoTiledMapReplyQGC::cacheReply); |
|
|
|
connect(task, &QGCFetchTileTask::tileFetched, this, &QGeoTiledMapReplyQGC::cacheReply); |
|
|
@ -91,21 +99,6 @@ QGeoTiledMapReplyQGC::_clearReply() |
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
void |
|
|
|
void |
|
|
|
QGeoTiledMapReplyQGC::_returnBadTile() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if(!_badMapBox.size()) { |
|
|
|
|
|
|
|
QFile b(":/res/notile.png"); |
|
|
|
|
|
|
|
if(b.open(QFile::ReadOnly)) |
|
|
|
|
|
|
|
_badMapBox = b.readAll(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
setMapImageData(_badMapBox); |
|
|
|
|
|
|
|
setMapImageFormat("png"); |
|
|
|
|
|
|
|
setFinished(true); |
|
|
|
|
|
|
|
setCached(false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void |
|
|
|
|
|
|
|
QGeoTiledMapReplyQGC::abort() |
|
|
|
QGeoTiledMapReplyQGC::abort() |
|
|
|
{ |
|
|
|
{ |
|
|
|
_timer.stop(); |
|
|
|
_timer.stop(); |
|
|
@ -145,8 +138,9 @@ QGeoTiledMapReplyQGC::networkReplyError(QNetworkReply::NetworkError error) |
|
|
|
} |
|
|
|
} |
|
|
|
if (error != QNetworkReply::OperationCanceledError) { |
|
|
|
if (error != QNetworkReply::OperationCanceledError) { |
|
|
|
qWarning() << "Fetch tile error:" << _reply->errorString(); |
|
|
|
qWarning() << "Fetch tile error:" << _reply->errorString(); |
|
|
|
|
|
|
|
setError(QGeoTiledMapReply::CommunicationError, _reply->errorString()); |
|
|
|
} |
|
|
|
} |
|
|
|
_returnBadTile(); |
|
|
|
setFinished(true); |
|
|
|
_clearReply(); |
|
|
|
_clearReply(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -154,8 +148,9 @@ QGeoTiledMapReplyQGC::networkReplyError(QNetworkReply::NetworkError error) |
|
|
|
void |
|
|
|
void |
|
|
|
QGeoTiledMapReplyQGC::cacheError(QGCMapTask::TaskType type, QString /*errorString*/) |
|
|
|
QGeoTiledMapReplyQGC::cacheError(QGCMapTask::TaskType type, QString /*errorString*/) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if(_networkManager->networkAccessible() < QNetworkAccessManager::Accessible || !getQGCMapEngine()->isInternetActive()) { |
|
|
|
if(!getQGCMapEngine()->isInternetActive()) { |
|
|
|
_returnBadTile(); |
|
|
|
setError(QGeoTiledMapReply::CommunicationError, "Network not available"); |
|
|
|
|
|
|
|
setFinished(true); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if(type != QGCMapTask::taskFetchTile) { |
|
|
|
if(type != QGCMapTask::taskFetchTile) { |
|
|
|
qWarning() << "QGeoTiledMapReplyQGC::cacheError() for wrong task"; |
|
|
|
qWarning() << "QGeoTiledMapReplyQGC::cacheError() for wrong task"; |
|
|
|