From a9c0abd71aa6d70262d9b218187e4b8d3ec15f07 Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Wed, 19 Jul 2017 02:02:43 +0300 Subject: [PATCH] maplocationmodel: add a "uuid" property to MapLocation The "uuid" property will be the one from the dive_site. At first it will also be used to track the active marker/flag selection. Signed-off-by: Lubomir I. Ivanov --- mobile-widgets/qmlmapwidgethelper.cpp | 2 +- qt-models/maplocationmodel.cpp | 12 +++++++++--- qt-models/maplocationmodel.h | 10 ++++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/mobile-widgets/qmlmapwidgethelper.cpp b/mobile-widgets/qmlmapwidgethelper.cpp index 7fceccdfa..264b62abb 100644 --- a/mobile-widgets/qmlmapwidgethelper.cpp +++ b/mobile-widgets/qmlmapwidgethelper.cpp @@ -34,7 +34,7 @@ void MapWidgetHelper::reloadMapLocations() continue; const qreal longitude = ds->longitude.udeg / 1000000.0; const qreal latitude = ds->latitude.udeg / 1000000.0; - locationList.append(new MapLocation(QGeoCoordinate(latitude, longitude))); + locationList.append(new MapLocation(ds->uuid, QGeoCoordinate(latitude, longitude))); } m_mapLocationModel->addList(locationList); } diff --git a/qt-models/maplocationmodel.cpp b/qt-models/maplocationmodel.cpp index 911905f1b..8e07a7489 100644 --- a/qt-models/maplocationmodel.cpp +++ b/qt-models/maplocationmodel.cpp @@ -1,18 +1,23 @@ // SPDX-License-Identifier: GPL-2.0 #include "maplocationmodel.h" +const char *MapLocation::PROPERTY_NAME_COORDINATE = "coordinate"; +const char *MapLocation::PROPERTY_NAME_UUID = "uuid"; + MapLocation::MapLocation() { } -MapLocation::MapLocation(QGeoCoordinate coord) : - m_coordinate(coord) +MapLocation::MapLocation(quint32 uuid, QGeoCoordinate coord) : + m_uuid(uuid), m_coordinate(coord) { } QVariant MapLocation::getRole(int role) const { switch (role) { + case Roles::RoleUuid: + return QVariant::fromValue(m_uuid); case Roles::RoleCoordinate: return QVariant::fromValue(m_coordinate); default: @@ -22,7 +27,8 @@ QVariant MapLocation::getRole(int role) const MapLocationModel::MapLocationModel(QObject *parent) : QAbstractListModel(parent) { - m_roles[MapLocation::Roles::RoleCoordinate] = "coordinate"; + m_roles[MapLocation::Roles::RoleUuid] = MapLocation::PROPERTY_NAME_UUID; + m_roles[MapLocation::Roles::RoleCoordinate] = MapLocation::PROPERTY_NAME_COORDINATE; } MapLocationModel::~MapLocationModel() diff --git a/qt-models/maplocationmodel.h b/qt-models/maplocationmodel.h index 547641fe7..2793a5137 100644 --- a/qt-models/maplocationmodel.h +++ b/qt-models/maplocationmodel.h @@ -12,19 +12,25 @@ class MapLocation : public QObject { Q_OBJECT + Q_PROPERTY(quint32 uuid MEMBER m_uuid) Q_PROPERTY(QGeoCoordinate coordinate MEMBER m_coordinate) public: + static const char *PROPERTY_NAME_COORDINATE; + static const char *PROPERTY_NAME_UUID; + explicit MapLocation(); - explicit MapLocation(QGeoCoordinate); + explicit MapLocation(quint32 uuid, QGeoCoordinate coord); QVariant getRole(int role) const; enum Roles { - RoleCoordinate = Qt::UserRole + 1, + RoleUuid = Qt::UserRole + 1, + RoleCoordinate }; private: + quint32 m_uuid; QGeoCoordinate m_coordinate; };