mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-24 11:45:53 +01:00
Added support for GPX 1.0 links
This commit is contained in:
parent
25b42fd2f8
commit
9905de67bd
@ -19,11 +19,9 @@ QString RouteItem::info() const
|
||||
_units));
|
||||
for (int i = 0; i < _links.size(); i++) {
|
||||
const Link &link = _links.at(i);
|
||||
if (!link.URL().isEmpty()) {
|
||||
tt.insert(tr("Link"), QString("<a href=\"%0\">%1</a>").arg(
|
||||
link.URL(), link.text().isEmpty() ? link.URL() : link.text()));
|
||||
}
|
||||
}
|
||||
|
||||
return tt.toString();
|
||||
}
|
||||
|
@ -23,11 +23,9 @@ QString TrackItem::info() const
|
||||
tt.insert(tr("Date"), _date.toString(Qt::SystemLocaleShortDate));
|
||||
for (int i = 0; i < _links.size(); i++) {
|
||||
const Link &link = _links.at(i);
|
||||
if (!link.URL().isEmpty()) {
|
||||
tt.insert(tr("Link"), QString("<a href=\"%0\">%1</a>").arg(
|
||||
link.URL(), link.text().isEmpty() ? link.URL() : link.text()));
|
||||
}
|
||||
}
|
||||
|
||||
return tt.toString();
|
||||
}
|
||||
|
@ -32,12 +32,10 @@ QString WaypointItem::info() const
|
||||
_waypoint.description());
|
||||
for (int i = 0; i < _waypoint.links().size(); i++) {
|
||||
const Link &link = _waypoint.links().at(i);
|
||||
if (!link.URL().isEmpty()) {
|
||||
tt.insert(qApp->translate("WaypointItem", "Link"),
|
||||
QString("<a href=\"%0\">%1</a>").arg(link.URL(),
|
||||
link.text().isEmpty() ? link.URL() : link.text()));
|
||||
}
|
||||
}
|
||||
tt.setImage(_waypoint.image());
|
||||
|
||||
return tt.toString();
|
||||
|
@ -149,6 +149,7 @@ void GPXParser::trackpointData(Trackpoint &trackpoint)
|
||||
void GPXParser::waypointData(Waypoint &waypoint, SegmentData *autoRoute)
|
||||
{
|
||||
qreal gh = NAN;
|
||||
Link link10;
|
||||
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == QLatin1String("name"))
|
||||
@ -161,14 +162,22 @@ void GPXParser::waypointData(Waypoint &waypoint, SegmentData *autoRoute)
|
||||
gh = number();
|
||||
else if (_reader.name() == QLatin1String("time"))
|
||||
waypoint.setTimestamp(time());
|
||||
else if (_reader.name() == QLatin1String("link"))
|
||||
waypoint.addLink(link());
|
||||
else if (_reader.name() == QLatin1String("link")) {
|
||||
Link l(link());
|
||||
if (!l.URL().isEmpty())
|
||||
waypoint.addLink(l);
|
||||
} else if (_reader.name() == QLatin1String("url"))
|
||||
link10.setURL(_reader.readElementText());
|
||||
else if (_reader.name() == QLatin1String("urlname"))
|
||||
link10.setText(_reader.readElementText());
|
||||
else if (autoRoute && _reader.name() == QLatin1String("extensions"))
|
||||
rteptExtensions(autoRoute);
|
||||
else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
|
||||
if (!link10.URL().isEmpty())
|
||||
waypoint.addLink(link10);
|
||||
if (!std::isnan(gh) && !std::isnan(waypoint.elevation()))
|
||||
waypoint.setElevation(waypoint.elevation() - gh);
|
||||
}
|
||||
@ -189,6 +198,7 @@ void GPXParser::routepoints(RouteData &route, QList<TrackData> &tracks)
|
||||
TrackData autoRoute;
|
||||
autoRoute.append(SegmentData());
|
||||
SegmentData &autoRouteSegment = autoRoute.last();
|
||||
Link link10;
|
||||
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == QLatin1String("rtept")) {
|
||||
@ -198,12 +208,21 @@ void GPXParser::routepoints(RouteData &route, QList<TrackData> &tracks)
|
||||
route.setName(_reader.readElementText());
|
||||
else if (_reader.name() == QLatin1String("desc"))
|
||||
route.setDescription(_reader.readElementText());
|
||||
else if (_reader.name() == QLatin1String("link"))
|
||||
route.addLink(link());
|
||||
else if (_reader.name() == QLatin1String("link")) {
|
||||
Link l(link());
|
||||
if (!l.URL().isEmpty())
|
||||
route.addLink(l);
|
||||
} else if (_reader.name() == QLatin1String("url"))
|
||||
link10.setURL(_reader.readElementText());
|
||||
else if (_reader.name() == QLatin1String("urlname"))
|
||||
link10.setText(_reader.readElementText());
|
||||
else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
|
||||
if (!link10.URL().isEmpty())
|
||||
route.addLink(link10);
|
||||
|
||||
if (!autoRouteSegment.isEmpty()) {
|
||||
autoRoute.setName(route.name());
|
||||
autoRoute.setDescription(route.description());
|
||||
@ -213,6 +232,8 @@ void GPXParser::routepoints(RouteData &route, QList<TrackData> &tracks)
|
||||
|
||||
void GPXParser::track(TrackData &track)
|
||||
{
|
||||
Link link10;
|
||||
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == QLatin1String("trkseg")) {
|
||||
track.append(SegmentData());
|
||||
@ -221,11 +242,20 @@ void GPXParser::track(TrackData &track)
|
||||
track.setName(_reader.readElementText());
|
||||
else if (_reader.name() == QLatin1String("desc"))
|
||||
track.setDescription(_reader.readElementText());
|
||||
else if (_reader.name() == QLatin1String("link"))
|
||||
track.addLink(link());
|
||||
else if (_reader.name() == QLatin1String("link")) {
|
||||
Link l(link());
|
||||
if (!l.URL().isEmpty())
|
||||
track.addLink(l);
|
||||
} else if (_reader.name() == QLatin1String("url"))
|
||||
link10.setURL(_reader.readElementText());
|
||||
else if (_reader.name() == QLatin1String("urlname"))
|
||||
link10.setText(_reader.readElementText());
|
||||
else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
|
||||
if (!link10.URL().isEmpty())
|
||||
track.addLink(link10);
|
||||
}
|
||||
|
||||
void GPXParser::area(Area &area)
|
||||
|
@ -9,6 +9,8 @@ public:
|
||||
Link(const QString &URL, const QString &text = QString())
|
||||
: _URL(URL), _text(text) {}
|
||||
|
||||
void setURL(const QString &URL) {_URL = URL;}
|
||||
void setText(const QString &text) {_text = text;}
|
||||
const QString &URL() const {return _URL;}
|
||||
const QString &text() const {return _text;}
|
||||
|
||||
|
@ -40,8 +40,9 @@ void LOCParser::waypoint(Waypoint &waypoint)
|
||||
_reader.skipCurrentElement();
|
||||
} else if (_reader.name() == QLatin1String("link")) {
|
||||
const QXmlStreamAttributes &attr = _reader.attributes();
|
||||
waypoint.addLink(Link(_reader.readElementText(),
|
||||
attr.value("text").toString()));
|
||||
QString URL(_reader.readElementText());
|
||||
if (!URL.isEmpty())
|
||||
waypoint.addLink(Link(URL, attr.value("text").toString()));
|
||||
} else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user