From 6cc22afcdc713a182d874f33b0794175f053e1da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Tue, 25 Oct 2016 19:46:44 +0200 Subject: [PATCH] Added file changes missing in last commit... --- gpxsee.pro | 6 ++-- lang/gpxsee_cs.ts | 86 +++++++++++++++++++++++++---------------------- src/csvparser.cpp | 10 +++--- src/data.cpp | 2 ++ src/gpxparser.cpp | 8 +++++ src/gui.cpp | 12 ++++--- 6 files changed, 72 insertions(+), 52 deletions(-) diff --git a/gpxsee.pro b/gpxsee.pro index 40c00b92..fa4a069f 100644 --- a/gpxsee.pro +++ b/gpxsee.pro @@ -59,7 +59,8 @@ HEADERS += src/config.h \ src/coordinates.h \ src/tile.h \ src/rd.h \ - src/wgs84.h + src/wgs84.h \ + src/kmlparser.h SOURCES += src/main.cpp \ src/gui.cpp \ src/poi.cpp \ @@ -101,7 +102,8 @@ SOURCES += src/main.cpp \ src/gpxparser.cpp \ src/tcxparser.cpp \ src/csvparser.cpp \ - src/coordinates.cpp + src/coordinates.cpp \ + src/kmlparser.cpp RESOURCES += gpxsee.qrc TRANSLATIONS = lang/gpxsee_cs.ts macx { diff --git a/lang/gpxsee_cs.ts b/lang/gpxsee_cs.ts index 5a5004bb..cc75dde9 100644 --- a/lang/gpxsee_cs.ts +++ b/lang/gpxsee_cs.ts @@ -151,7 +151,7 @@ Otevřít soubor - + Open POI file Otevřít POI soubor @@ -363,19 +363,31 @@ Předchozí mapa - + + All supported files (*.gpx *.tcx *.kml *.csv) + Všechny podporované soubory (*.gpx *.tcx *.kml *.csv) + + + + GPX files (*.gpx) Soubory GPX (*.gpx) - + TCX files (*.tcx) Soubory TCX (*.tcx) - + + + KML files (*.kml) + Soubory KML (*.kml) + + + Error loading data file: %1 Datový soubor nelze otevřít: @@ -383,34 +395,34 @@ - + CSV files (*.csv) Soubory CSV (*.csv) - - + + All files (*) Všechny soubory (*) - - + + Date Datum - + Routes Trasy - + No GPX files loaded Nejsou načteny žádné GPX soubory - + %1 files %1 soubor @@ -439,7 +451,7 @@ Exportovat do PDF... - + Waypoints Navigační body @@ -484,19 +496,13 @@ POI soubory, které se mají automaticky nahrát při startu programu jsou načítány z následujícího adresáře: - - - All supported files (*.gpx *.tcx *.csv) - Všechny podporované soubory (*.gpx *.tcx *.csv) - - - - + + Line: %1 Řádka: %1 - + Tracks Cesty @@ -523,24 +529,24 @@ - + Distance Vzdálenost - + Time Čas - - + + Error Chyba - + Error loading POI file: %1 Soubor POI nelze otevřít: @@ -648,7 +654,7 @@ RouteItem - + Distance Vzdálenost @@ -656,22 +662,22 @@ ScaleItem - + mi mi - + ft ft - + km km - + m m @@ -742,17 +748,17 @@ TrackItem - + Distance Vzdálenost - + Time Čas - + Date Datum @@ -760,27 +766,27 @@ WaypointItem - + Name Název - + Coordinates Souřadnice - + Elevation Výška - + Date Datum - + Description Popis diff --git a/src/csvparser.cpp b/src/csvparser.cpp index b9179a22..38764790 100644 --- a/src/csvparser.cpp +++ b/src/csvparser.cpp @@ -2,7 +2,7 @@ bool CSVParser::loadFile(QIODevice *device) { - bool ret; + bool res; int ln = 1; _errorLine = 0; @@ -17,14 +17,14 @@ bool CSVParser::loadFile(QIODevice *device) return false; } - qreal lat = list[0].trimmed().toDouble(&ret); - if (!ret) { + qreal lat = list[0].trimmed().toDouble(&res); + if (!res || (lat < -90.0 || lat > 90.0)) { _errorString = "Invalid latitude."; _errorLine = ln; return false; } - qreal lon = list[1].trimmed().toDouble(&ret); - if (!ret) { + qreal lon = list[1].trimmed().toDouble(&res); + if (!res || (lon < -180.0 || lon > 180.0)) { _errorString = "Invalid longitude."; _errorLine = ln; return false; diff --git a/src/data.cpp b/src/data.cpp index 3cf218cd..03bd22eb 100644 --- a/src/data.cpp +++ b/src/data.cpp @@ -3,6 +3,7 @@ #include "gpxparser.h" #include "tcxparser.h" #include "csvparser.h" +#include "kmlparser.h" #include "data.h" @@ -10,6 +11,7 @@ Data::Data() : _errorLine(0) { _parsers << new GPXParser(_track_data, _route_data, _waypoint_data); _parsers << new TCXParser(_track_data, _route_data, _waypoint_data); + _parsers << new KMLParser(_track_data, _route_data, _waypoint_data); _parsers << new CSVParser(_track_data, _route_data, _waypoint_data); } diff --git a/src/gpxparser.cpp b/src/gpxparser.cpp index 52418249..555fac45 100644 --- a/src/gpxparser.cpp +++ b/src/gpxparser.cpp @@ -81,12 +81,20 @@ Coordinates GPXParser::coordinates(const QXmlStreamAttributes &attr) bool res; qreal lon, lat; +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + lon = attr.value("lon").toString().toDouble(&res); +#else // QT_VERSION < 5 lon = attr.value("lon").toDouble(&res); +#endif // QT_VERSION < 5 if (!res || (lon < -180.0 || lon > 180.0)) { _reader.raiseError("Invalid longitude."); return Coordinates(); } +#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) + lat = attr.value("lat").toString().toDouble(&res); +#else // QT_VERSION < 5 lat = attr.value("lat").toDouble(&res); +#endif // QT_VERSION < 5 if (!res || (lat < -90.0 || lat > 90.0)) { _reader.raiseError("Invalid latitude."); return Coordinates(); diff --git a/src/gui.cpp b/src/gui.cpp index 93534a7e..06311e89 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -107,7 +107,7 @@ GUI::~GUI() void GUI::createBrowser() { QStringList filter; - filter << "*.gpx" << "*.tcx" << "*.csv"; + filter << "*.gpx" << "*.tcx" << "*.kml" << "*.csv"; _browser = new FileBrowser(this); _browser->setFilter(filter); } @@ -600,9 +600,10 @@ void GUI::dataSources() void GUI::openFile() { QStringList files = QFileDialog::getOpenFileNames(this, tr("Open file"), - QString(), tr("All supported files (*.gpx *.tcx *.csv)") + ";;" + QString(), tr("All supported files (*.gpx *.tcx *.kml *.csv)") + ";;" + tr("GPX files (*.gpx)") + ";;" + tr("TCX files (*.tcx)") + ";;" - + tr("CSV files (*.csv)") + ";;" + tr("All files (*)")); + + tr("CSV files (*.csv)") + ";;" + tr("KML files (*.kml)") + ";;" + + tr("All files (*)")); QStringList list = files; for (QStringList::Iterator it = list.begin(); it != list.end(); it++) @@ -681,9 +682,10 @@ bool GUI::loadFile(const QString &fileName) void GUI::openPOIFile() { QStringList files = QFileDialog::getOpenFileNames(this, tr("Open POI file"), - QString(), tr("All supported files (*.gpx *.tcx *.csv)") + ";;" + QString(), tr("All supported files (*.gpx *.tcx *.kml *.csv)") + ";;" + tr("GPX files (*.gpx)") + ";;" + tr("CSV files (*.csv)") + ";;" - + tr("TCX files (*.tcx)") + ";;" + tr("All files (*)")); + + tr("TCX files (*.tcx)") + ";;" + tr("KML files (*.kml)") + ";;" + + tr("All files (*)")); QStringList list = files; for (QStringList::Iterator it = list.begin(); it != list.end(); it++)