From ba4ac9fe51e44b62e14e9e479fead8e482b09049 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Fri, 19 Feb 2016 21:42:54 +0100 Subject: [PATCH] Yet another refactoring --- src/gpx.h | 6 +++--- src/parser.cpp | 6 +++--- src/parser.h | 8 ++++---- src/poi.cpp | 8 ++++---- src/poi.h | 4 ++-- src/track.h | 4 ++-- src/trackpoint.h | 4 ++-- src/trackview.cpp | 10 +++++----- src/trackview.h | 4 ++-- src/waypoint.h | 10 +++++----- src/waypointitem.cpp | 6 +++--- src/waypointitem.h | 8 ++++---- 12 files changed, 39 insertions(+), 39 deletions(-) diff --git a/src/gpx.h b/src/gpx.h index 7703c4da..06120fa1 100644 --- a/src/gpx.h +++ b/src/gpx.h @@ -19,15 +19,15 @@ public: int trackCount() const {return _tracks.count();} Track track(int i) const {return Track(_tracks.at(i));} - const QList &waypoints() const {return _waypoints;} + const QList &waypoints() const {return _waypoints;} private: Parser _parser; QString _error; int _errorLine; - QList > _tracks; - QList _waypoints; + QList > _tracks; + QList _waypoints; }; #endif // GPX_H diff --git a/src/parser.cpp b/src/parser.cpp index 75b378cc..805a32af 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -64,7 +64,7 @@ void Parser::trackPoints() { while (_reader.readNextStartElement()) { if (_reader.name() == "trkpt") { - _track->append(TrackPoint()); + _track->append(Trackpoint()); handleTrekPointAttributes(_reader.attributes()); trackPointData(); } else @@ -96,11 +96,11 @@ void Parser::gpx() { while (_reader.readNextStartElement()) { if (_reader.name() == "trk") { - _tracks.append(QVector()); + _tracks.append(QVector()); _track = &_tracks.back(); track(); } else if (_reader.name() == "wpt") { - _waypoints.append(WayPoint()); + _waypoints.append(Waypoint()); handleWayPointAttributes(_reader.attributes()); wayPointData(); } else diff --git a/src/parser.h b/src/parser.h index db2a4d13..e63998da 100644 --- a/src/parser.h +++ b/src/parser.h @@ -11,7 +11,7 @@ class Parser { public: - Parser(QList > &tracks, QList &waypoints) + Parser(QList > &tracks, QList &waypoints) : _tracks(tracks), _waypoints(waypoints) {_track = 0;} bool loadFile(QIODevice *device); QString errorString() const {return _reader.errorString();} @@ -33,9 +33,9 @@ private: void handleExtensionData(QStringRef element, const QString &value); QXmlStreamReader _reader; - QList > &_tracks; - QList &_waypoints; - QVector *_track; + QList > &_tracks; + QList &_waypoints; + QVector *_track; }; #endif // PARSER_H diff --git a/src/poi.cpp b/src/poi.cpp index 3763fc44..86af8340 100644 --- a/src/poi.cpp +++ b/src/poi.cpp @@ -43,7 +43,7 @@ bool POI::loadGPXFile(const QString &fileName) if (gpx.loadFile(fileName)) { for (int i = 0; i < gpx.waypoints().size(); i++) - _data.append(WayPoint( + _data.append(Waypoint( ll2mercator(gpx.waypoints().at(i).coordinates()), gpx.waypoints().at(i).description())); @@ -97,7 +97,7 @@ bool POI::loadCSVFile(const QString &fileName) } QByteArray ba = list[2].trimmed(); - _data.append(WayPoint(ll2mercator(QPointF(lon, lat)), + _data.append(Waypoint(ll2mercator(QPointF(lon, lat)), QString::fromUtf8(ba.data(), ba.size()))); ln++; } @@ -120,9 +120,9 @@ static bool cb(size_t data, void* context) return true; } -QVector POI::points(const QVector &path, qreal radius) const +QVector POI::points(const QVector &path, qreal radius) const { - QVector ret; + QVector ret; QSet set; qreal min[2], max[2]; diff --git a/src/poi.h b/src/poi.h index b91e96db..8610bd3f 100644 --- a/src/poi.h +++ b/src/poi.h @@ -15,7 +15,7 @@ public: QString errorString() const {return _error;} int errorLine() const {return _errorLine;} - QVector points(const QVector &path, + QVector points(const QVector &path, qreal radius = 0.01) const; void clear(); @@ -27,7 +27,7 @@ private: bool loadGPXFile(const QString &fileName); POITree _tree; - QVector _data; + QVector _data; QString _error; int _errorLine; diff --git a/src/track.h b/src/track.h index 370114b1..c1074183 100644 --- a/src/track.h +++ b/src/track.h @@ -8,7 +8,7 @@ class Track { public: - Track(const QVector &data) : _data(data) {} + Track(const QVector &data) : _data(data) {} void elevationGraph(QVector &graph) const; void speedGraph(QVector &graph) const; @@ -18,7 +18,7 @@ public: QDateTime date() const; private: - const QVector &_data; + const QVector &_data; }; #endif // TRACK_H diff --git a/src/trackpoint.h b/src/trackpoint.h index e3d26333..0e181e93 100644 --- a/src/trackpoint.h +++ b/src/trackpoint.h @@ -4,7 +4,7 @@ #include #include -struct TrackPoint +struct Trackpoint { QPointF coordinates; QDateTime timestamp; @@ -12,7 +12,7 @@ struct TrackPoint qreal geoidheight; qreal speed; - TrackPoint() {elevation = 0; geoidheight = 0; speed = -1;} + Trackpoint() {elevation = 0; geoidheight = 0; speed = -1;} }; #endif // TRACKPOINT_H diff --git a/src/trackview.cpp b/src/trackview.cpp index 4da63f0a..5dbee53e 100644 --- a/src/trackview.cpp +++ b/src/trackview.cpp @@ -156,7 +156,7 @@ void TrackView::rescale(qreal scale) _trackPaths.at(i)->setPen(pen); } - QHash::const_iterator it, jt; + QHash::const_iterator it, jt; for (it = _pois.constBegin(); it != _pois.constEnd(); it++) { it.value()->setPos(QPointF(it.value()->entry().coordinates().x() * 1.0/scale, -it.value()->entry().coordinates().y() * 1.0/scale)); @@ -176,19 +176,19 @@ void TrackView::rescale(qreal scale) void TrackView::loadPOI(const POI &poi) { - QHash::const_iterator it,jt; + QHash::const_iterator it,jt; if (!_tracks.size()) return; for (int i = 0; i < _tracks.size(); i++) { - QVector p = poi.points(_tracks.at(i)); + QVector p = poi.points(_tracks.at(i)); for (int i = 0; i < p.size(); i++) { if (_pois.contains(p.at(i))) continue; - WayPointItem *pi = new WayPointItem(p.at(i)); + WaypointItem *pi = new WaypointItem(p.at(i)); pi->setPos(p.at(i).coordinates().x() * 1.0/_scale, -p.at(i).coordinates().y() * 1.0/_scale); pi->setZValue(1); @@ -298,7 +298,7 @@ enum QPrinter::Orientation TrackView::orientation() const void TrackView::clearPOI() { - QHash::const_iterator it; + QHash::const_iterator it; for (it = _pois.constBegin(); it != _pois.constEnd(); it++) { _scene->removeItem(it.value()); diff --git a/src/trackview.h b/src/trackview.h index afe91d38..612ab668 100644 --- a/src/trackview.h +++ b/src/trackview.h @@ -13,7 +13,7 @@ class GPX; class POI; class Map; -class WayPointItem; +class WaypointItem; class MarkerItem; class ScaleItem; @@ -61,7 +61,7 @@ private: QList > _tracks; QList _trackPaths; QList _markers; - QHash _pois; + QHash _pois; Map *_map; ScaleItem *_mapScale; diff --git a/src/waypoint.h b/src/waypoint.h index d8ec3fb9..9bc3dcd4 100644 --- a/src/waypoint.h +++ b/src/waypoint.h @@ -5,11 +5,11 @@ #include #include -class WayPoint +class Waypoint { public: - WayPoint() {} - WayPoint(const QPointF &coordinates, const QString &description) + Waypoint() {} + Waypoint(const QPointF &coordinates, const QString &description) : _coordinates(coordinates), _description(description) {} const QPointF &coordinates() const {return _coordinates;} @@ -19,7 +19,7 @@ public: void setDescription(const QString &description) {_description = description;} - bool operator==(const WayPoint &other) const + bool operator==(const Waypoint &other) const {return this->_description == other._description && this->_coordinates == other._coordinates;} @@ -28,7 +28,7 @@ private: QString _description; }; -inline uint qHash(const WayPoint &key) +inline uint qHash(const Waypoint &key) { return ::qHash(key.description()); } diff --git a/src/waypointitem.cpp b/src/waypointitem.cpp index 012c4680..1758051d 100644 --- a/src/waypointitem.cpp +++ b/src/waypointitem.cpp @@ -5,14 +5,14 @@ #define POINT_SIZE 8 -WayPointItem::WayPointItem(const WayPoint &entry, QGraphicsItem *parent) +WaypointItem::WaypointItem(const Waypoint &entry, QGraphicsItem *parent) : QGraphicsItem(parent) { _entry = entry; updateBoundingRect(); } -void WayPointItem::updateBoundingRect() +void WaypointItem::updateBoundingRect() { QFont font; font.setPixelSize(FONT_SIZE); @@ -24,7 +24,7 @@ void WayPointItem::updateBoundingRect() ts.height() + fm.descent() + POINT_SIZE); } -void WayPointItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, +void WaypointItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(option); diff --git a/src/waypointitem.h b/src/waypointitem.h index a6f2ac24..6d5de713 100644 --- a/src/waypointitem.h +++ b/src/waypointitem.h @@ -4,11 +4,11 @@ #include #include "waypoint.h" -class WayPointItem : public QGraphicsItem +class WaypointItem : public QGraphicsItem { public: - WayPointItem(const WayPoint &entry, QGraphicsItem *parent = 0); - const WayPoint &entry() const {return _entry;} + WaypointItem(const Waypoint &entry, QGraphicsItem *parent = 0); + const Waypoint &entry() const {return _entry;} QRectF boundingRect() const {return _boundingRect;} void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, @@ -17,7 +17,7 @@ public: private: void updateBoundingRect(); - WayPoint _entry; + Waypoint _entry; QRectF _boundingRect; };