aboutsummaryrefslogtreecommitdiffstats
path: root/qt-models/maplocationmodel.cpp
diff options
context:
space:
mode:
authorGravatar Lubomir I. Ivanov <neolit123@gmail.com>2017-07-17 22:36:55 +0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-07-28 07:31:11 -0700
commitf44645b6fe3de4d117fe85d1f2ae7a01ac34b252 (patch)
tree029627b2a08c5ecb8734732b5616a83469576ed0 /qt-models/maplocationmodel.cpp
parentd7839844431a4ffab9050a9194b9f3e9fdd51118 (diff)
downloadsubsurface-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.cpp')
-rw-r--r--qt-models/maplocationmodel.cpp13
1 files changed, 5 insertions, 8 deletions
diff --git a/qt-models/maplocationmodel.cpp b/qt-models/maplocationmodel.cpp
index 43f28c981..d08e7020c 100644
--- a/qt-models/maplocationmodel.cpp
+++ b/qt-models/maplocationmodel.cpp
@@ -5,18 +5,16 @@ MapLocation::MapLocation()
{
}
-MapLocation::MapLocation(qreal latitude, qreal longitude) :
- m_latitude(latitude), m_longitude(longitude)
+MapLocation::MapLocation(QGeoCoordinate coord) :
+ m_coordinate(coord)
{
}
QVariant MapLocation::getRole(int role) const
{
switch (role) {
- case Roles::RoleLatitude:
- return m_latitude;
- case Roles::RoleLongitude:
- return m_longitude;
+ case Roles::RoleCoordinate:
+ return QVariant::fromValue(m_coordinate);
default:
return QVariant();
}
@@ -24,8 +22,7 @@ QVariant MapLocation::getRole(int role) const
MapLocationModel::MapLocationModel(QObject *parent) : QAbstractListModel(parent)
{
- m_roles[MapLocation::Roles::RoleLatitude] = "latitude";
- m_roles[MapLocation::Roles::RoleLongitude] = "longitude";
+ m_roles[MapLocation::Roles::RoleCoordinate] = "coordinate";
}
MapLocationModel::~MapLocationModel()