1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2025-01-18 19:52:09 +01:00

Code cleanup

This commit is contained in:
Martin Tůma 2019-01-18 00:17:28 +01:00
parent bd4af8c7e5
commit 735159fc79
27 changed files with 83 additions and 81 deletions

View File

@ -747,11 +747,11 @@ bool GUI::openFile(const QString &fileName)
bool GUI::loadFile(const QString &fileName) bool GUI::loadFile(const QString &fileName)
{ {
Data data; Data data(fileName);
QList<QList<GraphItem*> > graphs; QList<QList<GraphItem*> > graphs;
QList<PathItem*> paths; QList<PathItem*> paths;
if (data.loadFile(fileName)) { if (data.isValid()) {
for (int i = 0; i < data.tracks().count(); i++) { for (int i = 0; i < data.tracks().count(); i++) {
_trackDistance += data.tracks().at(i)->distance(); _trackDistance += data.tracks().at(i)->distance();
_time += data.tracks().at(i)->time(); _time += data.tracks().at(i)->time();

View File

@ -147,7 +147,7 @@ PathItem *MapView::addRoute(const Route &route)
return ri; return ri;
} }
void MapView::addWaypoints(const QList<Waypoint> &waypoints) void MapView::addWaypoints(const QVector<Waypoint> &waypoints)
{ {
for (int i = 0; i < waypoints.count(); i++) { for (int i = 0; i < waypoints.count(); i++) {
const Waypoint &w = waypoints.at(i); const Waypoint &w = waypoints.at(i);

View File

@ -78,7 +78,7 @@ private slots:
private: private:
PathItem *addTrack(const Track &track); PathItem *addTrack(const Track &track);
PathItem *addRoute(const Route &route); PathItem *addRoute(const Route &route);
void addWaypoints(const QList<Waypoint> &waypoints); void addWaypoints(const QVector<Waypoint> &waypoints);
void addPOI(const QList<Waypoint> &waypoints); void addPOI(const QList<Waypoint> &waypoints);
void loadPOI(); void loadPOI();
void clearPOI(); void clearPOI();

View File

@ -1,7 +1,7 @@
#include "csvparser.h" #include "csvparser.h"
bool CSVParser::parse(QFile *file, QList<TrackData> &tracks, bool CSVParser::parse(QFile *file, QList<TrackData> &tracks,
QList<RouteData> &routes, QList<Waypoint> &waypoints) QList<RouteData> &routes, QVector<Waypoint> &waypoints)
{ {
Q_UNUSED(tracks); Q_UNUSED(tracks);
Q_UNUSED(routes); Q_UNUSED(routes);

View File

@ -9,7 +9,7 @@ public:
CSVParser() : _errorLine(0) {} CSVParser() : _errorLine(0) {}
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes, bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
QList<Waypoint> &waypoints); QVector<Waypoint> &waypoints);
QString errorString() const {return _errorString;} QString errorString() const {return _errorString;}
int errorLine() const {return _errorLine;} int errorLine() const {return _errorLine;}

View File

@ -1,3 +1,4 @@
#include <QApplication>
#include <QFile> #include <QFile>
#include <QFileInfo> #include <QFileInfo>
#include <QLineF> #include <QLineF>
@ -75,34 +76,35 @@ void Data::processData()
} }
} }
bool Data::loadFile(const QString &fileName) Data::Data(const QString &fileName)
{ {
QFile file(fileName); QFile file(fileName);
QFileInfo fi(fileName); QFileInfo fi(fileName);
_valid = false;
_errorString.clear();
_errorLine = 0; _errorLine = 0;
if (!file.open(QFile::ReadOnly)) { if (!file.open(QFile::ReadOnly)) {
_errorString = qPrintable(file.errorString()); _errorString = qPrintable(file.errorString());
return false; return;
} }
QHash<QString, Parser*>::iterator it; QHash<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, _waypoints)) { if (it.value()->parse(&file, _trackData, _routeData, _waypoints)) {
processData(); processData();
return true; _valid = true;
return;
} else {
_errorLine = it.value()->errorLine();
_errorString = it.value()->errorString();
} }
_errorLine = it.value()->errorLine();
_errorString = it.value()->errorString();
} else { } else {
for (it = _parsers.begin(); it != _parsers.end(); it++) { for (it = _parsers.begin(); it != _parsers.end(); it++) {
if (it.value()->parse(&file, _trackData, _routeData, _waypoints)) { if (it.value()->parse(&file, _trackData, _routeData, _waypoints)) {
processData(); processData();
return true; _valid = true;
return;
} }
file.reset(); file.reset();
} }
@ -115,22 +117,24 @@ bool Data::loadFile(const QString &fileName)
_errorLine = 0; _errorLine = 0;
_errorString = "Unknown format"; _errorString = "Unknown format";
} }
return false;
} }
QString Data::formats() QString Data::formats()
{ {
return return
tr("Supported files") qApp->translate("Data", "Supported files")
+ " (*.csv *.fit *.gpx *.igc *.kml *.loc *.nmea *.plt *.rte *.slf *.tcx *.wpt);;" + " (*.csv *.fit *.gpx *.igc *.kml *.loc *.nmea *.plt *.rte *.slf *.tcx *.wpt);;"
+ tr("CSV files") + " (*.csv);;" + tr("FIT files") + " (*.fit);;" + qApp->translate("Data", "CSV files") + " (*.csv);;"
+ tr("GPX files") + " (*.gpx);;" + tr("IGC files") + " (*.igc);;" + qApp->translate("Data", "FIT files") + " (*.fit);;"
+ tr("KML files") + " (*.kml);;" + tr("LOC files") + " (*.loc);;" + qApp->translate("Data", "GPX files") + " (*.gpx);;"
+ tr("NMEA files") + " (*.nmea);;" + qApp->translate("Data", "IGC files") + " (*.igc);;"
+ tr("OziExplorer files") + " (*.plt *.rte *.wpt);;" + qApp->translate("Data", "KML files") + " (*.kml);;"
+ tr("SLF files") + " (*.slf);;" + tr("TCX files") + " (*.tcx);;" + qApp->translate("Data", "LOC files") + " (*.loc);;"
+ tr("All files") + " (*)"; + qApp->translate("Data", "NMEA files") + " (*.nmea);;"
+ qApp->translate("Data", "OziExplorer files") + " (*.plt *.rte *.wpt);;"
+ qApp->translate("Data", "SLF files") + " (*.slf);;"
+ qApp->translate("Data", "TCX files") + " (*.tcx);;"
+ qApp->translate("Data", "All files") + " (*)";
} }
QStringList Data::filter() QStringList Data::filter()

View File

@ -1,10 +1,8 @@
#ifndef DATA_H #ifndef DATA_H
#define DATA_H #define DATA_H
#include <QVector>
#include <QList> #include <QList>
#include <QHash> #include <QHash>
#include <QPointF>
#include <QString> #include <QString>
#include <QStringList> #include <QStringList>
#include "waypoint.h" #include "waypoint.h"
@ -13,21 +11,19 @@
#include "parser.h" #include "parser.h"
class Data : public QObject class Data
{ {
Q_OBJECT
public: public:
Data(QObject *parent = 0) : QObject(parent), _errorLine(0) {} Data(const QString &fileName);
~Data(); ~Data();
bool loadFile(const QString &fileName); bool isValid() const {return _valid;}
const QString &errorString() const {return _errorString;} const QString &errorString() const {return _errorString;}
int errorLine() const {return _errorLine;} int errorLine() const {return _errorLine;}
const QList<Track*> &tracks() const {return _tracks;} const QList<Track*> &tracks() const {return _tracks;}
const QList<Route*> &routes() const {return _routes;} const QList<Route*> &routes() const {return _routes;}
const QList<Waypoint> &waypoints() const {return _waypoints;} const QVector<Waypoint> &waypoints() const {return _waypoints;}
static QString formats(); static QString formats();
static QStringList filter(); static QStringList filter();
@ -37,12 +33,13 @@ public:
private: private:
void processData(); void processData();
bool _valid;
QString _errorString; QString _errorString;
int _errorLine; int _errorLine;
QList<Track*> _tracks; QList<Track*> _tracks;
QList<Route*> _routes; QList<Route*> _routes;
QList<Waypoint> _waypoints; QVector<Waypoint> _waypoints;
QList<TrackData> _trackData; QList<TrackData> _trackData;
QList<RouteData> _routeData; QList<RouteData> _routeData;

View File

@ -372,7 +372,7 @@ bool FITParser::parseHeader(CTX &ctx)
} }
bool FITParser::parse(QFile *file, QList<TrackData> &tracks, bool FITParser::parse(QFile *file, QList<TrackData> &tracks,
QList<RouteData> &routes, QList<Waypoint> &waypoints) QList<RouteData> &routes, QVector<Waypoint> &waypoints)
{ {
Q_UNUSED(routes); Q_UNUSED(routes);
Q_UNUSED(waypoints); Q_UNUSED(waypoints);

View File

@ -9,7 +9,7 @@ class FITParser : public Parser
{ {
public: public:
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes, bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
QList<Waypoint> &waypoints); QVector<Waypoint> &waypoints);
QString errorString() const {return _errorString;} QString errorString() const {return _errorString;}
int errorLine() const {return 0;} int errorLine() const {return 0;}

View File

@ -198,7 +198,7 @@ void GPXParser::track(TrackData &track)
} }
void GPXParser::gpx(QList<TrackData> &tracks, QList<RouteData> &routes, void GPXParser::gpx(QList<TrackData> &tracks, QList<RouteData> &routes,
QList<Waypoint> &waypoints) QVector<Waypoint> &waypoints)
{ {
while (_reader.readNextStartElement()) { while (_reader.readNextStartElement()) {
if (_reader.name() == QLatin1String("trk")) { if (_reader.name() == QLatin1String("trk")) {
@ -216,7 +216,7 @@ void GPXParser::gpx(QList<TrackData> &tracks, QList<RouteData> &routes,
} }
bool GPXParser::parse(QFile *file, QList<TrackData> &tracks, bool GPXParser::parse(QFile *file, QList<TrackData> &tracks,
QList<RouteData> &routes, QList<Waypoint> &waypoints) QList<RouteData> &routes, QVector<Waypoint> &waypoints)
{ {
_reader.clear(); _reader.clear();
_reader.setDevice(file); _reader.setDevice(file);

View File

@ -9,13 +9,13 @@ class GPXParser : public Parser
{ {
public: public:
bool parse(QFile *file, QList<TrackData> &tracks, bool parse(QFile *file, QList<TrackData> &tracks,
QList<RouteData> &routes, QList<Waypoint> &waypoints); QList<RouteData> &routes, QVector<Waypoint> &waypoints);
QString errorString() const {return _reader.errorString();} QString errorString() const {return _reader.errorString();}
int errorLine() const {return _reader.lineNumber();} int errorLine() const {return _reader.lineNumber();}
private: private:
void gpx(QList<TrackData> &tracks, QList<RouteData> &routes, void gpx(QList<TrackData> &tracks, QList<RouteData> &routes,
QList<Waypoint> &waypoints); QVector<Waypoint> &waypoints);
void track(TrackData &track); void track(TrackData &track);
void trackpoints(TrackData &track); void trackpoints(TrackData &track);
void routepoints(RouteData &route, QList<TrackData> &tracks); void routepoints(RouteData &route, QList<TrackData> &tracks);

View File

@ -192,7 +192,7 @@ bool IGCParser::readCRecord(RouteData &route, const char *line, int len)
} }
bool IGCParser::parse(QFile *file, QList<TrackData> &tracks, bool IGCParser::parse(QFile *file, QList<TrackData> &tracks,
QList<RouteData> &routes, QList<Waypoint> &waypoints) QList<RouteData> &routes, QVector<Waypoint> &waypoints)
{ {
Q_UNUSED(waypoints); Q_UNUSED(waypoints);
qint64 len; qint64 len;

View File

@ -12,7 +12,7 @@ public:
IGCParser() : _errorLine(0) {} IGCParser() : _errorLine(0) {}
bool parse(QFile *file, QList<TrackData> &tracks, bool parse(QFile *file, QList<TrackData> &tracks,
QList<RouteData> &routes, QList<Waypoint> &waypoints); QList<RouteData> &routes, QVector<Waypoint> &waypoints);
QString errorString() const {return _errorString;} QString errorString() const {return _errorString;}
int errorLine() const {return _errorLine;} int errorLine() const {return _errorLine;}

View File

@ -381,7 +381,7 @@ void KMLParser::multiTrack(TrackData &t)
} }
void KMLParser::multiGeometry(QList<TrackData> &tracks, void KMLParser::multiGeometry(QList<TrackData> &tracks,
QList<Waypoint> &waypoints, const QString &name, const QString &desc, QVector<Waypoint> &waypoints, const QString &name, const QString &desc,
const QDateTime timestamp) const QDateTime timestamp)
{ {
while (_reader.readNextStartElement()) { while (_reader.readNextStartElement()) {
@ -403,7 +403,7 @@ void KMLParser::multiGeometry(QList<TrackData> &tracks,
} }
} }
void KMLParser::placemark(QList<TrackData> &tracks, QList<Waypoint> &waypoints) void KMLParser::placemark(QList<TrackData> &tracks, QVector<Waypoint> &waypoints)
{ {
QString name, desc; QString name, desc;
QDateTime timestamp; QDateTime timestamp;
@ -448,7 +448,7 @@ void KMLParser::placemark(QList<TrackData> &tracks, QList<Waypoint> &waypoints)
} }
} }
void KMLParser::folder(QList<TrackData> &tracks, QList<Waypoint> &waypoints) void KMLParser::folder(QList<TrackData> &tracks, QVector<Waypoint> &waypoints)
{ {
while (_reader.readNextStartElement()) { while (_reader.readNextStartElement()) {
if (_reader.name() == QLatin1String("Placemark")) if (_reader.name() == QLatin1String("Placemark"))
@ -460,7 +460,7 @@ void KMLParser::folder(QList<TrackData> &tracks, QList<Waypoint> &waypoints)
} }
} }
void KMLParser::document(QList<TrackData> &tracks, QList<Waypoint> &waypoints) void KMLParser::document(QList<TrackData> &tracks, QVector<Waypoint> &waypoints)
{ {
while (_reader.readNextStartElement()) { while (_reader.readNextStartElement()) {
if (_reader.name() == QLatin1String("Placemark")) if (_reader.name() == QLatin1String("Placemark"))
@ -472,7 +472,7 @@ void KMLParser::document(QList<TrackData> &tracks, QList<Waypoint> &waypoints)
} }
} }
void KMLParser::kml(QList<TrackData> &tracks, QList<Waypoint> &waypoints) void KMLParser::kml(QList<TrackData> &tracks, QVector<Waypoint> &waypoints)
{ {
while (_reader.readNextStartElement()) { while (_reader.readNextStartElement()) {
if (_reader.name() == QLatin1String("Document")) if (_reader.name() == QLatin1String("Document"))
@ -487,7 +487,7 @@ void KMLParser::kml(QList<TrackData> &tracks, QList<Waypoint> &waypoints)
} }
bool KMLParser::parse(QFile *file, QList<TrackData> &tracks, bool KMLParser::parse(QFile *file, QList<TrackData> &tracks,
QList<RouteData> &routes, QList<Waypoint> &waypoints) QList<RouteData> &routes, QVector<Waypoint> &waypoints)
{ {
Q_UNUSED(routes); Q_UNUSED(routes);

View File

@ -9,16 +9,16 @@ class KMLParser : public Parser
{ {
public: public:
bool parse(QFile *file, QList<TrackData> &tracks, bool parse(QFile *file, QList<TrackData> &tracks,
QList<RouteData> &routes, QList<Waypoint> &waypoints); QList<RouteData> &routes, QVector<Waypoint> &waypoints);
QString errorString() const {return _reader.errorString();} QString errorString() const {return _reader.errorString();}
int errorLine() const {return _reader.lineNumber();} int errorLine() const {return _reader.lineNumber();}
private: private:
void kml(QList<TrackData> &tracks, QList<Waypoint> &waypoints); void kml(QList<TrackData> &tracks, QVector<Waypoint> &waypoints);
void document(QList<TrackData> &tracks, QList<Waypoint> &waypoints); void document(QList<TrackData> &tracks, QVector<Waypoint> &waypoints);
void folder(QList<TrackData> &tracks, QList<Waypoint> &waypoints); void folder(QList<TrackData> &tracks, QVector<Waypoint> &waypoints);
void placemark(QList<TrackData> &tracks, QList<Waypoint> &waypoints); void placemark(QList<TrackData> &tracks, QVector<Waypoint> &waypoints);
void multiGeometry(QList<TrackData> &tracks, QList<Waypoint> &waypoints, void multiGeometry(QList<TrackData> &tracks, QVector<Waypoint> &waypoints,
const QString &name, const QString &desc, const QDateTime timestamp); const QString &name, const QString &desc, const QDateTime timestamp);
void track(TrackData &track); void track(TrackData &track);
void multiTrack(TrackData &t); void multiTrack(TrackData &t);

View File

@ -46,7 +46,7 @@ void LOCParser::waypoint(Waypoint &waypoint)
_reader.raiseError("Missing waypoint coordinates"); _reader.raiseError("Missing waypoint coordinates");
} }
void LOCParser::loc(QList<Waypoint> &waypoints) void LOCParser::loc(QVector<Waypoint> &waypoints)
{ {
while (_reader.readNextStartElement()) { while (_reader.readNextStartElement()) {
if (_reader.name() == QLatin1String("waypoint")) { if (_reader.name() == QLatin1String("waypoint")) {
@ -58,7 +58,7 @@ void LOCParser::loc(QList<Waypoint> &waypoints)
} }
bool LOCParser::parse(QFile *file, QList<TrackData> &tracks, bool LOCParser::parse(QFile *file, QList<TrackData> &tracks,
QList<RouteData> &routes, QList<Waypoint> &waypoints) QList<RouteData> &routes, QVector<Waypoint> &waypoints)
{ {
Q_UNUSED(tracks); Q_UNUSED(tracks);
Q_UNUSED(routes); Q_UNUSED(routes);

View File

@ -8,12 +8,12 @@ class LOCParser : public Parser
{ {
public: public:
bool parse(QFile *file, QList<TrackData> &tracks, bool parse(QFile *file, QList<TrackData> &tracks,
QList<RouteData> &routes, QList<Waypoint> &waypoints); QList<RouteData> &routes, QVector<Waypoint> &waypoints);
QString errorString() const {return _reader.errorString();} QString errorString() const {return _reader.errorString();}
int errorLine() const {return _reader.lineNumber();} int errorLine() const {return _reader.lineNumber();}
private: private:
void loc(QList<Waypoint> &waypoints); void loc(QVector<Waypoint> &waypoints);
void waypoint(Waypoint &waypoint); void waypoint(Waypoint &waypoint);
Coordinates coordinates(); Coordinates coordinates();

View File

@ -372,7 +372,7 @@ bool NMEAParser::readGGA(TrackData &track, const char *line, int len)
return true; return true;
} }
bool NMEAParser::readWPL(QList<Waypoint> &waypoints, const char *line, int len) bool NMEAParser::readWPL(QVector<Waypoint> &waypoints, const char *line, int len)
{ {
int col = 1; int col = 1;
const char *vp = line; const char *vp = line;
@ -478,7 +478,7 @@ bool NMEAParser::readZDA(const char *line, int len)
} }
bool NMEAParser::parse(QFile *file, QList<TrackData> &tracks, bool NMEAParser::parse(QFile *file, QList<TrackData> &tracks,
QList<RouteData> &routes, QList<Waypoint> &waypoints) QList<RouteData> &routes, QVector<Waypoint> &waypoints)
{ {
Q_UNUSED(routes); Q_UNUSED(routes);
qint64 len; qint64 len;

View File

@ -11,7 +11,7 @@ public:
NMEAParser() : _errorLine(0), _GGA(false) {} NMEAParser() : _errorLine(0), _GGA(false) {}
bool parse(QFile *file, QList<TrackData> &tracks, bool parse(QFile *file, QList<TrackData> &tracks,
QList<RouteData> &routes, QList<Waypoint> &waypoints); QList<RouteData> &routes, QVector<Waypoint> &waypoints);
QString errorString() const {return _errorString;} QString errorString() const {return _errorString;}
int errorLine() const {return _errorLine;} int errorLine() const {return _errorLine;}
@ -27,7 +27,7 @@ private:
bool readRMC(TrackData &track, const char *line, int len); bool readRMC(TrackData &track, const char *line, int len);
bool readGGA(TrackData &track, const char *line, int len); bool readGGA(TrackData &track, const char *line, int len);
bool readWPL(QList<Waypoint> &waypoints, const char *line, int len); bool readWPL(QVector<Waypoint> &waypoints, const char *line, int len);
bool readZDA(const char *line, int len); bool readZDA(const char *line, int len);
int _errorLine; int _errorLine;

View File

@ -27,7 +27,7 @@ static QByteArray &decode(QByteArray &ba)
bool PLTParser::parse(QFile *file, QList<TrackData> &tracks, bool PLTParser::parse(QFile *file, QList<TrackData> &tracks,
QList<RouteData> &routes, QList<Waypoint> &waypoints) QList<RouteData> &routes, QVector<Waypoint> &waypoints)
{ {
Q_UNUSED(waypoints); Q_UNUSED(waypoints);
Q_UNUSED(routes); Q_UNUSED(routes);
@ -113,7 +113,7 @@ bool PLTParser::parse(QFile *file, QList<TrackData> &tracks,
} }
bool RTEParser::parse(QFile *file, QList<TrackData> &tracks, bool RTEParser::parse(QFile *file, QList<TrackData> &tracks,
QList<RouteData> &routes, QList<Waypoint> &waypoints) QList<RouteData> &routes, QVector<Waypoint> &waypoints)
{ {
Q_UNUSED(waypoints); Q_UNUSED(waypoints);
Q_UNUSED(tracks); Q_UNUSED(tracks);
@ -211,7 +211,7 @@ bool RTEParser::parse(QFile *file, QList<TrackData> &tracks,
} }
bool WPTParser::parse(QFile *file, QList<TrackData> &tracks, bool WPTParser::parse(QFile *file, QList<TrackData> &tracks,
QList<RouteData> &routes, QList<Waypoint> &waypoints) QList<RouteData> &routes, QVector<Waypoint> &waypoints)
{ {
Q_UNUSED(tracks); Q_UNUSED(tracks);
Q_UNUSED(routes); Q_UNUSED(routes);

View File

@ -9,7 +9,7 @@ public:
PLTParser() : _errorLine(0) {} PLTParser() : _errorLine(0) {}
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes, bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
QList<Waypoint> &waypoints); QVector<Waypoint> &waypoints);
QString errorString() const {return _errorString;} QString errorString() const {return _errorString;}
int errorLine() const {return _errorLine;} int errorLine() const {return _errorLine;}
@ -24,7 +24,7 @@ public:
RTEParser() : _errorLine(0) {} RTEParser() : _errorLine(0) {}
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes, bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
QList<Waypoint> &waypoints); QVector<Waypoint> &waypoints);
QString errorString() const {return _errorString;} QString errorString() const {return _errorString;}
int errorLine() const {return _errorLine;} int errorLine() const {return _errorLine;}
@ -39,7 +39,7 @@ public:
WPTParser() : _errorLine(0) {} WPTParser() : _errorLine(0) {}
bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes, bool parse(QFile *file, QList<TrackData> &tracks, QList<RouteData> &routes,
QList<Waypoint> &waypoints); QVector<Waypoint> &waypoints);
QString errorString() const {return _errorString;} QString errorString() const {return _errorString;}
int errorLine() const {return _errorLine;} int errorLine() const {return _errorLine;}

View File

@ -3,6 +3,7 @@
#include <QString> #include <QString>
#include <QList> #include <QList>
#include <QVector>
#include <QFile> #include <QFile>
#include "trackdata.h" #include "trackdata.h"
#include "routedata.h" #include "routedata.h"
@ -15,7 +16,7 @@ public:
virtual ~Parser() {} virtual ~Parser() {}
virtual bool parse(QFile *file, QList<TrackData> &tracks, virtual bool parse(QFile *file, QList<TrackData> &tracks,
QList<RouteData> &routes, QList<Waypoint> &waypoints) = 0; QList<RouteData> &routes, QVector<Waypoint> &waypoints) = 0;
virtual QString errorString() const = 0; virtual QString errorString() const = 0;
virtual int errorLine() const = 0; virtual int errorLine() const = 0;
}; };

View File

@ -14,13 +14,13 @@ POI::POI(QObject *parent) : QObject(parent)
bool POI::loadFile(const QString &path, bool dir) bool POI::loadFile(const QString &path, bool dir)
{ {
Data data; Data data(path);
FileIndex index; FileIndex index;
index.enabled = true; index.enabled = true;
index.start = _data.size(); index.start = _data.size();
if (!data.loadFile(path)) { if (!data.isValid()) {
if (dir) { if (dir) {
if (data.errorLine()) if (data.errorLine())
_errorString += QString("%1:%2: %3\n").arg(path) _errorString += QString("%1:%2: %3\n").arg(path)

View File

@ -99,7 +99,7 @@ void SLFParser::activity(TrackData &track)
} }
bool SLFParser::parse(QFile *file, QList<TrackData> &tracks, bool SLFParser::parse(QFile *file, QList<TrackData> &tracks,
QList<RouteData> &routes, QList<Waypoint> &waypoints) QList<RouteData> &routes, QVector<Waypoint> &waypoints)
{ {
Q_UNUSED(waypoints); Q_UNUSED(waypoints);
Q_UNUSED(routes); Q_UNUSED(routes);

View File

@ -9,7 +9,7 @@ class QDateTime;
class SLFParser : public Parser class SLFParser : public Parser
{ {
bool parse(QFile *file, QList<TrackData> &tracks, bool parse(QFile *file, QList<TrackData> &tracks,
QList<RouteData> &routes, QList<Waypoint> &waypoints); QList<RouteData> &routes, QVector<Waypoint> &waypoints);
QString errorString() const {return _reader.errorString();} QString errorString() const {return _reader.errorString();}
int errorLine() const {return _reader.lineNumber();} int errorLine() const {return _reader.lineNumber();}

View File

@ -141,7 +141,7 @@ void TCXParser::lap(TrackData &track)
} }
} }
void TCXParser::course(QList<Waypoint> &waypoints, TrackData &track) void TCXParser::course(QVector<Waypoint> &waypoints, TrackData &track)
{ {
while (_reader.readNextStartElement()) { while (_reader.readNextStartElement()) {
if (_reader.name() == QLatin1String("Track")) if (_reader.name() == QLatin1String("Track"))
@ -174,7 +174,7 @@ void TCXParser::activity(TrackData &track)
} }
} }
void TCXParser::courses(QList<TrackData> &tracks, QList<Waypoint> &waypoints) void TCXParser::courses(QList<TrackData> &tracks, QVector<Waypoint> &waypoints)
{ {
while (_reader.readNextStartElement()) { while (_reader.readNextStartElement()) {
if (_reader.name() == QLatin1String("Course")) { if (_reader.name() == QLatin1String("Course")) {
@ -220,7 +220,7 @@ void TCXParser::activities(QList<TrackData> &tracks)
} }
} }
void TCXParser::tcx(QList<TrackData> &tracks, QList<Waypoint> &waypoints) void TCXParser::tcx(QList<TrackData> &tracks, QVector<Waypoint> &waypoints)
{ {
while (_reader.readNextStartElement()) { while (_reader.readNextStartElement()) {
if (_reader.name() == QLatin1String("Courses")) if (_reader.name() == QLatin1String("Courses"))
@ -233,7 +233,7 @@ void TCXParser::tcx(QList<TrackData> &tracks, QList<Waypoint> &waypoints)
} }
bool TCXParser::parse(QFile *file, QList<TrackData> &tracks, bool TCXParser::parse(QFile *file, QList<TrackData> &tracks,
QList<RouteData> &routes, QList<Waypoint> &waypoints) QList<RouteData> &routes, QVector<Waypoint> &waypoints)
{ {
Q_UNUSED(routes); Q_UNUSED(routes);

View File

@ -9,17 +9,17 @@ class TCXParser : public Parser
{ {
public: public:
bool parse(QFile *file, QList<TrackData> &tracks, bool parse(QFile *file, QList<TrackData> &tracks,
QList<RouteData> &routes, QList<Waypoint> &waypoints); QList<RouteData> &routes, QVector<Waypoint> &waypoints);
QString errorString() const {return _reader.errorString();} QString errorString() const {return _reader.errorString();}
int errorLine() const {return _reader.lineNumber();} int errorLine() const {return _reader.lineNumber();}
private: private:
void tcx(QList<TrackData> &tracks, QList<Waypoint> &waypoints); void tcx(QList<TrackData> &tracks, QVector<Waypoint> &waypoints);
void courses(QList<TrackData> &tracks, QList<Waypoint> &waypoints); void courses(QList<TrackData> &tracks, QVector<Waypoint> &waypoints);
void activities(QList<TrackData> &tracks); void activities(QList<TrackData> &tracks);
void multiSportSession(QList<TrackData> &tracks); void multiSportSession(QList<TrackData> &tracks);
void sport(QList<TrackData> &tracks); void sport(QList<TrackData> &tracks);
void course(QList<Waypoint> &waypoints, TrackData &track); void course(QVector<Waypoint> &waypoints, TrackData &track);
void activity(TrackData &track); void activity(TrackData &track);
void lap(TrackData &track); void lap(TrackData &track);
void trackpoints(TrackData &track); void trackpoints(TrackData &track);