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