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
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue