mirror of
https://github.com/tumic0/GPXSee.git
synced 2025-06-27 03:29:16 +02:00
Added support for waypoint links
This commit is contained in:
@ -23,6 +23,21 @@ QDateTime GPXParser::time()
|
||||
return d;
|
||||
}
|
||||
|
||||
Link GPXParser::link()
|
||||
{
|
||||
QString URL = _reader.attributes().value("href").toString();
|
||||
QString text;
|
||||
|
||||
while (_reader.readNextStartElement()) {
|
||||
if (_reader.name() == QLatin1String("text"))
|
||||
text = _reader.readElementText();
|
||||
else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
|
||||
return Link(URL, text);
|
||||
}
|
||||
|
||||
Coordinates GPXParser::coordinates()
|
||||
{
|
||||
bool res;
|
||||
@ -146,6 +161,8 @@ 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.setLink(link());
|
||||
else if (autoRoute && _reader.name() == QLatin1String("extensions"))
|
||||
rteptExtensions(autoRoute);
|
||||
else
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include <QXmlStreamReader>
|
||||
#include "parser.h"
|
||||
|
||||
|
||||
class GPXParser : public Parser
|
||||
{
|
||||
public:
|
||||
@ -30,6 +29,7 @@ private:
|
||||
qreal number();
|
||||
QDateTime time();
|
||||
Coordinates coordinates();
|
||||
Link link();
|
||||
|
||||
QXmlStreamReader _reader;
|
||||
};
|
||||
|
20
src/data/link.h
Normal file
20
src/data/link.h
Normal file
@ -0,0 +1,20 @@
|
||||
#ifndef LINK_H
|
||||
#define LINK_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
class Link {
|
||||
public:
|
||||
Link() {}
|
||||
Link(const QString &URL, const QString &text = QString())
|
||||
: _URL(URL), _text(text) {}
|
||||
|
||||
const QString &URL() const {return _URL;}
|
||||
const QString &text() const {return _text;}
|
||||
|
||||
private:
|
||||
QString _URL;
|
||||
QString _text;
|
||||
};
|
||||
|
||||
#endif // LINK_H
|
@ -38,6 +38,10 @@ void LOCParser::waypoint(Waypoint &waypoint)
|
||||
} else if (_reader.name() == QLatin1String("coord")) {
|
||||
waypoint.setCoordinates(coordinates());
|
||||
_reader.skipCurrentElement();
|
||||
} else if (_reader.name() == QLatin1String("link")) {
|
||||
const QXmlStreamAttributes &attr = _reader.attributes();
|
||||
waypoint.setLink(Link(_reader.readElementText(),
|
||||
attr.value("text").toString()));
|
||||
} else
|
||||
_reader.skipCurrentElement();
|
||||
}
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <QDebug>
|
||||
#include "common/coordinates.h"
|
||||
#include "imageinfo.h"
|
||||
#include "link.h"
|
||||
|
||||
class Waypoint
|
||||
{
|
||||
@ -19,6 +20,7 @@ public:
|
||||
const QString &name() const {return _name;}
|
||||
const QString &description() const {return _description;}
|
||||
const ImageInfo &image() const {return _image;}
|
||||
const Link &link() const {return _link;}
|
||||
const QDateTime ×tamp() const {return _timestamp;}
|
||||
qreal elevation() const {return _elevation;}
|
||||
|
||||
@ -30,6 +32,7 @@ public:
|
||||
void setTimestamp(const QDateTime ×tamp) {_timestamp = timestamp;}
|
||||
void setElevation(qreal elevation) {_elevation = elevation;}
|
||||
void setImage(const ImageInfo &image) {_image = image;}
|
||||
void setLink(const Link &link) {_link = link;}
|
||||
|
||||
bool hasElevation() const {return !std::isnan(_elevation);}
|
||||
|
||||
@ -42,6 +45,7 @@ private:
|
||||
QString _name;
|
||||
QString _description;
|
||||
ImageInfo _image;
|
||||
Link _link;
|
||||
QDateTime _timestamp;
|
||||
qreal _elevation;
|
||||
};
|
||||
|
Reference in New Issue
Block a user