Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
5dd74dd7
Commit
5dd74dd7
authored
Mar 14, 2016
by
dogmaphobic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deleting old map tile disk cache if one is found.
parent
670eb375
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
6 deletions
+43
-6
QGCMapEngine.cpp
src/QtLocationPlugin/QGCMapEngine.cpp
+34
-2
QGCMapEngine.h
src/QtLocationPlugin/QGCMapEngine.h
+3
-0
QGeoTiledMappingManagerEngineQGC.cpp
src/QtLocationPlugin/QGeoTiledMappingManagerEngineQGC.cpp
+6
-4
No files found.
src/QtLocationPlugin/QGCMapEngine.cpp
View file @
5dd74dd7
...
...
@@ -45,6 +45,8 @@ Q_DECLARE_METATYPE(QList<QGCTile*>)
static
const
char
*
kDbFileName
=
"qgcMapCache.db"
;
static
QLocale
kLocale
;
#define CACHE_PATH_VERSION "100"
struct
stQGeoTileCacheQGCMapTypes
{
const
char
*
name
;
UrlFactory
::
MapType
type
;
...
...
@@ -157,10 +159,18 @@ QGCMapEngine::~QGCMapEngine()
void
QGCMapEngine
::
init
()
{
//-- Delete old style cache (if present)
#ifdef __mobile__
QString
c
acheDir
=
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppDataLocation
)
+
QLatin1String
(
"/QGCMapCache55"
);
QString
oldC
acheDir
=
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppDataLocation
)
+
QLatin1String
(
"/QGCMapCache55"
);
#else
QString
cacheDir
=
QStandardPaths
::
writableLocation
(
QStandardPaths
::
GenericCacheLocation
)
+
QLatin1String
(
"/QGCMapCache55"
);
QString
oldCacheDir
=
QStandardPaths
::
writableLocation
(
QStandardPaths
::
GenericCacheLocation
)
+
QLatin1String
(
"/QGCMapCache55"
);
#endif
_wipeDirectory
(
oldCacheDir
);
//-- Figure out cache path
#ifdef __mobile__
QString
cacheDir
=
QStandardPaths
::
writableLocation
(
QStandardPaths
::
AppDataLocation
)
+
QLatin1String
(
"/QGCMapCache"
CACHE_PATH_VERSION
);
#else
QString
cacheDir
=
QStandardPaths
::
writableLocation
(
QStandardPaths
::
GenericCacheLocation
)
+
QLatin1String
(
"/QGCMapCache"
CACHE_PATH_VERSION
);
#endif
if
(
!
QDir
::
root
().
mkpath
(
cacheDir
))
{
qWarning
()
<<
"Could not create mapping disk cache directory: "
<<
cacheDir
;
...
...
@@ -182,6 +192,28 @@ QGCMapEngine::init()
_worker
.
enqueueTask
(
task
);
}
//-----------------------------------------------------------------------------
bool
QGCMapEngine
::
_wipeDirectory
(
const
QString
&
dirPath
)
{
bool
result
=
true
;
QDir
dir
(
dirPath
);
if
(
dir
.
exists
(
dirPath
))
{
Q_FOREACH
(
QFileInfo
info
,
dir
.
entryInfoList
(
QDir
::
NoDotAndDotDot
|
QDir
::
System
|
QDir
::
Hidden
|
QDir
::
AllDirs
|
QDir
::
Files
,
QDir
::
DirsFirst
))
{
if
(
info
.
isDir
())
{
result
=
_wipeDirectory
(
info
.
absoluteFilePath
());
}
else
{
result
=
QFile
::
remove
(
info
.
absoluteFilePath
());
}
if
(
!
result
)
{
return
result
;
}
}
result
=
dir
.
rmdir
(
dirPath
);
}
return
result
;
}
//-----------------------------------------------------------------------------
void
QGCMapEngine
::
addTask
(
QGCMapTask
*
task
)
...
...
src/QtLocationPlugin/QGCMapEngine.h
View file @
5dd74dd7
...
...
@@ -119,6 +119,9 @@ private slots:
signals:
void
updateTotals
(
quint32
totaltiles
,
quint64
totalsize
,
quint32
defaulttiles
,
quint64
defaultsize
);
private:
bool
_wipeDirectory
(
const
QString
&
dirPath
);
private:
QGCCacheWorker
_worker
;
QString
_cachePath
;
...
...
src/QtLocationPlugin/QGeoTiledMappingManagerEngineQGC.cpp
View file @
5dd74dd7
...
...
@@ -194,10 +194,12 @@ QGeoTiledMappingManagerEngineQGC::_setCache(const QVariantMap ¶meters)
if
(
parameters
.
contains
(
QStringLiteral
(
"mapping.cache.directory"
)))
cacheDir
=
parameters
.
value
(
QStringLiteral
(
"mapping.cache.directory"
)).
toString
();
else
{
cacheDir
=
QStandardPaths
::
writableLocation
(
QStandardPaths
::
GenericCacheLocation
)
+
QLatin1String
(
"/QGCMapCache55"
);
if
(
!
QDir
::
root
().
mkpath
(
cacheDir
))
{
qWarning
()
<<
"Could not create mapping disk cache directory: "
<<
cacheDir
;
cacheDir
=
QDir
::
homePath
()
+
QLatin1String
(
"/.qgcmapscache/"
);
cacheDir
=
getQGCMapEngine
()
->
getCachePath
();
if
(
!
QFileInfo
(
cacheDir
).
exists
())
{
if
(
!
QDir
::
root
().
mkpath
(
cacheDir
))
{
qWarning
()
<<
"Could not create mapping disk cache directory: "
<<
cacheDir
;
cacheDir
=
QDir
::
homePath
()
+
QLatin1String
(
"/.qgcmapscache/"
);
}
}
}
if
(
!
QFileInfo
(
cacheDir
).
exists
())
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment