1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-06-27 03:29:16 +02:00

Asynchronous WMS/WMTS map loading

(also fixes crash on OS X)
This commit is contained in:
2020-03-17 21:06:51 +01:00
parent 9ce6e16b60
commit 82c0c1f8a7
19 changed files with 520 additions and 445 deletions

View File

@ -17,7 +17,7 @@ POI::POI(QObject *parent) : QObject(parent)
_useDEM = false;
}
bool POI::loadFile(const QString &path, bool dir)
bool POI::loadFile(const QString &path)
{
Data data(path, true);
FileIndex index;
@ -26,16 +26,8 @@ bool POI::loadFile(const QString &path, bool dir)
index.start = _data.size();
if (!data.isValid()) {
if (dir) {
if (data.errorLine())
_errorString += QString("%1:%2: %3\n").arg(path)
.arg(data.errorLine()).arg(data.errorString());
else
_errorString += path + ": " + data.errorString() + "\n";
} else {
_errorString = data.errorString();
_errorLine = data.errorLine();
}
_errorString = data.errorString();
_errorLine = data.errorLine();
return false;
}
@ -59,37 +51,22 @@ bool POI::loadFile(const QString &path, bool dir)
return true;
}
bool POI::loadFile(const QString &path)
{
_errorString.clear();
_errorLine = 0;
return loadFile(path, false);
}
bool POI::loadDir(const QString &path)
void POI::loadDir(const QString &path)
{
QDir md(path);
md.setFilter(QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
QFileInfoList fl = md.entryInfoList();
bool ret = true;
_errorString.clear();
_errorLine = 0;
for (int i = 0; i < fl.size(); i++) {
const QFileInfo &fi = fl.at(i);
if (fi.isDir()) {
if (!loadDir(fi.absoluteFilePath()))
ret = false;
} else {
if (!loadFile(fi.absoluteFilePath(), true))
ret = false;
}
if (fi.isDir())
loadDir(fi.absoluteFilePath());
else
if (!loadFile(fi.absoluteFilePath()))
qWarning(qPrintable(fi.absoluteFilePath() + ": "
+ _errorString));
}
return ret;
}
static bool cb(size_t data, void* context)

View File

@ -20,7 +20,7 @@ public:
POI(QObject *parent = 0);
bool loadFile(const QString &path);
bool loadDir(const QString &path);
void loadDir(const QString &path);
const QString &errorString() const {return _errorString;}
int errorLine() const {return _errorLine;}