Commit f0d0856f authored by Gus Grubba's avatar Gus Grubba

Fix several compiler warnings

parent 46c9696f
...@@ -29,9 +29,9 @@ ...@@ -29,9 +29,9 @@
#include "time.h" #include "time.h"
const char* kDefaultSet = "Default Tile Set"; static const char* kDefaultSet = "Default Tile Set";
const QString kSession = QStringLiteral("QGeoTileWorkerSession"); static const QString kSession = QStringLiteral("QGeoTileWorkerSession");
const QString kExportSession = QStringLiteral("QGeoTileExportSession"); static const QString kExportSession = QStringLiteral("QGeoTileExportSession");
QGC_LOGGING_CATEGORY(QGCTileCacheLog, "QGCTileCacheLog") QGC_LOGGING_CATEGORY(QGCTileCacheLog, "QGCTileCacheLog")
...@@ -42,7 +42,7 @@ QGC_LOGGING_CATEGORY(QGCTileCacheLog, "QGCTileCacheLog") ...@@ -42,7 +42,7 @@ QGC_LOGGING_CATEGORY(QGCTileCacheLog, "QGCTileCacheLog")
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
QGCCacheWorker::QGCCacheWorker() QGCCacheWorker::QGCCacheWorker()
: _db(NULL) : _db(nullptr)
, _valid(false) , _valid(false)
, _failed(false) , _failed(false)
, _defaultSet(UINT64_MAX) , _defaultSet(UINT64_MAX)
...@@ -54,13 +54,11 @@ QGCCacheWorker::QGCCacheWorker() ...@@ -54,13 +54,11 @@ QGCCacheWorker::QGCCacheWorker()
, _updateTimeout(SHORT_TIMEOUT) , _updateTimeout(SHORT_TIMEOUT)
, _hostLookupID(0) , _hostLookupID(0)
{ {
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
QGCCacheWorker::~QGCCacheWorker() QGCCacheWorker::~QGCCacheWorker()
{ {
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -173,13 +171,13 @@ QGCCacheWorker::run() ...@@ -173,13 +171,13 @@ QGCCacheWorker::run()
} }
task->deleteLater(); task->deleteLater();
//-- Check for update timeout //-- Check for update timeout
size_t count = _taskQueue.count(); size_t count = static_cast<size_t>(_taskQueue.count());
if(count > 100) { if(count > 100) {
_updateTimeout = LONG_TIMEOUT; _updateTimeout = LONG_TIMEOUT;
} else if(count < 25) { } else if(count < 25) {
_updateTimeout = SHORT_TIMEOUT; _updateTimeout = SHORT_TIMEOUT;
} }
if(!count || (time(0) - _lastUpdate > _updateTimeout)) { if(!count || (time(nullptr) - _lastUpdate > _updateTimeout)) {
if(_valid) { if(_valid) {
_updateTotals(); _updateTotals();
} }
...@@ -187,7 +185,7 @@ QGCCacheWorker::run() ...@@ -187,7 +185,7 @@ QGCCacheWorker::run()
} else { } else {
//-- Wait a bit before shutting things down //-- Wait a bit before shutting things down
_waitmutex.lock(); _waitmutex.lock();
int timeout = 5000; unsigned long timeout = 5000;
_waitc.wait(&_waitmutex, timeout); _waitc.wait(&_waitmutex, timeout);
_waitmutex.unlock(); _waitmutex.unlock();
_mutex.lock(); _mutex.lock();
...@@ -201,7 +199,7 @@ QGCCacheWorker::run() ...@@ -201,7 +199,7 @@ QGCCacheWorker::run()
} }
if(_db) { if(_db) {
delete _db; delete _db;
_db = NULL; _db = nullptr;
QSqlDatabase::removeDatabase(kSession); QSqlDatabase::removeDatabase(kSession);
} }
} }
...@@ -284,7 +282,7 @@ QGCCacheWorker::_getTile(QGCMapTask* mtask) ...@@ -284,7 +282,7 @@ QGCCacheWorker::_getTile(QGCMapTask* mtask)
if(query.next()) { if(query.next()) {
QByteArray ar = query.value(0).toByteArray(); QByteArray ar = query.value(0).toByteArray();
QString format = query.value(1).toString(); QString format = query.value(1).toString();
UrlFactory::MapType type = (UrlFactory::MapType)query.value(2).toInt(); UrlFactory::MapType type = static_cast<UrlFactory::MapType>(query.value(2).toInt());
qCDebug(QGCTileCacheLog) << "_getTile() (Found in DB) HASH:" << task->hash(); qCDebug(QGCTileCacheLog) << "_getTile() (Found in DB) HASH:" << task->hash();
QGCCacheTile* tile = new QGCCacheTile(task->hash(), ar, format, type); QGCCacheTile* tile = new QGCCacheTile(task->hash(), ar, format, type);
task->setTileFetched(tile); task->setTileFetched(tile);
...@@ -320,7 +318,7 @@ QGCCacheWorker::_getTileSets(QGCMapTask* mtask) ...@@ -320,7 +318,7 @@ QGCCacheWorker::_getTileSets(QGCMapTask* mtask)
set->setBottomRightLon(query.value("bottomRightLon").toDouble()); set->setBottomRightLon(query.value("bottomRightLon").toDouble());
set->setMinZoom(query.value("minZoom").toInt()); set->setMinZoom(query.value("minZoom").toInt());
set->setMaxZoom(query.value("maxZoom").toInt()); set->setMaxZoom(query.value("maxZoom").toInt());
set->setType((UrlFactory::MapType)query.value("type").toInt()); set->setType(static_cast<UrlFactory::MapType>(query.value("type").toInt()));
set->setTotalTileCount(query.value("numTiles").toUInt()); set->setTotalTileCount(query.value("numTiles").toUInt());
set->setDefaultSet(query.value("defaultSet").toInt() != 0); set->setDefaultSet(query.value("defaultSet").toInt() != 0);
set->setCreationDate(QDateTime::fromTime_t(query.value("date").toUInt())); set->setCreationDate(QDateTime::fromTime_t(query.value("date").toUInt()));
...@@ -413,7 +411,7 @@ QGCCacheWorker::_updateTotals() ...@@ -413,7 +411,7 @@ QGCCacheWorker::_updateTotals()
} }
} }
emit updateTotals(_totalCount, _totalSize, _defaultCount, _defaultSize); emit updateTotals(_totalCount, _totalSize, _defaultCount, _defaultSize);
_lastUpdate = time(0); _lastUpdate = time(nullptr);
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -526,14 +524,14 @@ QGCCacheWorker::_getTileDownloadList(QGCMapTask* mtask) ...@@ -526,14 +524,14 @@ QGCCacheWorker::_getTileDownloadList(QGCMapTask* mtask)
while(query.next()) { while(query.next()) {
QGCTile* tile = new QGCTile; QGCTile* tile = new QGCTile;
tile->setHash(query.value("hash").toString()); tile->setHash(query.value("hash").toString());
tile->setType((UrlFactory::MapType)query.value("type").toInt()); tile->setType(static_cast<UrlFactory::MapType>(query.value("type").toInt()));
tile->setX(query.value("x").toInt()); tile->setX(query.value("x").toInt());
tile->setY(query.value("y").toInt()); tile->setY(query.value("y").toInt());
tile->setZ(query.value("z").toInt()); tile->setZ(query.value("z").toInt());
tiles.append(tile); tiles.append(tile);
} }
for(int i = 0; i < tiles.size(); i++) { for(int i = 0; i < tiles.size(); i++) {
s = QString("UPDATE TilesDownload SET state = %1 WHERE setID = %2 and hash = \"%3\"").arg((int)QGCTile::StateDownloading).arg(task->setID()).arg(tiles[i]->hash()); s = QString("UPDATE TilesDownload SET state = %1 WHERE setID = %2 and hash = \"%3\"").arg(static_cast<int>(QGCTile::StateDownloading)).arg(task->setID()).arg(tiles[i]->hash());
if(!query.exec(s)) { if(!query.exec(s)) {
qWarning() << "Map Cache SQL error (set TilesDownload state):" << query.lastError().text(); qWarning() << "Map Cache SQL error (set TilesDownload state):" << query.lastError().text();
} }
...@@ -556,9 +554,9 @@ QGCCacheWorker::_updateTileDownloadState(QGCMapTask* mtask) ...@@ -556,9 +554,9 @@ QGCCacheWorker::_updateTileDownloadState(QGCMapTask* mtask)
s = QString("DELETE FROM TilesDownload WHERE setID = %1 AND hash = \"%2\"").arg(task->setID()).arg(task->hash()); s = QString("DELETE FROM TilesDownload WHERE setID = %1 AND hash = \"%2\"").arg(task->setID()).arg(task->hash());
} else { } else {
if(task->hash() == "*") { if(task->hash() == "*") {
s = QString("UPDATE TilesDownload SET state = %1 WHERE setID = %2").arg((int)task->state()).arg(task->setID()); s = QString("UPDATE TilesDownload SET state = %1 WHERE setID = %2").arg(static_cast<int>(task->state())).arg(task->setID());
} else { } else {
s = QString("UPDATE TilesDownload SET state = %1 WHERE setID = %2 AND hash = \"%3\"").arg((int)task->state()).arg(task->setID()).arg(task->hash()); s = QString("UPDATE TilesDownload SET state = %1 WHERE setID = %2 AND hash = \"%3\"").arg(static_cast<int>(task->state())).arg(task->setID()).arg(task->hash());
} }
} }
if(!query.exec(s)) { if(!query.exec(s)) {
......
...@@ -58,7 +58,7 @@ int QGeoTiledMapReplyQGC::_requestCount = 0; ...@@ -58,7 +58,7 @@ int QGeoTiledMapReplyQGC::_requestCount = 0;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
QGeoTiledMapReplyQGC::QGeoTiledMapReplyQGC(QNetworkAccessManager *networkManager, const QNetworkRequest &request, const QGeoTileSpec &spec, QObject *parent) QGeoTiledMapReplyQGC::QGeoTiledMapReplyQGC(QNetworkAccessManager *networkManager, const QNetworkRequest &request, const QGeoTileSpec &spec, QObject *parent)
: QGeoTiledMapReply(spec, parent) : QGeoTiledMapReply(spec, parent)
, _reply(NULL) , _reply(nullptr)
, _request(request) , _request(request)
, _networkManager(networkManager) , _networkManager(networkManager)
{ {
...@@ -73,7 +73,7 @@ QGeoTiledMapReplyQGC::QGeoTiledMapReplyQGC(QNetworkAccessManager *networkManager ...@@ -73,7 +73,7 @@ QGeoTiledMapReplyQGC::QGeoTiledMapReplyQGC(QNetworkAccessManager *networkManager
setFinished(true); setFinished(true);
setCached(false); setCached(false);
} else { } else {
QGCFetchTileTask* task = getQGCMapEngine()->createFetchTileTask((UrlFactory::MapType)spec.mapId(), spec.x(), spec.y(), spec.zoom()); QGCFetchTileTask* task = getQGCMapEngine()->createFetchTileTask(static_cast<UrlFactory::MapType>(spec.mapId()), spec.x(), spec.y(), spec.zoom());
connect(task, &QGCFetchTileTask::tileFetched, this, &QGeoTiledMapReplyQGC::cacheReply); connect(task, &QGCFetchTileTask::tileFetched, this, &QGeoTiledMapReplyQGC::cacheReply);
connect(task, &QGCMapTask::error, this, &QGeoTiledMapReplyQGC::cacheError); connect(task, &QGCMapTask::error, this, &QGeoTiledMapReplyQGC::cacheError);
getQGCMapEngine()->addTask(task); getQGCMapEngine()->addTask(task);
...@@ -93,7 +93,7 @@ QGeoTiledMapReplyQGC::_clearReply() ...@@ -93,7 +93,7 @@ QGeoTiledMapReplyQGC::_clearReply()
_timer.stop(); _timer.stop();
if (_reply) { if (_reply) {
_reply->deleteLater(); _reply->deleteLater();
_reply = 0; _reply = nullptr;
_requestCount--; _requestCount--;
} }
} }
...@@ -122,9 +122,9 @@ QGeoTiledMapReplyQGC::networkReplyFinished() ...@@ -122,9 +122,9 @@ QGeoTiledMapReplyQGC::networkReplyFinished()
return; return;
} }
QByteArray a = _reply->readAll(); QByteArray a = _reply->readAll();
QString format = getQGCMapEngine()->urlFactory()->getImageFormat((UrlFactory::MapType)tileSpec().mapId(), a); QString format = getQGCMapEngine()->urlFactory()->getImageFormat(static_cast<UrlFactory::MapType>(tileSpec().mapId()), a);
//-- Test for a specialized, elevation data (not map tile) //-- Test for a specialized, elevation data (not map tile)
if ((UrlFactory::MapType)tileSpec().mapId() == UrlFactory::MapType::AirmapElevation) { if (static_cast<UrlFactory::MapType>(tileSpec().mapId()) == UrlFactory::MapType::AirmapElevation) {
a = TerrainTile::serialize(a); a = TerrainTile::serialize(a);
//-- Cache it if valid //-- Cache it if valid
if(!a.isEmpty()) { if(!a.isEmpty()) {
...@@ -136,7 +136,7 @@ QGeoTiledMapReplyQGC::networkReplyFinished() ...@@ -136,7 +136,7 @@ QGeoTiledMapReplyQGC::networkReplyFinished()
setMapImageData(a); setMapImageData(a);
if(!format.isEmpty()) { if(!format.isEmpty()) {
setMapImageFormat(format); setMapImageFormat(format);
getQGCMapEngine()->cacheTile((UrlFactory::MapType)tileSpec().mapId(), tileSpec().x(), tileSpec().y(), tileSpec().zoom(), a, format); getQGCMapEngine()->cacheTile(static_cast<UrlFactory::MapType>(tileSpec().mapId()), tileSpec().x(), tileSpec().y(), tileSpec().zoom(), a, format);
} }
setFinished(true); setFinished(true);
} }
...@@ -152,7 +152,7 @@ QGeoTiledMapReplyQGC::networkReplyError(QNetworkReply::NetworkError error) ...@@ -152,7 +152,7 @@ QGeoTiledMapReplyQGC::networkReplyError(QNetworkReply::NetworkError error)
return; return;
} }
//-- Test for a specialized, elevation data (not map tile) //-- Test for a specialized, elevation data (not map tile)
if ((UrlFactory::MapType)tileSpec().mapId() == UrlFactory::MapType::AirmapElevation) { if (static_cast<UrlFactory::MapType>(tileSpec().mapId()) == UrlFactory::MapType::AirmapElevation) {
emit terrainDone(QByteArray(), error); emit terrainDone(QByteArray(), error);
} else { } else {
//-- Regular map tile //-- Regular map tile
...@@ -170,7 +170,7 @@ void ...@@ -170,7 +170,7 @@ void
QGeoTiledMapReplyQGC::cacheError(QGCMapTask::TaskType type, QString /*errorString*/) QGeoTiledMapReplyQGC::cacheError(QGCMapTask::TaskType type, QString /*errorString*/)
{ {
if(!getQGCMapEngine()->isInternetActive()) { if(!getQGCMapEngine()->isInternetActive()) {
if ((UrlFactory::MapType)tileSpec().mapId() == UrlFactory::MapType::AirmapElevation) { if (static_cast<UrlFactory::MapType>(tileSpec().mapId()) == UrlFactory::MapType::AirmapElevation) {
emit terrainDone(QByteArray(), QNetworkReply::NetworkSessionFailedError); emit terrainDone(QByteArray(), QNetworkReply::NetworkSessionFailedError);
} else { } else {
setError(QGeoTiledMapReply::CommunicationError, "Network not available"); setError(QGeoTiledMapReply::CommunicationError, "Network not available");
...@@ -188,8 +188,8 @@ QGeoTiledMapReplyQGC::cacheError(QGCMapTask::TaskType type, QString /*errorStrin ...@@ -188,8 +188,8 @@ QGeoTiledMapReplyQGC::cacheError(QGCMapTask::TaskType type, QString /*errorStrin
_networkManager->setProxy(tProxy); _networkManager->setProxy(tProxy);
#endif #endif
_reply = _networkManager->get(_request); _reply = _networkManager->get(_request);
_reply->setParent(0); _reply->setParent(nullptr);
connect(_reply, &QNetworkReply::finished, this, &QGeoTiledMapReplyQGC::networkReplyFinished); connect(_reply, &QNetworkReply::finished, this, &QGeoTiledMapReplyQGC::networkReplyFinished);
connect(_reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(networkReplyError(QNetworkReply::NetworkError))); connect(_reply, SIGNAL(error(QNetworkReply::NetworkError)), this, SLOT(networkReplyError(QNetworkReply::NetworkError)));
#if !defined(__mobile__) #if !defined(__mobile__)
_networkManager->setProxy(proxy); _networkManager->setProxy(proxy);
...@@ -207,7 +207,7 @@ void ...@@ -207,7 +207,7 @@ void
QGeoTiledMapReplyQGC::cacheReply(QGCCacheTile* tile) QGeoTiledMapReplyQGC::cacheReply(QGCCacheTile* tile)
{ {
//-- Test for a specialized, elevation data (not map tile) //-- Test for a specialized, elevation data (not map tile)
if ((UrlFactory::MapType)tileSpec().mapId() == UrlFactory::MapType::AirmapElevation) { if (static_cast<UrlFactory::MapType>(tileSpec().mapId()) == UrlFactory::MapType::AirmapElevation) {
emit terrainDone(tile->img(), QNetworkReply::NoError); emit terrainDone(tile->img(), QNetworkReply::NoError);
} else { } else {
//-- Regular map tile //-- Regular map tile
......
...@@ -152,7 +152,7 @@ QGCMapEngineManager::startDownload(const QString& name, const QString& mapType) ...@@ -152,7 +152,7 @@ QGCMapEngineManager::startDownload(const QString& name, const QString& mapType)
set->setMinZoom(_minZoom); set->setMinZoom(_minZoom);
set->setMaxZoom(_maxZoom); set->setMaxZoom(_maxZoom);
set->setTotalTileSize(_imageSet.tileSize); set->setTotalTileSize(_imageSet.tileSize);
set->setTotalTileCount(_imageSet.tileCount); set->setTotalTileCount(static_cast<quint32>(_imageSet.tileCount));
set->setType(QGCMapEngine::getTypeFromName(mapType)); set->setType(QGCMapEngine::getTypeFromName(mapType));
QGCCreateTileSetTask* task = new QGCCreateTileSetTask(set); QGCCreateTileSetTask* task = new QGCCreateTileSetTask(set);
//-- Create Tile Set (it will also create a list of tiles to download) //-- Create Tile Set (it will also create a list of tiles to download)
...@@ -172,7 +172,7 @@ QGCMapEngineManager::startDownload(const QString& name, const QString& mapType) ...@@ -172,7 +172,7 @@ QGCMapEngineManager::startDownload(const QString& name, const QString& mapType)
set->setMinZoom(1); set->setMinZoom(1);
set->setMaxZoom(1); set->setMaxZoom(1);
set->setTotalTileSize(_elevationSet.tileSize); set->setTotalTileSize(_elevationSet.tileSize);
set->setTotalTileCount(_elevationSet.tileCount); set->setTotalTileCount(static_cast<quint32>(_elevationSet.tileCount));
set->setType(QGCMapEngine::getTypeFromName("Airmap Elevation Data")); set->setType(QGCMapEngine::getTypeFromName("Airmap Elevation Data"));
QGCCreateTileSetTask* task = new QGCCreateTileSetTask(set); QGCCreateTileSetTask* task = new QGCCreateTileSetTask(set);
//-- Create Tile Set (it will also create a list of tiles to download) //-- Create Tile Set (it will also create a list of tiles to download)
...@@ -305,7 +305,7 @@ void ...@@ -305,7 +305,7 @@ void
QGCMapEngineManager::_tileSetDeleted(quint64 setID) QGCMapEngineManager::_tileSetDeleted(quint64 setID)
{ {
//-- Tile Set successfully deleted //-- Tile Set successfully deleted
QGCCachedTileSet* setToDelete = NULL; QGCCachedTileSet* setToDelete = nullptr;
int i = 0; int i = 0;
for(i = 0; i < _tileSets.count(); i++ ) { for(i = 0; i < _tileSets.count(); i++ ) {
QGCCachedTileSet* set = qobject_cast<QGCCachedTileSet*>(_tileSets.get(i)); QGCCachedTileSet* set = qobject_cast<QGCCachedTileSet*>(_tileSets.get(i));
...@@ -436,7 +436,7 @@ QGCMapEngineManager::importSets(QString path) { ...@@ -436,7 +436,7 @@ QGCMapEngineManager::importSets(QString path) {
dir = QDir(QDir::homePath()).filePath(QString("export_%1.db").arg(QDateTime::currentDateTime().toTime_t())); dir = QDir(QDir::homePath()).filePath(QString("export_%1.db").arg(QDateTime::currentDateTime().toTime_t()));
#else #else
dir = QGCQFileDialog::getOpenFileName( dir = QGCQFileDialog::getOpenFileName(
NULL, nullptr,
"Import Tile Set", "Import Tile Set",
QDir::homePath(), QDir::homePath(),
"Tile Sets (*.qgctiledb)"); "Tile Sets (*.qgctiledb)");
...@@ -547,8 +547,8 @@ QGCMapEngineManager::_updateDiskFreeSpace() ...@@ -547,8 +547,8 @@ QGCMapEngineManager::_updateDiskFreeSpace()
QString path = getQGCMapEngine()->getCachePath(); QString path = getQGCMapEngine()->getCachePath();
if(!path.isEmpty()) { if(!path.isEmpty()) {
QStorageInfo info(path); QStorageInfo info(path);
quint32 total = (quint32)(info.bytesTotal() / 1024); quint32 total = static_cast<quint32>(info.bytesTotal() / 1024);
quint32 free = (quint32)(info.bytesFree() / 1024); quint32 free = static_cast<quint32>(info.bytesFree() / 1024);
qCDebug(QGCMapEngineManagerLog) << info.rootPath() << "has" << free << "Mbytes available."; qCDebug(QGCMapEngineManagerLog) << info.rootPath() << "has" << free << "Mbytes available.";
if(_freeDiskSpace != free) { if(_freeDiskSpace != free) {
_freeDiskSpace = free; _freeDiskSpace = free;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment