mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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 <neolit123@gmail.com>
This commit is contained in:
parent
ea5221bcf0
commit
a9c0abd71a
3 changed files with 18 additions and 6 deletions
|
@ -34,7 +34,7 @@ void MapWidgetHelper::reloadMapLocations()
|
||||||
continue;
|
continue;
|
||||||
const qreal longitude = ds->longitude.udeg / 1000000.0;
|
const qreal longitude = ds->longitude.udeg / 1000000.0;
|
||||||
const qreal latitude = ds->latitude.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);
|
m_mapLocationModel->addList(locationList);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,23 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
#include "maplocationmodel.h"
|
#include "maplocationmodel.h"
|
||||||
|
|
||||||
|
const char *MapLocation::PROPERTY_NAME_COORDINATE = "coordinate";
|
||||||
|
const char *MapLocation::PROPERTY_NAME_UUID = "uuid";
|
||||||
|
|
||||||
MapLocation::MapLocation()
|
MapLocation::MapLocation()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
MapLocation::MapLocation(QGeoCoordinate coord) :
|
MapLocation::MapLocation(quint32 uuid, QGeoCoordinate coord) :
|
||||||
m_coordinate(coord)
|
m_uuid(uuid), m_coordinate(coord)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant MapLocation::getRole(int role) const
|
QVariant MapLocation::getRole(int role) const
|
||||||
{
|
{
|
||||||
switch (role) {
|
switch (role) {
|
||||||
|
case Roles::RoleUuid:
|
||||||
|
return QVariant::fromValue(m_uuid);
|
||||||
case Roles::RoleCoordinate:
|
case Roles::RoleCoordinate:
|
||||||
return QVariant::fromValue(m_coordinate);
|
return QVariant::fromValue(m_coordinate);
|
||||||
default:
|
default:
|
||||||
|
@ -22,7 +27,8 @@ QVariant MapLocation::getRole(int role) const
|
||||||
|
|
||||||
MapLocationModel::MapLocationModel(QObject *parent) : QAbstractListModel(parent)
|
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()
|
MapLocationModel::~MapLocationModel()
|
||||||
|
|
|
@ -12,19 +12,25 @@
|
||||||
class MapLocation : public QObject
|
class MapLocation : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
Q_PROPERTY(quint32 uuid MEMBER m_uuid)
|
||||||
Q_PROPERTY(QGeoCoordinate coordinate MEMBER m_coordinate)
|
Q_PROPERTY(QGeoCoordinate coordinate MEMBER m_coordinate)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static const char *PROPERTY_NAME_COORDINATE;
|
||||||
|
static const char *PROPERTY_NAME_UUID;
|
||||||
|
|
||||||
explicit MapLocation();
|
explicit MapLocation();
|
||||||
explicit MapLocation(QGeoCoordinate);
|
explicit MapLocation(quint32 uuid, QGeoCoordinate coord);
|
||||||
|
|
||||||
QVariant getRole(int role) const;
|
QVariant getRole(int role) const;
|
||||||
|
|
||||||
enum Roles {
|
enum Roles {
|
||||||
RoleCoordinate = Qt::UserRole + 1,
|
RoleUuid = Qt::UserRole + 1,
|
||||||
|
RoleCoordinate
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
quint32 m_uuid;
|
||||||
QGeoCoordinate m_coordinate;
|
QGeoCoordinate m_coordinate;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue