diff options
author | Lubomir I. Ivanov <neolit123@gmail.com> | 2017-07-17 22:36:55 +0300 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-07-28 07:31:11 -0700 |
commit | f44645b6fe3de4d117fe85d1f2ae7a01ac34b252 (patch) | |
tree | 029627b2a08c5ecb8734732b5616a83469576ed0 /qt-models/maplocationmodel.h | |
parent | d7839844431a4ffab9050a9194b9f3e9fdd51118 (diff) | |
download | subsurface-f44645b6fe3de4d117fe85d1f2ae7a01ac34b252.tar.gz |
maplocationmodel: store the coordinate as QGeoCoordinate
Instead of maintaining a seperate latitude/longitude values
in C++ and passing them to QML separatelly, pass them as a QGeoCoordinate.
This reduces the number of model "roles" and also prevents the creations
of extra objects in QML (e.g. via QtPositioning.coordinate(..)).
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Diffstat (limited to 'qt-models/maplocationmodel.h')
-rw-r--r-- | qt-models/maplocationmodel.h | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/qt-models/maplocationmodel.h b/qt-models/maplocationmodel.h index 8dff65eac..4aeee0364 100644 --- a/qt-models/maplocationmodel.h +++ b/qt-models/maplocationmodel.h @@ -7,27 +7,25 @@ #include <QHash> #include <QByteArray> #include <QAbstractListModel> +#include <QGeoCoordinate> class MapLocation : public QObject { Q_OBJECT - Q_PROPERTY(qreal latitude MEMBER m_latitude) - Q_PROPERTY(qreal longitude MEMBER m_longitude) + Q_PROPERTY(QGeoCoordinate coordinate MEMBER m_coordinate) public: explicit MapLocation(); - explicit MapLocation(qreal lat, qreal lng); + explicit MapLocation(QGeoCoordinate); QVariant getRole(int role) const; enum Roles { - RoleLatitude = Qt::UserRole + 1, - RoleLongitude + RoleCoordinate = Qt::UserRole + 1, }; private: - qreal m_latitude; - qreal m_longitude; + QGeoCoordinate m_coordinate; }; class MapLocationModel : public QAbstractListModel |