1
0
mirror of https://github.com/tumic0/GPXSee.git synced 2024-11-24 11:45:53 +01:00

String handling optimization

This commit is contained in:
Martin Tůma 2018-08-27 22:25:55 +02:00
parent 0a9077545b
commit d9e025a18c
6 changed files with 112 additions and 109 deletions

View File

@ -303,3 +303,4 @@ win32 {
}
DEFINES += APP_VERSION=\\\"$$VERSION\\\"
DEFINES *= QT_USE_QSTRINGBUILDER

View File

@ -54,7 +54,7 @@ Coordinates GPXParser::coordinates()
void GPXParser::rpExtension(TrackData *autoRoute)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "rpt")
if (_reader.name() == QLatin1String("rpt"))
autoRoute->append(Trackpoint(coordinates()));
_reader.skipCurrentElement();
}
@ -63,9 +63,9 @@ void GPXParser::rpExtension(TrackData *autoRoute)
void GPXParser::tpExtension(Trackpoint &trackpoint)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "hr")
if (_reader.name() == QLatin1String("hr"))
trackpoint.setHeartRate(number());
else if (_reader.name() == "atemp")
else if (_reader.name() == QLatin1String("atemp"))
trackpoint.setTemperature(number());
else
_reader.skipCurrentElement();
@ -75,7 +75,7 @@ void GPXParser::tpExtension(Trackpoint &trackpoint)
void GPXParser::rteptExtensions(TrackData *autoRoute)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "RoutePointExtension")
if (_reader.name() == QLatin1String("RoutePointExtension"))
rpExtension(autoRoute);
else
_reader.skipCurrentElement();
@ -85,17 +85,18 @@ void GPXParser::rteptExtensions(TrackData *autoRoute)
void GPXParser::trkptExtensions(Trackpoint &trackpoint)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "speed")
if (_reader.name() == QLatin1String("speed"))
trackpoint.setSpeed(number());
else if (_reader.name() == "hr" || _reader.name() == "heartrate")
else if (_reader.name() == QLatin1String("hr")
|| _reader.name() == QLatin1String("heartrate"))
trackpoint.setHeartRate(number());
else if (_reader.name() == "temp")
else if (_reader.name() == QLatin1String("temp"))
trackpoint.setTemperature(number());
else if (_reader.name() == "cadence")
else if (_reader.name() == QLatin1String("cadence"))
trackpoint.setCadence(number());
else if (_reader.name() == "power")
else if (_reader.name() == QLatin1String("power"))
trackpoint.setPower(number());
else if (_reader.name() == "TrackPointExtension")
else if (_reader.name() == QLatin1String("TrackPointExtension"))
tpExtension(trackpoint);
else
_reader.skipCurrentElement();
@ -107,13 +108,13 @@ void GPXParser::trackpointData(Trackpoint &trackpoint)
qreal gh = NAN;
while (_reader.readNextStartElement()) {
if (_reader.name() == "ele")
if (_reader.name() == QLatin1String("ele"))
trackpoint.setElevation(number());
else if (_reader.name() == "time")
else if (_reader.name() == QLatin1String("time"))
trackpoint.setTimestamp(time());
else if (_reader.name() == "geoidheight")
else if (_reader.name() == QLatin1String("geoidheight"))
gh = number();
else if (_reader.name() == "extensions")
else if (_reader.name() == QLatin1String("extensions"))
trkptExtensions(trackpoint);
else
_reader.skipCurrentElement();
@ -128,17 +129,17 @@ void GPXParser::waypointData(Waypoint &waypoint, TrackData *autoRoute)
qreal gh = NAN;
while (_reader.readNextStartElement()) {
if (_reader.name() == "name")
if (_reader.name() == QLatin1String("name"))
waypoint.setName(_reader.readElementText());
else if (_reader.name() == "desc")
else if (_reader.name() == QLatin1String("desc"))
waypoint.setDescription(_reader.readElementText());
else if (_reader.name() == "ele")
else if (_reader.name() == QLatin1String("ele"))
waypoint.setElevation(number());
else if (_reader.name() == "geoidheight")
else if (_reader.name() == QLatin1String("geoidheight"))
gh = number();
else if (_reader.name() == "time")
else if (_reader.name() == QLatin1String("time"))
waypoint.setTimestamp(time());
else if (autoRoute && _reader.name() == "extensions")
else if (autoRoute && _reader.name() == QLatin1String("extensions"))
rteptExtensions(autoRoute);
else
_reader.skipCurrentElement();
@ -151,7 +152,7 @@ void GPXParser::waypointData(Waypoint &waypoint, TrackData *autoRoute)
void GPXParser::trackpoints(TrackData &track)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "trkpt") {
if (_reader.name() == QLatin1String("trkpt")) {
track.append(Trackpoint(coordinates()));
trackpointData(track.last());
} else
@ -164,12 +165,12 @@ void GPXParser::routepoints(RouteData &route, QList<TrackData> &tracks)
TrackData autoRoute;
while (_reader.readNextStartElement()) {
if (_reader.name() == "rtept") {
if (_reader.name() == QLatin1String("rtept")) {
route.append(Waypoint(coordinates()));
waypointData(route.last(), &autoRoute);
} else if (_reader.name() == "name")
} else if (_reader.name() == QLatin1String("name"))
route.setName(_reader.readElementText());
else if (_reader.name() == "desc")
else if (_reader.name() == QLatin1String("desc"))
route.setDescription(_reader.readElementText());
else
_reader.skipCurrentElement();
@ -185,11 +186,11 @@ void GPXParser::routepoints(RouteData &route, QList<TrackData> &tracks)
void GPXParser::track(TrackData &track)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "trkseg")
if (_reader.name() == QLatin1String("trkseg"))
trackpoints(track);
else if (_reader.name() == "name")
else if (_reader.name() == QLatin1String("name"))
track.setName(_reader.readElementText());
else if (_reader.name() == "desc")
else if (_reader.name() == QLatin1String("desc"))
track.setDescription(_reader.readElementText());
else
_reader.skipCurrentElement();
@ -200,13 +201,13 @@ void GPXParser::gpx(QList<TrackData> &tracks, QList<RouteData> &routes,
QList<Waypoint> &waypoints)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "trk") {
if (_reader.name() == QLatin1String("trk")) {
tracks.append(TrackData());
track(tracks.back());
} else if (_reader.name() == "rte") {
} else if (_reader.name() == QLatin1String("rte")) {
routes.append(RouteData());
routepoints(routes.back(), tracks);
} else if (_reader.name() == "wpt") {
} else if (_reader.name() == QLatin1String("wpt")) {
waypoints.append(Waypoint(coordinates()));
waypointData(waypoints.last());
} else
@ -222,7 +223,7 @@ bool GPXParser::parse(QFile *file, QList<TrackData> &tracks,
_reader.setNamespaceProcessing(false);
if (_reader.readNextStartElement()) {
if (_reader.name() == "gpx")
if (_reader.name() == QLatin1String("gpx"))
gpx(tracks, routes, waypoints);
else
_reader.raiseError("Not a GPX file");

View File

@ -191,7 +191,7 @@ QDateTime KMLParser::timeStamp()
QDateTime ts;
while (_reader.readNextStartElement()) {
if (_reader.name() == "when")
if (_reader.name() == QLatin1String("when"))
ts = time();
else
_reader.skipCurrentElement();
@ -203,7 +203,7 @@ QDateTime KMLParser::timeStamp()
void KMLParser::lineString(TrackData &track)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "coordinates") {
if (_reader.name() == QLatin1String("coordinates")) {
if (!lineCoordinates(track))
_reader.raiseError("Invalid coordinates");
} else
@ -214,7 +214,7 @@ void KMLParser::lineString(TrackData &track)
void KMLParser::point(Waypoint &waypoint)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "coordinates") {
if (_reader.name() == QLatin1String("coordinates")) {
if (!pointCoordinates(waypoint))
_reader.raiseError("Invalid coordinates");
} else
@ -231,7 +231,7 @@ void KMLParser::heartRate(TrackData &track, int start)
const char error[] = "Heartrate data count mismatch";
while (_reader.readNextStartElement()) {
if (_reader.name() == "value") {
if (_reader.name() == QLatin1String("value")) {
if (i < track.size())
track[i++].setHeartRate(number());
else {
@ -252,7 +252,7 @@ void KMLParser::cadence(TrackData &track, int start)
const char error[] = "Cadence data count mismatch";
while (_reader.readNextStartElement()) {
if (_reader.name() == "value") {
if (_reader.name() == QLatin1String("value")) {
if (i < track.size())
track[i++].setCadence(number());
else {
@ -273,7 +273,7 @@ void KMLParser::speed(TrackData &track, int start)
const char error[] = "Speed data count mismatch";
while (_reader.readNextStartElement()) {
if (_reader.name() == "value") {
if (_reader.name() == QLatin1String("value")) {
if (i < track.size())
track[i++].setSpeed(number());
else {
@ -294,7 +294,7 @@ void KMLParser::temperature(TrackData &track, int start)
const char error[] = "Temperature data count mismatch";
while (_reader.readNextStartElement()) {
if (_reader.name() == "value") {
if (_reader.name() == QLatin1String("value")) {
if (i < track.size())
track[i++].setTemperature(number());
else {
@ -312,17 +312,17 @@ void KMLParser::temperature(TrackData &track, int start)
void KMLParser::schemaData(TrackData &track, int start)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "SimpleArrayData") {
if (_reader.name() == QLatin1String("SimpleArrayData")) {
QXmlStreamAttributes attr = _reader.attributes();
QStringRef name = attr.value("name");
if (name == "Heartrate")
if (name == QLatin1String("Heartrate"))
heartRate(track, start);
else if (name == "Cadence")
else if (name == QLatin1String("Cadence"))
cadence(track, start);
else if (name == "Speed")
else if (name == QLatin1String("Speed"))
speed(track, start);
else if (name == "Temperature")
else if (name == QLatin1String("Temperature"))
temperature(track, start);
else
_reader.skipCurrentElement();
@ -334,7 +334,7 @@ void KMLParser::schemaData(TrackData &track, int start)
void KMLParser::extendedData(TrackData &track, int start)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "SchemaData")
if (_reader.name() == QLatin1String("SchemaData"))
schemaData(track, start);
else
_reader.skipCurrentElement();
@ -348,10 +348,10 @@ void KMLParser::track(TrackData &track)
int i = first;
while (_reader.readNextStartElement()) {
if (_reader.name() == "when") {
if (_reader.name() == QLatin1String("when")) {
track.append(Trackpoint());
track.last().setTimestamp(time());
} else if (_reader.name() == "coord") {
} else if (_reader.name() == QLatin1String("coord")) {
if (i == track.size()) {
_reader.raiseError(error);
return;
@ -360,7 +360,7 @@ void KMLParser::track(TrackData &track)
return;
}
i++;
} else if (_reader.name() == "ExtendedData")
} else if (_reader.name() == QLatin1String("ExtendedData"))
extendedData(track, first);
else
_reader.skipCurrentElement();
@ -373,7 +373,7 @@ void KMLParser::track(TrackData &track)
void KMLParser::multiTrack(TrackData &t)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "Track")
if (_reader.name() == QLatin1String("Track"))
track(t);
else
_reader.skipCurrentElement();
@ -385,14 +385,14 @@ void KMLParser::multiGeometry(QList<TrackData> &tracks,
const QDateTime timestamp)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "Point") {
if (_reader.name() == QLatin1String("Point")) {
waypoints.append(Waypoint());
Waypoint &w = waypoints.last();
w.setName(name);
w.setDescription(desc);
w.setTimestamp(timestamp);
point(w);
} else if (_reader.name() == "LineString") {
} else if (_reader.name() == QLatin1String("LineString")) {
tracks.append(TrackData());
TrackData &t = tracks.last();
t.setName(name);
@ -409,35 +409,35 @@ void KMLParser::placemark(QList<TrackData> &tracks, QList<Waypoint> &waypoints)
QDateTime timestamp;
while (_reader.readNextStartElement()) {
if (_reader.name() == "name")
if (_reader.name() == QLatin1String("name"))
name = _reader.readElementText();
else if (_reader.name() == "description")
else if (_reader.name() == QLatin1String("description"))
desc = _reader.readElementText();
else if (_reader.name() == "TimeStamp")
else if (_reader.name() == QLatin1String("TimeStamp"))
timestamp = timeStamp();
else if (_reader.name() == "MultiGeometry")
else if (_reader.name() == QLatin1String("MultiGeometry"))
multiGeometry(tracks, waypoints, name, desc, timestamp);
else if (_reader.name() == "Point") {
else if (_reader.name() == QLatin1String("Point")) {
waypoints.append(Waypoint());
Waypoint &w = waypoints.last();
w.setName(name);
w.setDescription(desc);
w.setTimestamp(timestamp);
point(w);
} else if (_reader.name() == "LineString"
|| _reader.name() == "LinearRing") {
} else if (_reader.name() == QLatin1String("LineString")
|| _reader.name() == QLatin1String("LinearRing")) {
tracks.append(TrackData());
TrackData &t = tracks.last();
t.setName(name);
t.setDescription(desc);
lineString(t);
} else if (_reader.name() == "Track") {
} else if (_reader.name() == QLatin1String("Track")) {
tracks.append(TrackData());
TrackData &t = tracks.last();
t.setName(name);
t.setDescription(desc);
track(t);
} else if (_reader.name() == "MultiTrack") {
} else if (_reader.name() == QLatin1String("MultiTrack")) {
tracks.append(TrackData());
TrackData &t = tracks.last();
t.setName(name);
@ -451,9 +451,9 @@ void KMLParser::placemark(QList<TrackData> &tracks, QList<Waypoint> &waypoints)
void KMLParser::folder(QList<TrackData> &tracks, QList<Waypoint> &waypoints)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "Placemark")
if (_reader.name() == QLatin1String("Placemark"))
placemark(tracks, waypoints);
else if (_reader.name() == "Folder")
else if (_reader.name() == QLatin1String("Folder"))
folder(tracks, waypoints);
else
_reader.skipCurrentElement();
@ -463,9 +463,9 @@ void KMLParser::folder(QList<TrackData> &tracks, QList<Waypoint> &waypoints)
void KMLParser::document(QList<TrackData> &tracks, QList<Waypoint> &waypoints)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "Placemark")
if (_reader.name() == QLatin1String("Placemark"))
placemark(tracks, waypoints);
else if (_reader.name() == "Folder")
else if (_reader.name() == QLatin1String("Folder"))
folder(tracks, waypoints);
else
_reader.skipCurrentElement();
@ -475,11 +475,11 @@ void KMLParser::document(QList<TrackData> &tracks, QList<Waypoint> &waypoints)
void KMLParser::kml(QList<TrackData> &tracks, QList<Waypoint> &waypoints)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "Document")
if (_reader.name() == QLatin1String("Document"))
document(tracks, waypoints);
else if (_reader.name() == "Placemark")
else if (_reader.name() == QLatin1String("Placemark"))
placemark(tracks, waypoints);
else if (_reader.name() == "Folder")
else if (_reader.name() == QLatin1String("Folder"))
folder(tracks, waypoints);
else
_reader.skipCurrentElement();
@ -495,7 +495,7 @@ bool KMLParser::parse(QFile *file, QList<TrackData> &tracks,
_reader.setDevice(file);
if (_reader.readNextStartElement()) {
if (_reader.name() == "kml")
if (_reader.name() == QLatin1String("kml"))
kml(tracks, waypoints);
else
_reader.raiseError("Not a KML file");

View File

@ -31,11 +31,11 @@ Coordinates LOCParser::coordinates()
void LOCParser::waypoint(Waypoint &waypoint)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "name") {
if (_reader.name() == QLatin1String("name")) {
const QXmlStreamAttributes &attr = _reader.attributes();
waypoint.setName(attr.value("id").toString());
waypoint.setDescription(_reader.readElementText());
} else if (_reader.name() == "coord") {
} else if (_reader.name() == QLatin1String("coord")) {
waypoint.setCoordinates(coordinates());
_reader.skipCurrentElement();
} else
@ -49,7 +49,7 @@ void LOCParser::waypoint(Waypoint &waypoint)
void LOCParser::loc(QList<Waypoint> &waypoints)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "waypoint") {
if (_reader.name() == QLatin1String("waypoint")) {
waypoints.append(Waypoint());
waypoint(waypoints.last());
} else
@ -67,7 +67,7 @@ bool LOCParser::parse(QFile *file, QList<TrackData> &tracks,
_reader.setDevice(file);
if (_reader.readNextStartElement()) {
if (_reader.name() == "loc")
if (_reader.name() == QLatin1String("loc"))
loc(waypoints);
else
_reader.raiseError("Not a LOC file");

View File

@ -29,7 +29,7 @@ bool SLFParser::data(const QXmlStreamAttributes &attr, const char *name,
void SLFParser::entries(const QDateTime &date, TrackData &track)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "Entry") {
if (_reader.name() == QLatin1String("Entry")) {
qreal val, lat, lon;
QXmlStreamAttributes attr(_reader.attributes());
@ -70,11 +70,11 @@ void SLFParser::entries(const QDateTime &date, TrackData &track)
void SLFParser::generalInformation(QDateTime &date, TrackData &track)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "name")
if (_reader.name() == QLatin1String("name"))
track.setName(_reader.readElementText());
else if (_reader.name() == "description")
else if (_reader.name() == QLatin1String("description"))
track.setDescription(_reader.readElementText());
else if (_reader.name() == "startDate") {
else if (_reader.name() == QLatin1String("startDate")) {
QString ds(_reader.readElementText());
QLocale locale(QLocale::English);
date = locale.toDateTime(ds.mid(0, ds.indexOf("GMT"))
@ -89,9 +89,9 @@ void SLFParser::activity(TrackData &track)
QDateTime date;
while (_reader.readNextStartElement()) {
if (_reader.name() == "Entries")
if (_reader.name() == QLatin1String("Entries"))
entries(date, track);
else if (_reader.name() == "GeneralInformation")
else if (_reader.name() == QLatin1String("GeneralInformation"))
generalInformation(date, track);
else
_reader.skipCurrentElement();
@ -108,7 +108,7 @@ bool SLFParser::parse(QFile *file, QList<TrackData> &tracks,
_reader.setDevice(file);
if (_reader.readNextStartElement()) {
if (_reader.name() == "Activity") {
if (_reader.name() == QLatin1String("Activity")) {
tracks.append(TrackData());
activity(tracks.last());
} else

View File

@ -37,13 +37,13 @@ Coordinates TCXParser::position()
bool res;
while (_reader.readNextStartElement()) {
if (_reader.name() == "LatitudeDegrees") {
if (_reader.name() == QLatin1String("LatitudeDegrees")) {
val = _reader.readElementText().toDouble(&res);
if (!res || (val < -90.0 || val > 90.0))
_reader.raiseError("Invalid LatitudeDegrees");
else
pos.setLat(val);
} else if (_reader.name() == "LongitudeDegrees") {
} else if (_reader.name() == QLatin1String("LongitudeDegrees")) {
val = _reader.readElementText().toDouble(&res);
if (!res || (val < -180.0 || val > 180.0))
_reader.raiseError("Invalid LongitudeDegrees");
@ -59,7 +59,7 @@ Coordinates TCXParser::position()
void TCXParser::heartRateBpm(Trackpoint &trackpoint)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "Value")
if (_reader.name() == QLatin1String("Value"))
trackpoint.setHeartRate(number());
else
_reader.skipCurrentElement();
@ -69,9 +69,9 @@ void TCXParser::heartRateBpm(Trackpoint &trackpoint)
void TCXParser::extensions(Trackpoint &trackpoint)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "RunCadence")
if (_reader.name() == QLatin1String("RunCadence"))
trackpoint.setCadence(number());
else if (_reader.name() == "Watts")
else if (_reader.name() == QLatin1String("Watts"))
trackpoint.setPower(number());
else
_reader.skipCurrentElement();
@ -81,17 +81,17 @@ void TCXParser::extensions(Trackpoint &trackpoint)
void TCXParser::trackpointData(Trackpoint &trackpoint)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "Position")
if (_reader.name() == QLatin1String("Position"))
trackpoint.setCoordinates(position());
else if (_reader.name() == "AltitudeMeters")
else if (_reader.name() == QLatin1String("AltitudeMeters"))
trackpoint.setElevation(number());
else if (_reader.name() == "Time")
else if (_reader.name() == QLatin1String("Time"))
trackpoint.setTimestamp(time());
else if (_reader.name() == "HeartRateBpm")
else if (_reader.name() == QLatin1String("HeartRateBpm"))
heartRateBpm(trackpoint);
else if (_reader.name() == "Cadence")
else if (_reader.name() == QLatin1String("Cadence"))
trackpoint.setCadence(number());
else if (_reader.name() == "Extensions")
else if (_reader.name() == QLatin1String("Extensions"))
extensions(trackpoint);
else
_reader.skipCurrentElement();
@ -101,15 +101,15 @@ void TCXParser::trackpointData(Trackpoint &trackpoint)
void TCXParser::waypointData(Waypoint &waypoint)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "Position")
if (_reader.name() == QLatin1String("Position"))
waypoint.setCoordinates(position());
else if (_reader.name() == "Name")
else if (_reader.name() == QLatin1String("Name"))
waypoint.setName(_reader.readElementText());
else if (_reader.name() == "Notes")
else if (_reader.name() == QLatin1String("Notes"))
waypoint.setDescription(_reader.readElementText());
else if (_reader.name() == "AltitudeMeters")
else if (_reader.name() == QLatin1String("AltitudeMeters"))
waypoint.setElevation(number());
else if (_reader.name() == "Time")
else if (_reader.name() == QLatin1String("Time"))
waypoint.setTimestamp(time());
else
_reader.skipCurrentElement();
@ -119,7 +119,7 @@ void TCXParser::waypointData(Waypoint &waypoint)
void TCXParser::trackpoints(TrackData &track)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "Trackpoint") {
if (_reader.name() == QLatin1String("Trackpoint")) {
Trackpoint t;
trackpointData(t);
if (t.coordinates().isValid())
@ -134,7 +134,7 @@ void TCXParser::trackpoints(TrackData &track)
void TCXParser::lap(TrackData &track)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "Track")
if (_reader.name() == QLatin1String("Track"))
trackpoints(track);
else
_reader.skipCurrentElement();
@ -144,13 +144,13 @@ void TCXParser::lap(TrackData &track)
void TCXParser::course(QList<Waypoint> &waypoints, TrackData &track)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "Track")
if (_reader.name() == QLatin1String("Track"))
trackpoints(track);
else if (_reader.name() == "Name")
else if (_reader.name() == QLatin1String("Name"))
track.setName(_reader.readElementText());
else if (_reader.name() == "Notes")
else if (_reader.name() == QLatin1String("Notes"))
track.setDescription(_reader.readElementText());
else if (_reader.name() == "CoursePoint") {
else if (_reader.name() == QLatin1String("CoursePoint")) {
Waypoint w;
waypointData(w);
if (w.coordinates().isValid())
@ -165,7 +165,7 @@ void TCXParser::course(QList<Waypoint> &waypoints, TrackData &track)
void TCXParser::activity(TrackData &track)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "Lap")
if (_reader.name() == QLatin1String("Lap"))
lap(track);
else
_reader.skipCurrentElement();
@ -175,7 +175,7 @@ void TCXParser::activity(TrackData &track)
void TCXParser::courses(QList<TrackData> &tracks, QList<Waypoint> &waypoints)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "Course") {
if (_reader.name() == QLatin1String("Course")) {
tracks.append(TrackData());
course(waypoints, tracks.back());
} else
@ -186,7 +186,7 @@ void TCXParser::courses(QList<TrackData> &tracks, QList<Waypoint> &waypoints)
void TCXParser::sport(QList<TrackData> &tracks)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "Activity") {
if (_reader.name() == QLatin1String("Activity")) {
tracks.append(TrackData());
activity(tracks.back());
} else
@ -197,7 +197,8 @@ void TCXParser::sport(QList<TrackData> &tracks)
void TCXParser::multiSportSession(QList<TrackData> &tracks)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "FirstSport" || _reader.name() == "NextSport")
if (_reader.name() == QLatin1String("FirstSport")
|| _reader.name() == QLatin1String("NextSport"))
sport(tracks);
else
_reader.skipCurrentElement();
@ -207,10 +208,10 @@ void TCXParser::multiSportSession(QList<TrackData> &tracks)
void TCXParser::activities(QList<TrackData> &tracks)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "Activity") {
if (_reader.name() == QLatin1String("Activity")) {
tracks.append(TrackData());
activity(tracks.back());
} else if (_reader.name() == "MultiSportSession")
} else if (_reader.name() == QLatin1String("MultiSportSession"))
multiSportSession(tracks);
else
_reader.skipCurrentElement();
@ -220,9 +221,9 @@ void TCXParser::activities(QList<TrackData> &tracks)
void TCXParser::tcx(QList<TrackData> &tracks, QList<Waypoint> &waypoints)
{
while (_reader.readNextStartElement()) {
if (_reader.name() == "Courses")
if (_reader.name() == QLatin1String("Courses"))
courses(tracks, waypoints);
else if (_reader.name() == "Activities")
else if (_reader.name() == QLatin1String("Activities"))
activities(tracks);
else
_reader.skipCurrentElement();
@ -238,7 +239,7 @@ bool TCXParser::parse(QFile *file, QList<TrackData> &tracks,
_reader.setDevice(file);
if (_reader.readNextStartElement()) {
if (_reader.name() == "TrainingCenterDatabase")
if (_reader.name() == QLatin1String("TrainingCenterDatabase"))
tcx(tracks, waypoints);
else
_reader.raiseError("Not a TCX file");