summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFriedrich W. H. Kossebau <kossebau@kde.org>2016-09-03 01:05:00 (GMT)
committerFriedrich W. H. Kossebau <kossebau@kde.org>2016-09-03 01:49:48 (GMT)
commit1ccc01975e229d3956d1351865ba9113f5840411 (patch)
tree8836faa1673afe391204f24623306032f9889735
parentd3e078acad59c523ba81b73a9624988b7537b772 (diff)
Use QStringLiteral with elementsByTagName/firstChildElement
-rw-r--r--src/plugins/runner/cyclestreets/CycleStreetsRunner.cpp16
-rw-r--r--src/plugins/runner/mapquest/MapQuestRunner.cpp18
-rw-r--r--src/plugins/runner/monav/MonavConfigWidget.cpp8
-rw-r--r--src/plugins/runner/nominatim-reversegeocoding/OsmNominatimReverseGeocodingRunner.cpp4
-rw-r--r--src/plugins/runner/nominatim-search/OsmNominatimSearchRunner.cpp20
-rw-r--r--src/plugins/runner/openrouteservice/OpenRouteServiceRunner.cpp16
6 files changed, 41 insertions, 41 deletions
diff --git a/src/plugins/runner/cyclestreets/CycleStreetsRunner.cpp b/src/plugins/runner/cyclestreets/CycleStreetsRunner.cpp
index 215da2f..68ea120 100644
--- a/src/plugins/runner/cyclestreets/CycleStreetsRunner.cpp
+++ b/src/plugins/runner/cyclestreets/CycleStreetsRunner.cpp
@@ -152,14 +152,14 @@ GeoDataDocument *CycleStreetsRunner::parse( const QByteArray &content ) const
routePlacemark->setName( "Route" );
GeoDataLineString *routeWaypoints = new GeoDataLineString;
- QDomNodeList features = xml.elementsByTagName( "gml:featureMember" );
+ QDomNodeList features = xml.elementsByTagName(QStringLiteral("gml:featureMember"));
if ( features.isEmpty() ) {
return 0;
}
QDomElement route = features.at( 0 ).toElement().firstChild().toElement();
- QDomElement lineString = route.elementsByTagName( "gml:LineString" ).at( 0 ).toElement();
- QDomElement coordinates = lineString.toElement().elementsByTagName( "gml:coordinates" ).at( 0 ).toElement();
+ QDomElement lineString = route.elementsByTagName(QStringLiteral("gml:LineString")).at(0).toElement();
+ QDomElement coordinates = lineString.toElement().elementsByTagName(QStringLiteral("gml:coordinates")).at(0).toElement();
QStringList coordinatesList = coordinates.text().split(QLatin1Char(' '));
QStringList::iterator iter = coordinatesList.begin();
@@ -176,7 +176,7 @@ GeoDataDocument *CycleStreetsRunner::parse( const QByteArray &content ) const
}
routePlacemark->setGeometry( routeWaypoints );
- QDomElement durationElement = route.elementsByTagName( "cs:time" ).at(0).toElement();
+ QDomElement durationElement = route.elementsByTagName(QStringLiteral("cs:time")).at(0).toElement();
QTime duration;
duration = duration.addSecs( durationElement.text().toInt() );
qreal length = routeWaypoints->length( EARTH_RADIUS );
@@ -192,10 +192,10 @@ GeoDataDocument *CycleStreetsRunner::parse( const QByteArray &content ) const
for ( ; i < features.count(); ++i) {
QDomElement segment = features.at( i ).toElement();
- QString name = segment.elementsByTagName( "cs:name" ).at( 0 ).toElement().text();
- QString maneuver = segment.elementsByTagName( "cs:turn" ).at( 0 ).toElement().text();
- QStringList points = segment.elementsByTagName( "cs:points" ).at( 0 ).toElement().text().split(QLatin1Char(' '));
- QStringList const elevation = segment.elementsByTagName( "cs:elevations" ).at( 0 ).toElement().text().split(QLatin1Char(','));
+ QString name = segment.elementsByTagName(QStringLiteral("cs:name")).at(0).toElement().text();
+ QString maneuver = segment.elementsByTagName(QStringLiteral("cs:turn")).at(0).toElement().text();
+ QStringList points = segment.elementsByTagName(QStringLiteral("cs:points")).at(0).toElement().text().split(QLatin1Char(' '));
+ QStringList const elevation = segment.elementsByTagName(QStringLiteral("cs:elevations")).at(0).toElement().text().split(QLatin1Char(','));
GeoDataPlacemark *instructions = new GeoDataPlacemark;
QString instructionName;
diff --git a/src/plugins/runner/mapquest/MapQuestRunner.cpp b/src/plugins/runner/mapquest/MapQuestRunner.cpp
index 1ad7f23..401b5df 100644
--- a/src/plugins/runner/mapquest/MapQuestRunner.cpp
+++ b/src/plugins/runner/mapquest/MapQuestRunner.cpp
@@ -214,9 +214,9 @@ GeoDataDocument* MapQuestRunner::parse( const QByteArray &content ) const
routePlacemark->setName( "Route" );
GeoDataLineString* routeWaypoints = new GeoDataLineString;
- QDomNodeList shapePoints = root.elementsByTagName( "shapePoints" );
+ QDomNodeList shapePoints = root.elementsByTagName(QStringLiteral("shapePoints"));
if ( shapePoints.size() == 1 ) {
- QDomNodeList geometry = shapePoints.at( 0 ).toElement().elementsByTagName( "latLng" );
+ QDomNodeList geometry = shapePoints.at(0).toElement().elementsByTagName(QStringLiteral("latLng"));
for ( int i=0; i<geometry.size(); ++i ) {
double const lat = geometry.item(i).namedItem(QStringLiteral("lat")).toElement().text().toDouble();
double const lon = geometry.item(i).namedItem(QStringLiteral("lng")).toElement().text().toDouble();
@@ -227,7 +227,7 @@ GeoDataDocument* MapQuestRunner::parse( const QByteArray &content ) const
routePlacemark->setGeometry( routeWaypoints );
QTime time;
- time = time.addSecs( root.elementsByTagName( "time" ).at( 0 ).toElement().text().toInt() );
+ time = time.addSecs(root.elementsByTagName(QStringLiteral("time")).at(0).toElement().text().toInt());
qreal length = routeWaypoints->length( EARTH_RADIUS );
const QString name = nameString( "MQ", length, time );
const GeoDataExtendedData data = routeData( length, time );
@@ -236,7 +236,7 @@ GeoDataDocument* MapQuestRunner::parse( const QByteArray &content ) const
result->append( routePlacemark );
QMap<int,int> mapping;
- QDomNodeList maneuvers = root.elementsByTagName( "maneuverIndexes" );
+ QDomNodeList maneuvers = root.elementsByTagName(QStringLiteral("maneuverIndexes"));
if ( maneuvers.size() == 1 ) {
maneuvers = maneuvers.at( 0 ).childNodes();
for ( int i=0; i<maneuvers.size(); ++i ) {
@@ -247,15 +247,15 @@ GeoDataDocument* MapQuestRunner::parse( const QByteArray &content ) const
}
}
- QDomNodeList instructions = root.elementsByTagName( "maneuver" );
+ QDomNodeList instructions = root.elementsByTagName(QStringLiteral("maneuver"));
unsigned int const lastInstruction = qMax<int>( 0, instructions.length()-1 ); // ignore the last 'Welcome to xy' instruction
for ( unsigned int i = 0; i < lastInstruction; ++i ) {
QDomElement node = instructions.item( i ).toElement();
- QDomNodeList maneuver = node.elementsByTagName( "turnType" );
- QDomNodeList textNodes = node.elementsByTagName( "narrative" );
- QDomNodeList points = node.elementsByTagName( "startPoint" );
- QDomNodeList streets = node.elementsByTagName( "streets" );
+ QDomNodeList maneuver = node.elementsByTagName(QStringLiteral("turnType"));
+ QDomNodeList textNodes = node.elementsByTagName(QStringLiteral("narrative"));
+ QDomNodeList points = node.elementsByTagName(QStringLiteral("startPoint"));
+ QDomNodeList streets = node.elementsByTagName(QStringLiteral("streets"));
Q_ASSERT( mapping.contains( i ) );
if ( textNodes.size() == 1 && maneuver.size() == 1 && points.size() == 1 && mapping.contains( i ) ) {
diff --git a/src/plugins/runner/monav/MonavConfigWidget.cpp b/src/plugins/runner/monav/MonavConfigWidget.cpp
index fc5d758..ac61e03 100644
--- a/src/plugins/runner/monav/MonavConfigWidget.cpp
+++ b/src/plugins/runner/monav/MonavConfigWidget.cpp
@@ -211,24 +211,24 @@ void MonavConfigWidgetPrivate::parseNewStuff( const QByteArray &data )
}
QDomElement root = xml.documentElement();
- QDomNodeList items = root.elementsByTagName( "stuff" );
+ QDomNodeList items = root.elementsByTagName(QStringLiteral("stuff"));
for (int i=0 ; i < items.length(); ++i ) {
MonavStuffEntry item;
QDomNode node = items.item( i );
- QDomNodeList names = node.toElement().elementsByTagName( "name" );
+ QDomNodeList names = node.toElement().elementsByTagName(QStringLiteral("name"));
if ( names.size() == 1 ) {
item.setName( names.at( 0 ).toElement().text() );
}
QString releaseDate;
- QDomNodeList dates = node.toElement().elementsByTagName( "releasedate" );
+ QDomNodeList dates = node.toElement().elementsByTagName(QStringLiteral("releasedate"));
if ( dates.size() == 1 ) {
releaseDate = dates.at( 0 ).toElement().text();
}
QString filename;
- QDomNodeList payloads = node.toElement().elementsByTagName( "payload" );
+ QDomNodeList payloads = node.toElement().elementsByTagName(QStringLiteral("payload"));
if ( payloads.size() == 1 ) {
QString payload = payloads.at( 0 ).toElement().text();
filename = payload.mid(1 + payload.lastIndexOf(QLatin1Char('/')));
diff --git a/src/plugins/runner/nominatim-reversegeocoding/OsmNominatimReverseGeocodingRunner.cpp b/src/plugins/runner/nominatim-reversegeocoding/OsmNominatimReverseGeocodingRunner.cpp
index 15145f5..33f4817 100644
--- a/src/plugins/runner/nominatim-reversegeocoding/OsmNominatimReverseGeocodingRunner.cpp
+++ b/src/plugins/runner/nominatim-reversegeocoding/OsmNominatimReverseGeocodingRunner.cpp
@@ -99,7 +99,7 @@ void OsmNominatimRunner::handleResult( QNetworkReply* reply )
}
QDomElement root = xml.documentElement();
- QDomNodeList places = root.elementsByTagName( "result" );
+ QDomNodeList places = root.elementsByTagName(QStringLiteral("result"));
if ( places.size() == 1 ) {
QString address = places.item( 0 ).toElement().text();
GeoDataPlacemark placemark;
@@ -107,7 +107,7 @@ void OsmNominatimRunner::handleResult( QNetworkReply* reply )
placemark.setAddress( address );
placemark.setCoordinate( m_coordinates );
- QDomNode details = root.firstChildElement( "addressparts" );
+ QDomNode details = root.firstChildElement(QStringLiteral("addressparts"));
extractChildren( details, placemark );
emit reverseGeocodingFinished( m_coordinates, placemark );
diff --git a/src/plugins/runner/nominatim-search/OsmNominatimSearchRunner.cpp b/src/plugins/runner/nominatim-search/OsmNominatimSearchRunner.cpp
index ccc4e9d..e0af560 100644
--- a/src/plugins/runner/nominatim-search/OsmNominatimSearchRunner.cpp
+++ b/src/plugins/runner/nominatim-search/OsmNominatimSearchRunner.cpp
@@ -112,7 +112,7 @@ void OsmNominatimRunner::handleResult( QNetworkReply* reply )
QVector<GeoDataPlacemark*> placemarks;
QDomElement root = xml.documentElement();
- QDomNodeList places = root.elementsByTagName("place");
+ QDomNodeList places = root.elementsByTagName(QStringLiteral("place"));
for (int i=0; i<places.size(); ++i) {
QDomNode place = places.at(i);
QDomNamedNodeMap attributes = place.attributes();
@@ -129,31 +129,31 @@ void OsmNominatimRunner::handleResult( QNetworkReply* reply )
placemarkData.addValue(GeoDataData(QStringLiteral("type"), value));
QString name = place.firstChildElement(value).text();
- QString road = place.firstChildElement("road").text();
+ QString road = place.firstChildElement(QStringLiteral("road")).text();
placemarkData.addValue(GeoDataData(QStringLiteral("name"), name));
- QString city = place.firstChildElement("city").text();
+ QString city = place.firstChildElement(QStringLiteral("city")).text();
if( city.isEmpty() ) {
- city = place.firstChildElement("town").text();
+ city = place.firstChildElement(QStringLiteral("town")).text();
if( city.isEmpty() ) {
- city = place.firstChildElement("village").text();
+ city = place.firstChildElement(QStringLiteral("village")).text();
} if( city.isEmpty() ) {
- city = place.firstChildElement("hamlet").text();
+ city = place.firstChildElement(QStringLiteral("hamlet")).text();
}
}
- QString administrative = place.firstChildElement("county").text();
+ QString administrative = place.firstChildElement(QStringLiteral("county")).text();
if( administrative.isEmpty() ) {
- administrative = place.firstChildElement("region").text();
+ administrative = place.firstChildElement(QStringLiteral("region")).text();
if( administrative.isEmpty() ) {
- administrative = place.firstChildElement("state").text();
+ administrative = place.firstChildElement(QStringLiteral("state")).text();
data.addTag(QStringLiteral("addr:state"), administrative);
} else {
data.addTag(QStringLiteral("district"), administrative);
}
}
- QString country = place.firstChildElement("country").text();
+ QString country = place.firstChildElement(QStringLiteral("country")).text();
QString description;
for (int i=0; i<place.childNodes().size(); ++i) {
diff --git a/src/plugins/runner/openrouteservice/OpenRouteServiceRunner.cpp b/src/plugins/runner/openrouteservice/OpenRouteServiceRunner.cpp
index 7c39f86..acf31b1 100644
--- a/src/plugins/runner/openrouteservice/OpenRouteServiceRunner.cpp
+++ b/src/plugins/runner/openrouteservice/OpenRouteServiceRunner.cpp
@@ -207,7 +207,7 @@ GeoDataDocument* OpenRouteServiceRunner::parse( const QByteArray &content ) cons
GeoDataDocument* result = new GeoDataDocument();
result->setName( "OpenRouteService" );
- QDomNodeList errors = root.elementsByTagName( "xls:Error" );
+ QDomNodeList errors = root.elementsByTagName(QStringLiteral("xls:Error"));
if ( errors.size() > 0 ) {
return 0;
// Returning early because fallback routing providers are used now
@@ -243,9 +243,9 @@ GeoDataDocument* OpenRouteServiceRunner::parse( const QByteArray &content ) cons
GeoDataPlacemark* routePlacemark = new GeoDataPlacemark;
routePlacemark->setName( "Route" );
QTime time;
- QDomNodeList summary = root.elementsByTagName( "xls:RouteSummary" );
+ QDomNodeList summary = root.elementsByTagName(QStringLiteral("xls:RouteSummary"));
if ( summary.size() > 0 ) {
- QDomNodeList timeNodeList = summary.item( 0 ).toElement().elementsByTagName( "xls:TotalTime" );
+ QDomNodeList timeNodeList = summary.item(0).toElement().elementsByTagName(QStringLiteral("xls:TotalTime"));
if ( timeNodeList.size() == 1 ) {
QRegExp regexp = QRegExp( "^P(?:(\\d+)D)?T(?:(\\d+)H)?(?:(\\d+)M)?(\\d+)S" );
if ( regexp.indexIn( timeNodeList.item( 0 ).toElement().text() ) == 0 ) {
@@ -274,7 +274,7 @@ GeoDataDocument* OpenRouteServiceRunner::parse( const QByteArray &content ) cons
}
GeoDataLineString* routeWaypoints = new GeoDataLineString;
- QDomNodeList geometry = root.elementsByTagName( "xls:RouteGeometry" );
+ QDomNodeList geometry = root.elementsByTagName(QStringLiteral("xls:RouteGeometry"));
if ( geometry.size() > 0 ) {
QDomNodeList waypoints = geometry.item( 0 ).toElement().elementsByTagName( "gml:pos" );
for (int i=0 ; i < waypoints.length(); ++i ) {
@@ -298,14 +298,14 @@ GeoDataDocument* OpenRouteServiceRunner::parse( const QByteArray &content ) cons
result->append( routePlacemark );
- QDomNodeList instructionList = root.elementsByTagName( "xls:RouteInstructionsList" );
+ QDomNodeList instructionList = root.elementsByTagName(QStringLiteral("xls:RouteInstructionsList"));
if ( instructionList.size() > 0 ) {
- QDomNodeList instructions = instructionList.item( 0 ).toElement().elementsByTagName( "xls:RouteInstruction" );
+ QDomNodeList instructions = instructionList.item(0).toElement().elementsByTagName(QStringLiteral("xls:RouteInstruction"));
for (int i=0 ; i < instructions.length(); ++i ) {
QDomElement node = instructions.item( i ).toElement();
- QDomNodeList textNodes = node.elementsByTagName( "xls:Instruction" );
- QDomNodeList positions = node.elementsByTagName( "gml:pos" );
+ QDomNodeList textNodes = node.elementsByTagName(QStringLiteral("xls:Instruction"));
+ QDomNodeList positions = node.elementsByTagName(QStringLiteral("gml:pos"));
if ( textNodes.size() > 0 && positions.size() > 0 ) {
const QStringList content = positions.at(0).toElement().text().split(QLatin1Char(' '));