1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-10-06 23:03:22 +02:00
GPXSee/src/mapdir.cpp

41 lines
794 B
C++
Raw Normal View History

#include <QDir>
2017-03-26 15:32:55 +02:00
#include "atlas.h"
2017-03-21 09:27:44 +01:00
#include "offlinemap.h"
2017-03-26 15:32:55 +02:00
#include "mapdir.h"
QList<Map*> MapDir::load(const QString &path, QObject *parent)
{
QList<Map*> maps;
QDir dir(path);
if (!dir.exists())
return maps;
if (!dir.isReadable()) {
qWarning("Map directory not readable: %s\n", qPrintable(path));
return maps;
}
QFileInfoList list = dir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot);
for (int i = 0; i < list.size(); i++) {
QFileInfo fileInfo = list.at(i);
2017-03-26 15:32:55 +02:00
Atlas *atlas = new Atlas(fileInfo.absoluteFilePath(), parent);
if (atlas->isValid())
maps.append(atlas);
else {
delete atlas;
OfflineMap *map = new OfflineMap(fileInfo.absoluteFilePath(),
parent);
if (map->isValid())
maps.append(map);
else
delete map;
}
}
return maps;
}