mirror of
https://github.com/tumic0/GPXSee.git
synced 2024-11-28 05:34:47 +01:00
Added support for waypoint phone data
+ address waypoint data where missing
This commit is contained in:
parent
4b2bee2368
commit
b9e3e81ac1
@ -279,6 +279,7 @@ SOURCES += src/main.cpp \
|
|||||||
src/GUI/gearratiographitem.cpp \
|
src/GUI/gearratiographitem.cpp \
|
||||||
src/GUI/mapview.cpp \
|
src/GUI/mapview.cpp \
|
||||||
src/GUI/areaitem.cpp \
|
src/GUI/areaitem.cpp \
|
||||||
|
src/data/address.cpp \
|
||||||
src/data/itnparser.cpp \
|
src/data/itnparser.cpp \
|
||||||
src/data/ov2parser.cpp \
|
src/data/ov2parser.cpp \
|
||||||
src/data/waypoint.cpp \
|
src/data/waypoint.cpp \
|
||||||
|
@ -45,19 +45,14 @@ QString WaypointItem::info() const
|
|||||||
&& _waypoint.comment() != _waypoint.description())
|
&& _waypoint.comment() != _waypoint.description())
|
||||||
tt.insert(qApp->translate("WaypointItem", "Comment"),
|
tt.insert(qApp->translate("WaypointItem", "Comment"),
|
||||||
_waypoint.comment());
|
_waypoint.comment());
|
||||||
if (_waypoint.address().isValid()) {
|
if (!_waypoint.address().isEmpty()) {
|
||||||
QString addr("<address>");
|
QString addr(_waypoint.address());
|
||||||
addr += _waypoint.address().street();
|
addr.replace('\n', "<br/>");
|
||||||
addr += "<br/>" + _waypoint.address().city();
|
addr = "<address>" + addr + "</address>";
|
||||||
if (!_waypoint.address().postalCode().isEmpty())
|
|
||||||
addr += "<br/>" + _waypoint.address().postalCode();
|
|
||||||
if (!_waypoint.address().state().isEmpty())
|
|
||||||
addr += "<br/>" + _waypoint.address().state();
|
|
||||||
if (!_waypoint.address().country().isEmpty())
|
|
||||||
addr += "<br/>" + _waypoint.address().country();
|
|
||||||
addr += "</address>";
|
|
||||||
tt.insert(qApp->translate("WaypointItem", "Address"), addr);
|
tt.insert(qApp->translate("WaypointItem", "Address"), addr);
|
||||||
}
|
}
|
||||||
|
if (!_waypoint.phone().isEmpty())
|
||||||
|
tt.insert(qApp->translate("WaypointItem", "Phone"), _waypoint.phone());
|
||||||
if (!_waypoint.links().isEmpty()) {
|
if (!_waypoint.links().isEmpty()) {
|
||||||
QString links;
|
QString links;
|
||||||
for (int i = 0; i < _waypoint.links().size(); i++) {
|
for (int i = 0; i < _waypoint.links().size(); i++) {
|
||||||
|
19
src/data/address.cpp
Normal file
19
src/data/address.cpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#include "address.h"
|
||||||
|
|
||||||
|
QString Address::address() const
|
||||||
|
{
|
||||||
|
QString addr(_street);
|
||||||
|
|
||||||
|
if (addr.isEmpty())
|
||||||
|
addr = _city;
|
||||||
|
else
|
||||||
|
addr += "\n" + _city;
|
||||||
|
if (!_postalCode.isEmpty())
|
||||||
|
addr += "\n" + _postalCode;
|
||||||
|
if (!_state.isEmpty())
|
||||||
|
addr += "\n" + _state;
|
||||||
|
if (!_country.isEmpty())
|
||||||
|
addr += "\n" + _country;
|
||||||
|
|
||||||
|
return addr;
|
||||||
|
}
|
@ -10,11 +10,7 @@ public:
|
|||||||
Address(const QString &street, const QString &city)
|
Address(const QString &street, const QString &city)
|
||||||
: _street(street), _city(city) {}
|
: _street(street), _city(city) {}
|
||||||
|
|
||||||
const QString &street() const {return _street;}
|
QString address() const;
|
||||||
const QString &city() const {return _city;}
|
|
||||||
const QString &state() const {return _state;}
|
|
||||||
const QString &country() const {return _country;}
|
|
||||||
const QString &postalCode() const {return _postalCode;}
|
|
||||||
|
|
||||||
void setStreet(const QString &street) {_street = street;}
|
void setStreet(const QString &street) {_street = street;}
|
||||||
void setCity(const QString &city) {_city = city;}
|
void setCity(const QString &city) {_city = city;}
|
||||||
@ -22,7 +18,7 @@ public:
|
|||||||
void setCountry(const QString &country) {_country = country;}
|
void setCountry(const QString &country) {_country = country;}
|
||||||
void setPostalCode(const QString &postalCode) {_postalCode = postalCode;}
|
void setPostalCode(const QString &postalCode) {_postalCode = postalCode;}
|
||||||
|
|
||||||
bool isValid() const {return !(_street.isEmpty() || _city.isEmpty());}
|
bool isValid() const {return !_city.isEmpty();}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QString _street;
|
QString _street;
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include <QTemporaryDir>
|
#include <QTemporaryDir>
|
||||||
#include "common/garmin.h"
|
#include "common/garmin.h"
|
||||||
#include "common/textcodec.h"
|
#include "common/textcodec.h"
|
||||||
|
#include "address.h"
|
||||||
#include "gpiparser.h"
|
#include "gpiparser.h"
|
||||||
|
|
||||||
|
|
||||||
@ -324,15 +325,19 @@ static quint32 readContact(DataStream &stream, Waypoint &waypoint)
|
|||||||
rs = stream.readRecordHeader(rh);
|
rs = stream.readRecordHeader(rh);
|
||||||
stream >> flags;
|
stream >> flags;
|
||||||
|
|
||||||
if (flags & 0x1) // phone
|
if (flags & 0x1) {
|
||||||
ds += stream.readString(str);
|
ds += stream.readString(str);
|
||||||
|
waypoint.setPhone(str);
|
||||||
|
}
|
||||||
if (flags & 0x2) // phone2
|
if (flags & 0x2) // phone2
|
||||||
ds += stream.readString(str);
|
ds += stream.readString(str);
|
||||||
if (flags & 0x4) // fax
|
if (flags & 0x4) // fax
|
||||||
ds += stream.readString(str);
|
ds += stream.readString(str);
|
||||||
if (flags & 0x8) // mail
|
if (flags & 0x8) {
|
||||||
ds += stream.readString(str);
|
ds += stream.readString(str);
|
||||||
if (flags & 0x10) { // web
|
waypoint.addLink(Link("mailto:" + str, str));
|
||||||
|
}
|
||||||
|
if (flags & 0x10) {
|
||||||
ds += stream.readString(str);
|
ds += stream.readString(str);
|
||||||
QUrl url(str);
|
QUrl url(str);
|
||||||
waypoint.addLink(Link(url.scheme().isEmpty()
|
waypoint.addLink(Link(url.scheme().isEmpty()
|
||||||
@ -387,7 +392,8 @@ static quint32 readAddress(DataStream &stream, Waypoint &waypoint)
|
|||||||
if (flags & 0x20) // unknown
|
if (flags & 0x20) // unknown
|
||||||
ds += stream.readString(str);
|
ds += stream.readString(str);
|
||||||
|
|
||||||
waypoint.setAddress(addr);
|
if (addr.isValid())
|
||||||
|
waypoint.setAddress(addr.address());
|
||||||
|
|
||||||
if (ds != rh.size)
|
if (ds != rh.size)
|
||||||
stream.setStatus(QDataStream::ReadCorruptData);
|
stream.setStatus(QDataStream::ReadCorruptData);
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
#include "address.h"
|
||||||
#include "gpxparser.h"
|
#include "gpxparser.h"
|
||||||
|
|
||||||
|
|
||||||
@ -103,7 +104,8 @@ void GPXParser::address(Waypoint &waypoint)
|
|||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
waypoint.setAddress(addr);
|
if (addr.isValid())
|
||||||
|
waypoint.setAddress(addr.address());
|
||||||
}
|
}
|
||||||
|
|
||||||
void GPXParser::wpExtension(Waypoint &waypoint)
|
void GPXParser::wpExtension(Waypoint &waypoint)
|
||||||
@ -111,6 +113,8 @@ void GPXParser::wpExtension(Waypoint &waypoint)
|
|||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
if (_reader.name() == QLatin1String("Address"))
|
if (_reader.name() == QLatin1String("Address"))
|
||||||
address(waypoint);
|
address(waypoint);
|
||||||
|
else if (_reader.name() == QLatin1String("PhoneNumber"))
|
||||||
|
waypoint.setPhone(_reader.readElementText());
|
||||||
else
|
else
|
||||||
_reader.skipCurrentElement();
|
_reader.skipCurrentElement();
|
||||||
}
|
}
|
||||||
|
@ -492,7 +492,7 @@ void KMLParser::multiGeometry(QList<TrackData> &tracks, QList<Area> &areas,
|
|||||||
void KMLParser::placemark(QList<TrackData> &tracks, QList<Area> &areas,
|
void KMLParser::placemark(QList<TrackData> &tracks, QList<Area> &areas,
|
||||||
QVector<Waypoint> &waypoints)
|
QVector<Waypoint> &waypoints)
|
||||||
{
|
{
|
||||||
QString name, desc;
|
QString name, desc, phone, address;
|
||||||
QDateTime timestamp;
|
QDateTime timestamp;
|
||||||
|
|
||||||
while (_reader.readNextStartElement()) {
|
while (_reader.readNextStartElement()) {
|
||||||
@ -500,6 +500,10 @@ void KMLParser::placemark(QList<TrackData> &tracks, QList<Area> &areas,
|
|||||||
name = _reader.readElementText();
|
name = _reader.readElementText();
|
||||||
else if (_reader.name() == QLatin1String("description"))
|
else if (_reader.name() == QLatin1String("description"))
|
||||||
desc = _reader.readElementText();
|
desc = _reader.readElementText();
|
||||||
|
else if (_reader.name() == QLatin1String("phoneNumber"))
|
||||||
|
phone = _reader.readElementText();
|
||||||
|
else if (_reader.name() == QLatin1String("address"))
|
||||||
|
address = _reader.readElementText();
|
||||||
else if (_reader.name() == QLatin1String("TimeStamp"))
|
else if (_reader.name() == QLatin1String("TimeStamp"))
|
||||||
timestamp = timeStamp();
|
timestamp = timeStamp();
|
||||||
else if (_reader.name() == QLatin1String("MultiGeometry"))
|
else if (_reader.name() == QLatin1String("MultiGeometry"))
|
||||||
@ -510,6 +514,8 @@ void KMLParser::placemark(QList<TrackData> &tracks, QList<Area> &areas,
|
|||||||
w.setName(name);
|
w.setName(name);
|
||||||
w.setDescription(desc);
|
w.setDescription(desc);
|
||||||
w.setTimestamp(timestamp);
|
w.setTimestamp(timestamp);
|
||||||
|
w.setAddress(address);
|
||||||
|
w.setPhone(phone);
|
||||||
point(w);
|
point(w);
|
||||||
} else if (_reader.name() == QLatin1String("LineString")
|
} else if (_reader.name() == QLatin1String("LineString")
|
||||||
|| _reader.name() == QLatin1String("LinearRing")) {
|
|| _reader.name() == QLatin1String("LinearRing")) {
|
||||||
|
@ -53,6 +53,11 @@ bool OV2Parser::parse(QFile *file, QList<TrackData> &tracks,
|
|||||||
}
|
}
|
||||||
Waypoint wp(Coordinates(lon/1e5, lat/1e5));
|
Waypoint wp(Coordinates(lon/1e5, lat/1e5));
|
||||||
QList<QByteArray> parts(ba.split('\0'));
|
QList<QByteArray> parts(ba.split('\0'));
|
||||||
|
int pp = parts.first().indexOf('>');
|
||||||
|
if (pp >= 0) {
|
||||||
|
wp.setName(codec.toString(parts.first().left(pp)));
|
||||||
|
wp.setPhone(parts.first().mid(pp+1));
|
||||||
|
} else
|
||||||
wp.setName(codec.toString(parts.first()));
|
wp.setName(codec.toString(parts.first()));
|
||||||
waypoints.append(wp);}
|
waypoints.append(wp);}
|
||||||
break;
|
break;
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
#include "common/coordinates.h"
|
#include "common/coordinates.h"
|
||||||
#include "imageinfo.h"
|
#include "imageinfo.h"
|
||||||
#include "link.h"
|
#include "link.h"
|
||||||
#include "address.h"
|
|
||||||
|
|
||||||
class Waypoint
|
class Waypoint
|
||||||
{
|
{
|
||||||
@ -24,7 +23,8 @@ public:
|
|||||||
const QString &name() const {return _name;}
|
const QString &name() const {return _name;}
|
||||||
const QString &description() const {return _description;}
|
const QString &description() const {return _description;}
|
||||||
const QString &comment() const {return _comment;}
|
const QString &comment() const {return _comment;}
|
||||||
const Address &address() const {return _address;}
|
const QString &address() const {return _address;}
|
||||||
|
const QString &phone() const {return _phone;}
|
||||||
const QVector<ImageInfo> &images() const {return _images;}
|
const QVector<ImageInfo> &images() const {return _images;}
|
||||||
const QVector<Link> &links() const {return _links;}
|
const QVector<Link> &links() const {return _links;}
|
||||||
const QDateTime ×tamp() const {return _timestamp;}
|
const QDateTime ×tamp() const {return _timestamp;}
|
||||||
@ -38,7 +38,8 @@ public:
|
|||||||
void setDescription(const QString &description)
|
void setDescription(const QString &description)
|
||||||
{_description = description;}
|
{_description = description;}
|
||||||
void setComment(const QString &comment) {_comment = comment;}
|
void setComment(const QString &comment) {_comment = comment;}
|
||||||
void setAddress(const Address &address) {_address = address;}
|
void setAddress(const QString &address) {_address = address;}
|
||||||
|
void setPhone(const QString &phone) {_phone = phone;}
|
||||||
void setTimestamp(const QDateTime ×tamp) {_timestamp = timestamp;}
|
void setTimestamp(const QDateTime ×tamp) {_timestamp = timestamp;}
|
||||||
void setElevation(qreal elevation) {_elevation = elevation;}
|
void setElevation(qreal elevation) {_elevation = elevation;}
|
||||||
void addImage(const ImageInfo &image) {_images.append(image);}
|
void addImage(const ImageInfo &image) {_images.append(image);}
|
||||||
@ -59,7 +60,8 @@ private:
|
|||||||
QString _name;
|
QString _name;
|
||||||
QString _description;
|
QString _description;
|
||||||
QString _comment;
|
QString _comment;
|
||||||
Address _address;
|
QString _address;
|
||||||
|
QString _phone;
|
||||||
QVector<ImageInfo> _images;
|
QVector<ImageInfo> _images;
|
||||||
QVector<Link> _links;
|
QVector<Link> _links;
|
||||||
QDateTime _timestamp;
|
QDateTime _timestamp;
|
||||||
|
Loading…
Reference in New Issue
Block a user