mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-18 11:52:08 +01:00
Cleanup the data loading code
This commit is contained in:
parent
eb9767f2dd
commit
71f0e1d0ac
@ -44,37 +44,37 @@ static CUPParser cup;
|
|||||||
static GPIParser gpi;
|
static GPIParser gpi;
|
||||||
static SMLParser sml;
|
static SMLParser sml;
|
||||||
|
|
||||||
static QHash<QString, Parser*> parsers()
|
static QMap<QString, Parser*> parsers()
|
||||||
{
|
{
|
||||||
QHash<QString, Parser*> hash;
|
QMap<QString, Parser*> map;
|
||||||
|
|
||||||
hash.insert("gpx", &gpx);
|
map.insert("gpx", &gpx);
|
||||||
hash.insert("tcx", &tcx);
|
map.insert("tcx", &tcx);
|
||||||
hash.insert("kml", &kml);
|
map.insert("kml", &kml);
|
||||||
hash.insert("fit", &fit);
|
map.insert("fit", &fit);
|
||||||
hash.insert("csv", &csv);
|
map.insert("csv", &csv);
|
||||||
hash.insert("igc", &igc);
|
map.insert("igc", &igc);
|
||||||
hash.insert("nmea", &nmea);
|
map.insert("nmea", &nmea);
|
||||||
hash.insert("plt", &plt);
|
map.insert("plt", &plt);
|
||||||
hash.insert("wpt", &wpt);
|
map.insert("wpt", &wpt);
|
||||||
hash.insert("rte", &rte);
|
map.insert("rte", &rte);
|
||||||
hash.insert("loc", &loc);
|
map.insert("loc", &loc);
|
||||||
hash.insert("slf", &slf);
|
map.insert("slf", &slf);
|
||||||
#ifdef ENABLE_GEOJSON
|
#ifdef ENABLE_GEOJSON
|
||||||
hash.insert("json", &geojson);
|
map.insert("json", &geojson);
|
||||||
hash.insert("geojson", &geojson);
|
map.insert("geojson", &geojson);
|
||||||
#endif // ENABLE_GEOJSON
|
#endif // ENABLE_GEOJSON
|
||||||
hash.insert("jpeg", &exif);
|
map.insert("jpeg", &exif);
|
||||||
hash.insert("jpg", &exif);
|
map.insert("jpg", &exif);
|
||||||
hash.insert("cup", &cup);
|
map.insert("cup", &cup);
|
||||||
hash.insert("gpi", &gpi);
|
map.insert("gpi", &gpi);
|
||||||
hash.insert("sml", &sml);
|
map.insert("sml", &sml);
|
||||||
|
|
||||||
return hash;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QHash<QString, Parser*> Data::_parsers = parsers();
|
QMap<QString, Parser*> Data::_parsers = parsers();
|
||||||
bool Data::_useDEM = false;
|
bool Data::_useDEM = false;
|
||||||
|
|
||||||
void Data::processData(QList<TrackData> &trackData, QList<RouteData> &routeData)
|
void Data::processData(QList<TrackData> &trackData, QList<RouteData> &routeData)
|
||||||
@ -130,7 +130,7 @@ Data::Data(const QString &fileName, bool poi)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<QString, Parser*>::iterator it;
|
QMap<QString, Parser*>::iterator it;
|
||||||
if ((it = _parsers.find(fi.suffix().toLower())) != _parsers.end()) {
|
if ((it = _parsers.find(fi.suffix().toLower())) != _parsers.end()) {
|
||||||
if (it.value()->parse(&file, trackData, routeData, _polygons,
|
if (it.value()->parse(&file, trackData, routeData, _polygons,
|
||||||
_waypoints)) {
|
_waypoints)) {
|
||||||
@ -166,17 +166,8 @@ Data::Data(const QString &fileName, bool poi)
|
|||||||
|
|
||||||
QString Data::formats()
|
QString Data::formats()
|
||||||
{
|
{
|
||||||
QStringList l(filter());
|
|
||||||
qSort(l);
|
|
||||||
QString supported;
|
|
||||||
for (int i = 0; i < l.size(); i++) {
|
|
||||||
supported += l.at(i);
|
|
||||||
if (i != l.size() - 1)
|
|
||||||
supported += " ";
|
|
||||||
}
|
|
||||||
|
|
||||||
return
|
return
|
||||||
qApp->translate("Data", "Supported files") + " (" + supported + ");;"
|
qApp->translate("Data", "Supported files") + " (" + filter().join(" ") + ");;"
|
||||||
+ qApp->translate("Data", "CSV files") + " (*.csv);;"
|
+ qApp->translate("Data", "CSV files") + " (*.csv);;"
|
||||||
+ qApp->translate("Data", "CUP files") + " (*.cup);;"
|
+ qApp->translate("Data", "CUP files") + " (*.cup);;"
|
||||||
+ qApp->translate("Data", "FIT files") + " (*.fit);;"
|
+ qApp->translate("Data", "FIT files") + " (*.fit);;"
|
||||||
@ -200,10 +191,10 @@ QString Data::formats()
|
|||||||
QStringList Data::filter()
|
QStringList Data::filter()
|
||||||
{
|
{
|
||||||
QStringList filter;
|
QStringList filter;
|
||||||
QHash<QString, Parser*>::iterator it;
|
|
||||||
|
|
||||||
for (it = _parsers.begin(); it != _parsers.end(); it++)
|
for (QMap<QString, Parser*>::iterator it = _parsers.begin();
|
||||||
filter << QString("*.%1").arg(it.key());
|
it != _parsers.end(); it++)
|
||||||
|
filter << "*." + it.key();
|
||||||
|
|
||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define DATA_H
|
#define DATA_H
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QHash>
|
#include <QMap>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include "waypoint.h"
|
#include "waypoint.h"
|
||||||
@ -42,7 +42,7 @@ private:
|
|||||||
QList<Area> _polygons;
|
QList<Area> _polygons;
|
||||||
QVector<Waypoint> _waypoints;
|
QVector<Waypoint> _waypoints;
|
||||||
|
|
||||||
static QHash<QString, Parser*> _parsers;
|
static QMap<QString, Parser*> _parsers;
|
||||||
static bool _useDEM;
|
static bool _useDEM;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user