mirror of
https://github.com/subsurface/subsurface.git
synced 2025-01-19 06:15:26 +00:00
maplocationmodel: add the "namer" property
The MapLocation QObject now has a QString property "name", which is translating the dive_site->name member. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
parent
8c7d1a1163
commit
be0d513324
3 changed files with 13 additions and 5 deletions
|
@ -52,7 +52,7 @@ void MapWidgetHelper::reloadMapLocations()
|
|||
}
|
||||
}
|
||||
if (!diveSiteTooClose)
|
||||
locationList.append(new MapLocation(ds->uuid, QGeoCoordinate(latitude, longitude)));
|
||||
locationList.append(new MapLocation(ds->uuid, QGeoCoordinate(latitude, longitude), QString(ds->name)));
|
||||
}
|
||||
m_mapLocationModel->addList(locationList);
|
||||
}
|
||||
|
|
|
@ -3,13 +3,14 @@
|
|||
|
||||
const char *MapLocation::PROPERTY_NAME_COORDINATE = "coordinate";
|
||||
const char *MapLocation::PROPERTY_NAME_UUID = "uuid";
|
||||
const char *MapLocation::PROPERTY_NAME_NAME = "name";
|
||||
|
||||
MapLocation::MapLocation()
|
||||
{
|
||||
}
|
||||
|
||||
MapLocation::MapLocation(quint32 uuid, QGeoCoordinate coord) :
|
||||
m_uuid(uuid), m_coordinate(coord)
|
||||
MapLocation::MapLocation(quint32 uuid, QGeoCoordinate coord, QString name) :
|
||||
m_uuid(uuid), m_coordinate(coord), m_name(name)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -20,6 +21,8 @@ QVariant MapLocation::getRole(int role) const
|
|||
return QVariant::fromValue(m_uuid);
|
||||
case Roles::RoleCoordinate:
|
||||
return QVariant::fromValue(m_coordinate);
|
||||
case Roles::RoleName:
|
||||
return QVariant::fromValue(m_name);
|
||||
default:
|
||||
return QVariant();
|
||||
}
|
||||
|
@ -29,6 +32,7 @@ MapLocationModel::MapLocationModel(QObject *parent) : QAbstractListModel(parent)
|
|||
{
|
||||
m_roles[MapLocation::Roles::RoleUuid] = MapLocation::PROPERTY_NAME_UUID;
|
||||
m_roles[MapLocation::Roles::RoleCoordinate] = MapLocation::PROPERTY_NAME_COORDINATE;
|
||||
m_roles[MapLocation::Roles::RoleName] = MapLocation::PROPERTY_NAME_NAME;
|
||||
}
|
||||
|
||||
MapLocationModel::~MapLocationModel()
|
||||
|
|
|
@ -14,24 +14,28 @@ class MapLocation : public QObject
|
|||
Q_OBJECT
|
||||
Q_PROPERTY(quint32 uuid MEMBER m_uuid)
|
||||
Q_PROPERTY(QGeoCoordinate coordinate MEMBER m_coordinate)
|
||||
Q_PROPERTY(QString name MEMBER m_name)
|
||||
|
||||
public:
|
||||
static const char *PROPERTY_NAME_COORDINATE;
|
||||
static const char *PROPERTY_NAME_UUID;
|
||||
static const char *PROPERTY_NAME_NAME;
|
||||
|
||||
explicit MapLocation();
|
||||
explicit MapLocation(quint32 uuid, QGeoCoordinate coord);
|
||||
explicit MapLocation(quint32 uuid, QGeoCoordinate coord, QString name);
|
||||
|
||||
QVariant getRole(int role) const;
|
||||
|
||||
enum Roles {
|
||||
RoleUuid = Qt::UserRole + 1,
|
||||
RoleCoordinate
|
||||
RoleCoordinate,
|
||||
RoleName
|
||||
};
|
||||
|
||||
private:
|
||||
quint32 m_uuid;
|
||||
QGeoCoordinate m_coordinate;
|
||||
QString m_name;
|
||||
};
|
||||
|
||||
class MapLocationModel : public QAbstractListModel
|
||||
|
|
Loading…
Add table
Reference in a new issue