mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
d783984443
commit
f44645b6fe
3 changed files with 11 additions and 16 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue