1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-07-15 19:34:24 +02:00

Do not depend on the file extension when loading the maps

This commit is contained in:
2022-04-29 23:16:10 +02:00
parent 40febb8c0e
commit 93aadb7e74
34 changed files with 225 additions and 99 deletions

View File

@ -206,26 +206,16 @@ void MapSource::map(QXmlStreamReader &reader, Config &config)
}
}
bool MapSource::isMap(const QString &path)
{
QFile file(path);
if (!file.open(QFile::ReadOnly | QFile::Text))
return false;
QXmlStreamReader reader(&file);
if (reader.readNextStartElement() && reader.name() == QLatin1String("map"))
return true;
return false;
}
Map *MapSource::loadMap(const QString &path)
Map *MapSource::create(const QString &path, const Projection &proj, bool *isDir)
{
Q_UNUSED(proj);
Config config;
QFile file(path);
if (isDir)
*isDir = false;
if (!file.open(QFile::ReadOnly | QFile::Text))
return new InvalidMap(path, file.errorString());