From e94dea72059e4c1cdb9ccc473b21e8357d567409 Mon Sep 17 00:00:00 2001 From: dogmaphobic Date: Tue, 12 Jul 2016 15:41:14 -0400 Subject: [PATCH] Map Reset Dialog Adding a dialog telling the user the map cache database has been reset. --- src/QGCApplication.cc | 7 +++++++ src/QtLocationPlugin/QGCMapEngine.cpp | 16 ++++++++++++++-- src/QtLocationPlugin/QGCMapEngine.h | 3 +++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/QGCApplication.cc b/src/QGCApplication.cc index 697fc95c0..4069124cf 100644 --- a/src/QGCApplication.cc +++ b/src/QGCApplication.cc @@ -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; diff --git a/src/QtLocationPlugin/QGCMapEngine.cpp b/src/QtLocationPlugin/QGCMapEngine.cpp index fc02dedd7..6b39c4483 100644 --- a/src/QtLocationPlugin/QGCMapEngine.cpp +++ b/src/QtLocationPlugin/QGCMapEngine.cpp @@ -126,6 +126,7 @@ QGCMapEngine::QGCMapEngine() , _maxDiskCache(0) , _maxMemCache(0) , _prunning(false) + , _cacheWasReset(false) { qRegisterMetaType(); qRegisterMetaType(); @@ -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); } //----------------------------------------------------------------------------- diff --git a/src/QtLocationPlugin/QGCMapEngine.h b/src/QtLocationPlugin/QGCMapEngine.h index 97fe8ee7e..8b38d1300 100644 --- a/src/QtLocationPlugin/QGCMapEngine.h +++ b/src/QtLocationPlugin/QGCMapEngine.h @@ -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(); -- 2.22.0