Commit b5164290 authored by Gus Grubba's avatar Gus Grubba Committed by GitHub

Merge pull request #3803 from dogmaphobic/offlineMapDialog

Map Reset Dialog
parents b2a7459c e94dea72
......@@ -116,6 +116,8 @@
#endif
#endif
#include "QGCMapEngine.h"
QGCApplication* QGCApplication::_app = NULL;
const char* QGCApplication::parameterFileExtension = "params";
......@@ -445,6 +447,11 @@ bool QGCApplication::_initForNormalAppBoot(void)
"Your saved settings have been reset to defaults.");
}
if (getQGCMapEngine()->wasCacheReset()) {
showMessage("The Offline Map Cache database has been upgraded. "
"Your old map cache sets have been reset.");
}
settings.sync();
return true;
......
......@@ -126,6 +126,7 @@ QGCMapEngine::QGCMapEngine()
, _maxDiskCache(0)
, _maxMemCache(0)
, _prunning(false)
, _cacheWasReset(false)
{
qRegisterMetaType<QGCMapTask::TaskType>();
qRegisterMetaType<QGCTile>();
......@@ -142,6 +143,17 @@ QGCMapEngine::~QGCMapEngine()
delete _urlFactory;
}
//-----------------------------------------------------------------------------
void
QGCMapEngine::_checkWipeDirectory(const QString& dirPath)
{
QDir dir(dirPath);
if (dir.exists(dirPath)) {
_cacheWasReset = true;
_wipeDirectory(dirPath);
}
}
//-----------------------------------------------------------------------------
void
QGCMapEngine::_wipeOldCaches()
......@@ -152,13 +164,13 @@ QGCMapEngine::_wipeOldCaches()
#else
oldCacheDir = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + QLatin1String("/QGCMapCache55");
#endif
_wipeDirectory(oldCacheDir);
_checkWipeDirectory(oldCacheDir);
#ifdef __mobile__
oldCacheDir = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation) + QLatin1String("/QGCMapCache100");
#else
oldCacheDir = QStandardPaths::writableLocation(QStandardPaths::GenericCacheLocation) + QLatin1String("/QGCMapCache100");
#endif
_wipeDirectory(oldCacheDir);
_checkWipeDirectory(oldCacheDir);
}
//-----------------------------------------------------------------------------
......
......@@ -86,6 +86,7 @@ public:
void setMaxMemCache (quint32 size);
const QString getCachePath () { return _cachePath; }
const QString getCacheFilename () { return _cacheFile; }
bool wasCacheReset () { return _cacheWasReset; }
UrlFactory* urlFactory () { return _urlFactory; }
......@@ -108,6 +109,7 @@ signals:
private:
void _wipeOldCaches ();
void _checkWipeDirectory (const QString& dirPath);
bool _wipeDirectory (const QString& dirPath);
private:
......@@ -120,6 +122,7 @@ private:
quint32 _maxDiskCache;
quint32 _maxMemCache;
bool _prunning;
bool _cacheWasReset;
};
extern QGCMapEngine* getQGCMapEngine();
......
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