mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-01-18 19:52:09 +01:00
Improved error reporting
This commit is contained in:
parent
e4d777bace
commit
c89f8dbb47
@ -151,7 +151,7 @@
|
||||
<translation>Otevřít soubor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="684"/>
|
||||
<location filename="../src/gui.cpp" line="686"/>
|
||||
<source>Open POI file</source>
|
||||
<translation>Otevřít POI soubor</translation>
|
||||
</message>
|
||||
@ -364,70 +364,63 @@
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="603"/>
|
||||
<location filename="../src/gui.cpp" line="685"/>
|
||||
<location filename="../src/gui.cpp" line="687"/>
|
||||
<source>All supported files (*.gpx *.tcx *.kml *.csv)</source>
|
||||
<translation>Všechny podporované soubory (*.gpx *.tcx *.kml *.csv) </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="604"/>
|
||||
<location filename="../src/gui.cpp" line="686"/>
|
||||
<location filename="../src/gui.cpp" line="688"/>
|
||||
<source>GPX files (*.gpx)</source>
|
||||
<translation>Soubory GPX (*.gpx)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="604"/>
|
||||
<location filename="../src/gui.cpp" line="687"/>
|
||||
<location filename="../src/gui.cpp" line="689"/>
|
||||
<source>TCX files (*.tcx)</source>
|
||||
<translation>Soubory TCX (*.tcx)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="605"/>
|
||||
<location filename="../src/gui.cpp" line="687"/>
|
||||
<location filename="../src/gui.cpp" line="689"/>
|
||||
<source>KML files (*.kml)</source>
|
||||
<translation>Soubory KML (*.kml)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="672"/>
|
||||
<source>Error loading data file:
|
||||
%1</source>
|
||||
<translation>Datový soubor nelze otevřít:
|
||||
%1 </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="605"/>
|
||||
<location filename="../src/gui.cpp" line="686"/>
|
||||
<location filename="../src/gui.cpp" line="688"/>
|
||||
<source>CSV files (*.csv)</source>
|
||||
<translation>Soubory CSV (*.csv)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="606"/>
|
||||
<location filename="../src/gui.cpp" line="688"/>
|
||||
<location filename="../src/gui.cpp" line="690"/>
|
||||
<source>All files (*)</source>
|
||||
<translation>Všechny soubory (*)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="774"/>
|
||||
<location filename="../src/gui.cpp" line="777"/>
|
||||
<location filename="../src/gui.cpp" line="775"/>
|
||||
<location filename="../src/gui.cpp" line="778"/>
|
||||
<source>Date</source>
|
||||
<translation>Datum</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="786"/>
|
||||
<location filename="../src/gui.cpp" line="787"/>
|
||||
<source>Routes</source>
|
||||
<translation>Trasy</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="974"/>
|
||||
<location filename="../src/gui.cpp" line="975"/>
|
||||
<source>No GPX files loaded</source>
|
||||
<translation>Nejsou načteny žádné GPX soubory</translation>
|
||||
</message>
|
||||
<message numerus="yes">
|
||||
<location filename="../src/gui.cpp" line="978"/>
|
||||
<source>%1 files</source>
|
||||
<location filename="../src/gui.cpp" line="979"/>
|
||||
<source>%n files</source>
|
||||
<translation>
|
||||
<numerusform>%1 soubor</numerusform>
|
||||
<numerusform>%1 soubory</numerusform>
|
||||
<numerusform>%1 souborů</numerusform>
|
||||
<numerusform>%n soubor</numerusform>
|
||||
<numerusform>%n soubory</numerusform>
|
||||
<numerusform>%n souborů</numerusform>
|
||||
</translation>
|
||||
</message>
|
||||
<message>
|
||||
@ -451,7 +444,7 @@
|
||||
<translation>Exportovat do PDF...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="788"/>
|
||||
<location filename="../src/gui.cpp" line="789"/>
|
||||
<source>Waypoints</source>
|
||||
<translation>Navigační body</translation>
|
||||
</message>
|
||||
@ -497,12 +490,22 @@
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="675"/>
|
||||
<location filename="../src/gui.cpp" line="705"/>
|
||||
<source>Error loading data file:</source>
|
||||
<translation>Datový soubor nelze načíst:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="678"/>
|
||||
<location filename="../src/gui.cpp" line="706"/>
|
||||
<source>Line: %1</source>
|
||||
<translation>Řádka: %1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="784"/>
|
||||
<location filename="../src/gui.cpp" line="703"/>
|
||||
<source>Error loading POI file:</source>
|
||||
<translation>Soubor POI nelze načíst:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="785"/>
|
||||
<source>Tracks</source>
|
||||
<translation>Cesty</translation>
|
||||
</message>
|
||||
@ -529,29 +532,16 @@
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="325"/>
|
||||
<location filename="../src/gui.cpp" line="791"/>
|
||||
<location filename="../src/gui.cpp" line="792"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="332"/>
|
||||
<location filename="../src/gui.cpp" line="793"/>
|
||||
<location filename="../src/gui.cpp" line="794"/>
|
||||
<source>Time</source>
|
||||
<translation>Čas</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="677"/>
|
||||
<location filename="../src/gui.cpp" line="706"/>
|
||||
<source>Error</source>
|
||||
<translation>Chyba</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/gui.cpp" line="702"/>
|
||||
<source>Error loading POI file:
|
||||
%1</source>
|
||||
<translation>Soubor POI nelze otevřít:
|
||||
%1</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>GraphView</name>
|
||||
@ -654,7 +644,17 @@
|
||||
<context>
|
||||
<name>RouteItem</name>
|
||||
<message>
|
||||
<location filename="../src/routeitem.cpp" line="14"/>
|
||||
<location filename="../src/routeitem.cpp" line="15"/>
|
||||
<source>Name</source>
|
||||
<translation>Název</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/routeitem.cpp" line="17"/>
|
||||
<source>Description</source>
|
||||
<translation>Popis</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/routeitem.cpp" line="18"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
@ -748,17 +748,27 @@
|
||||
<context>
|
||||
<name>TrackItem</name>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="13"/>
|
||||
<location filename="../src/trackitem.cpp" line="14"/>
|
||||
<source>Name</source>
|
||||
<translation>Název</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="16"/>
|
||||
<source>Description</source>
|
||||
<translation>Popis</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="17"/>
|
||||
<source>Distance</source>
|
||||
<translation>Vzdálenost</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="16"/>
|
||||
<location filename="../src/trackitem.cpp" line="20"/>
|
||||
<source>Time</source>
|
||||
<translation>Čas</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../src/trackitem.cpp" line="18"/>
|
||||
<location filename="../src/trackitem.cpp" line="22"/>
|
||||
<source>Date</source>
|
||||
<translation>Datum</translation>
|
||||
</message>
|
||||
|
@ -12,20 +12,20 @@ bool CSVParser::loadFile(QFile *file)
|
||||
QByteArray line = file->readLine();
|
||||
QList<QByteArray> list = line.split(',');
|
||||
if (list.size() < 3) {
|
||||
_errorString = "Parse error.";
|
||||
_errorString = "Parse error";
|
||||
_errorLine = ln;
|
||||
return false;
|
||||
}
|
||||
|
||||
qreal lat = list[0].trimmed().toDouble(&res);
|
||||
if (!res || (lat < -90.0 || lat > 90.0)) {
|
||||
_errorString = "Invalid latitude.";
|
||||
_errorString = "Invalid latitude";
|
||||
_errorLine = ln;
|
||||
return false;
|
||||
}
|
||||
qreal lon = list[1].trimmed().toDouble(&res);
|
||||
if (!res || (lon < -180.0 || lon > 180.0)) {
|
||||
_errorString = "Invalid longitude.";
|
||||
_errorString = "Invalid longitude";
|
||||
_errorLine = ln;
|
||||
return false;
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ qreal GPXParser::number()
|
||||
bool res;
|
||||
qreal ret = _reader.readElementText().toDouble(&res);
|
||||
if (!res)
|
||||
_reader.raiseError(QString("Invalid %1.").arg(
|
||||
_reader.raiseError(QString("Invalid %1").arg(
|
||||
_reader.name().toString()));
|
||||
|
||||
return ret;
|
||||
@ -17,7 +17,7 @@ QDateTime GPXParser::time()
|
||||
QDateTime d = QDateTime::fromString(_reader.readElementText(),
|
||||
Qt::ISODate);
|
||||
if (!d.isValid())
|
||||
_reader.raiseError(QString("Invalid %1.").arg(
|
||||
_reader.raiseError(QString("Invalid %1").arg(
|
||||
_reader.name().toString()));
|
||||
|
||||
return d;
|
||||
@ -35,7 +35,7 @@ Coordinates GPXParser::coordinates()
|
||||
lon = attr.value("lon").toDouble(&res);
|
||||
#endif // QT_VERSION < 5
|
||||
if (!res || (lon < -180.0 || lon > 180.0)) {
|
||||
_reader.raiseError("Invalid longitude.");
|
||||
_reader.raiseError("Invalid longitude");
|
||||
return Coordinates();
|
||||
}
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
|
||||
@ -44,7 +44,7 @@ Coordinates GPXParser::coordinates()
|
||||
lat = attr.value("lat").toDouble(&res);
|
||||
#endif // QT_VERSION < 5
|
||||
if (!res || (lat < -90.0 || lat > 90.0)) {
|
||||
_reader.raiseError("Invalid latitude.");
|
||||
_reader.raiseError("Invalid latitude");
|
||||
return Coordinates();
|
||||
}
|
||||
|
||||
@ -229,7 +229,7 @@ bool GPXParser::parse()
|
||||
if (_reader.name() == "gpx")
|
||||
gpx();
|
||||
else
|
||||
_reader.raiseError("Not a GPX file.");
|
||||
_reader.raiseError("Not a GPX file");
|
||||
}
|
||||
|
||||
return !_reader.error();
|
||||
|
22
src/gui.cpp
22
src/gui.cpp
@ -672,13 +672,11 @@ bool GUI::loadFile(const QString &fileName)
|
||||
updateGraphTabs();
|
||||
updatePathView();
|
||||
|
||||
QString error = fileName + QString("\n\n")
|
||||
+ tr("Error loading data file:\n%1").arg(data.errorString())
|
||||
+ QString("\n");
|
||||
QString error = tr("Error loading data file:") + "\n\n"
|
||||
+ fileName + "\n\n" + data.errorString();
|
||||
if (data.errorLine())
|
||||
error.append(tr("Line: %1").arg(data.errorLine()));
|
||||
|
||||
QMessageBox::critical(this, tr("Error"), error);
|
||||
error.append("\n" + tr("Line: %1").arg(data.errorLine()));
|
||||
QMessageBox::critical(this, APP_NAME, error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -702,12 +700,11 @@ bool GUI::openPOIFile(const QString &fileName)
|
||||
return false;
|
||||
|
||||
if (!_poi->loadFile(fileName)) {
|
||||
QString error = fileName + QString("\n\n")
|
||||
+ tr("Error loading POI file:\n%1").arg(_poi->errorString())
|
||||
+ QString("\n");
|
||||
QString error = tr("Error loading POI file:") + "\n\n"
|
||||
+ fileName + "\n\n" + _poi->errorString();
|
||||
if (_poi->errorLine())
|
||||
error.append(tr("Line: %1").arg(_poi->errorLine()));
|
||||
QMessageBox::critical(this, tr("Error"), error);
|
||||
error.append("\n" + tr("Line: %1").arg(_poi->errorLine()));
|
||||
QMessageBox::critical(this, APP_NAME, error);
|
||||
|
||||
return false;
|
||||
} else {
|
||||
@ -979,8 +976,7 @@ void GUI::updateStatusBarInfo()
|
||||
else if (_files.count() == 1)
|
||||
_fileNameLabel->setText(_files.at(0));
|
||||
else
|
||||
_fileNameLabel->setText(tr("%1 files", "", _files.count())
|
||||
.arg(_files.count()));
|
||||
_fileNameLabel->setText(tr("%n files", "", _files.count()));
|
||||
|
||||
qreal d = distance();
|
||||
Units units = _imperialUnitsAction->isChecked() ? Imperial : Metric;
|
||||
|
@ -6,7 +6,7 @@ qreal KMLParser::number()
|
||||
bool res;
|
||||
qreal ret = _reader.readElementText().toDouble(&res);
|
||||
if (!res)
|
||||
_reader.raiseError(QString("Invalid %1.").arg(
|
||||
_reader.raiseError(QString("Invalid %1").arg(
|
||||
_reader.name().toString()));
|
||||
|
||||
return ret;
|
||||
@ -17,7 +17,7 @@ QDateTime KMLParser::time()
|
||||
QDateTime d = QDateTime::fromString(_reader.readElementText(),
|
||||
Qt::ISODate);
|
||||
if (!d.isValid())
|
||||
_reader.raiseError(QString("Invalid %1.").arg(
|
||||
_reader.raiseError(QString("Invalid %1").arg(
|
||||
_reader.name().toString()));
|
||||
|
||||
return d;
|
||||
@ -205,7 +205,7 @@ void KMLParser::lineString(TrackData &track)
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "coordinates") {
|
||||
if (!lineCoordinates(track))
|
||||
_reader.raiseError("Invalid coordinates.");
|
||||
_reader.raiseError("Invalid coordinates");
|
||||
} else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
@ -216,18 +216,18 @@ void KMLParser::point(Waypoint &waypoint)
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == "coordinates") {
|
||||
if (!pointCoordinates(waypoint))
|
||||
_reader.raiseError("Invalid coordinates.");
|
||||
_reader.raiseError("Invalid coordinates");
|
||||
} else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
|
||||
if (waypoint.coordinates().isNull())
|
||||
_reader.raiseError("Missing Point coordinates.");
|
||||
_reader.raiseError("Missing Point coordinates");
|
||||
}
|
||||
|
||||
void KMLParser::Track(TrackData &track)
|
||||
{
|
||||
const char mismatchError[] = "gx:coord/when element count mismatch.";
|
||||
const char mismatchError[] = "gx:coord/when element count mismatch";
|
||||
int i = track.size();
|
||||
|
||||
while (_reader.readNextStartElement()) {
|
||||
@ -239,7 +239,7 @@ void KMLParser::Track(TrackData &track)
|
||||
_reader.raiseError(mismatchError);
|
||||
return;
|
||||
} else if (!coord(track[i])) {
|
||||
_reader.raiseError("Invalid coordinates.");
|
||||
_reader.raiseError("Invalid coordinates");
|
||||
return;
|
||||
}
|
||||
i++;
|
||||
@ -329,7 +329,7 @@ bool KMLParser::parse()
|
||||
if (_reader.name() == "kml")
|
||||
kml();
|
||||
else
|
||||
_reader.raiseError("Not a KML file.");
|
||||
_reader.raiseError("Not a KML file");
|
||||
}
|
||||
|
||||
return !_reader.error();
|
||||
|
@ -13,7 +13,7 @@ qreal TCXParser::number()
|
||||
bool res;
|
||||
qreal ret = _reader.readElementText().toDouble(&res);
|
||||
if (!res)
|
||||
_reader.raiseError(QString("Invalid %1.").arg(
|
||||
_reader.raiseError(QString("Invalid %1").arg(
|
||||
_reader.name().toString()));
|
||||
|
||||
return ret;
|
||||
@ -24,7 +24,7 @@ QDateTime TCXParser::time()
|
||||
QDateTime d = QDateTime::fromString(_reader.readElementText(),
|
||||
Qt::ISODate);
|
||||
if (!d.isValid())
|
||||
_reader.raiseError(QString("Invalid %1.").arg(
|
||||
_reader.raiseError(QString("Invalid %1").arg(
|
||||
_reader.name().toString()));
|
||||
|
||||
return d;
|
||||
@ -40,13 +40,13 @@ Coordinates TCXParser::position()
|
||||
if (_reader.name() == "LatitudeDegrees") {
|
||||
val = _reader.readElementText().toDouble(&res);
|
||||
if (!res || (val < -90.0 || val > 90.0))
|
||||
_reader.raiseError("Invalid LatitudeDegrees.");
|
||||
_reader.raiseError("Invalid LatitudeDegrees");
|
||||
else
|
||||
pos.setLat(val);
|
||||
} else if (_reader.name() == "LongitudeDegrees") {
|
||||
val = _reader.readElementText().toDouble(&res);
|
||||
if (!res || (val < -180.0 || val > 180.0))
|
||||
_reader.raiseError("Invalid LongitudeDegrees.");
|
||||
_reader.raiseError("Invalid LongitudeDegrees");
|
||||
else
|
||||
pos.setLon(val);
|
||||
} else
|
||||
@ -186,7 +186,7 @@ bool TCXParser::parse()
|
||||
if (_reader.name() == "TrainingCenterDatabase")
|
||||
tcx();
|
||||
else
|
||||
_reader.raiseError("Not a TCX file.");
|
||||
_reader.raiseError("Not a TCX file");
|
||||
}
|
||||
|
||||
return !_reader.error();
|
||||
|
Loading…
x
Reference in New Issue
Block a user