mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-28 05:34:47 +01:00
Code cleanup
This commit is contained in:
parent
143f53fbd9
commit
a6b327f773
@ -20,13 +20,11 @@ bool MapList::loadMap(Map* map, const QString &path, bool dir)
|
||||
_errorString += path + ": " + map->errorString() + "\n";
|
||||
else
|
||||
_errorString = map->errorString();
|
||||
|
||||
delete map;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool MapList::loadSource(const QString &path, bool dir)
|
||||
Map *MapList::loadSource(const QString &path, bool dir)
|
||||
{
|
||||
QString err;
|
||||
Map *map = MapSource::loadMap(path, err);
|
||||
@ -36,31 +34,39 @@ bool MapList::loadSource(const QString &path, bool dir)
|
||||
_errorString += path + ": " + err + "\n";
|
||||
else
|
||||
_errorString = err;
|
||||
return false;
|
||||
}
|
||||
map->setParent(this);
|
||||
} else
|
||||
map->setParent(this);
|
||||
|
||||
return loadMap(map, path, dir);
|
||||
return map;
|
||||
}
|
||||
|
||||
bool MapList::loadFile(const QString &path, bool *atlas, bool dir)
|
||||
{
|
||||
QFileInfo fi(path);
|
||||
QString suffix = fi.suffix().toLower();
|
||||
Map *map;
|
||||
|
||||
if (Atlas::isAtlas(path)) {
|
||||
*atlas = true;
|
||||
return loadMap(new Atlas(path, this), path, dir);
|
||||
} else if (suffix == "xml")
|
||||
return loadSource(path, dir);
|
||||
else if (suffix == "jnx")
|
||||
return loadMap(new JNXMap(path, this), path, dir);
|
||||
map = new Atlas(path, this);
|
||||
} else if (suffix == "xml") {
|
||||
if (!(map = loadSource(path, dir)))
|
||||
return false;
|
||||
} else if (suffix == "jnx")
|
||||
map = new JNXMap(path, this);
|
||||
else if (suffix == "tif" || suffix == "tiff")
|
||||
return loadMap(new GeoTIFFMap(path, this), path, dir);
|
||||
map = new GeoTIFFMap(path, this);
|
||||
else if (suffix == "mbtiles")
|
||||
return loadMap(new MBTilesMap(path, this), path, dir);
|
||||
map = new MBTilesMap(path, this);
|
||||
else
|
||||
return loadMap(new OziMap(path, this), path, dir);
|
||||
map = new OziMap(path, this);
|
||||
|
||||
if (!loadMap(map, path, dir)) {
|
||||
delete map;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MapList::loadDirR(const QString &path)
|
||||
@ -104,13 +110,6 @@ bool MapList::loadDir(const QString &path)
|
||||
return loadDirR(path);
|
||||
}
|
||||
|
||||
void MapList::clear()
|
||||
{
|
||||
for (int i = 0; i < _maps.count(); i++)
|
||||
delete _maps.at(i);
|
||||
_maps.clear();
|
||||
}
|
||||
|
||||
QString MapList::formats()
|
||||
{
|
||||
return
|
||||
|
@ -15,7 +15,6 @@ public:
|
||||
|
||||
bool loadFile(const QString &path);
|
||||
bool loadDir(const QString &path);
|
||||
void clear();
|
||||
|
||||
const QList<Map*> &maps() const {return _maps;}
|
||||
const QString &errorString() const {return _errorString;}
|
||||
@ -26,7 +25,7 @@ public:
|
||||
private:
|
||||
bool loadFile(const QString &path, bool *atlas, bool dir);
|
||||
bool loadDirR(const QString &path);
|
||||
bool loadSource(const QString &path, bool dir);
|
||||
Map *loadSource(const QString &path, bool dir);
|
||||
bool loadMap(Map *map, const QString &path, bool dir);
|
||||
|
||||
QList<Map*> _maps;
|
||||
|
Loading…
Reference in New Issue
Block a user