mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
maplocation: add helpers for coordinate and uuid
getRole() returns a QVariant and the cast is a small overhead. Using these helpers will reduce the overhead. Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
This commit is contained in:
parent
f7095aa89e
commit
2dea6f5146
2 changed files with 24 additions and 2 deletions
|
@ -28,6 +28,22 @@ QVariant MapLocation::getRole(int role) const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QGeoCoordinate MapLocation::coordinate()
|
||||||
|
{
|
||||||
|
return m_coordinate;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MapLocation::setCoordinate(QGeoCoordinate coord)
|
||||||
|
{
|
||||||
|
m_coordinate = coord;
|
||||||
|
emit coordinateChanged();
|
||||||
|
}
|
||||||
|
|
||||||
|
quint32 MapLocation::uuid()
|
||||||
|
{
|
||||||
|
return m_uuid;
|
||||||
|
}
|
||||||
|
|
||||||
MapLocationModel::MapLocationModel(QObject *parent) : QAbstractListModel(parent)
|
MapLocationModel::MapLocationModel(QObject *parent) : QAbstractListModel(parent)
|
||||||
{
|
{
|
||||||
m_roles[MapLocation::Roles::RoleUuid] = MapLocation::PROPERTY_NAME_UUID;
|
m_roles[MapLocation::Roles::RoleUuid] = MapLocation::PROPERTY_NAME_UUID;
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
class MapLocation : public QObject
|
class MapLocation : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_PROPERTY(quint32 uuid MEMBER m_uuid)
|
Q_PROPERTY(quint32 uuid READ uuid)
|
||||||
Q_PROPERTY(QGeoCoordinate coordinate MEMBER m_coordinate)
|
Q_PROPERTY(QGeoCoordinate coordinate READ coordinate WRITE setCoordinate NOTIFY coordinateChanged)
|
||||||
Q_PROPERTY(QString name MEMBER m_name)
|
Q_PROPERTY(QString name MEMBER m_name)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -25,6 +25,9 @@ public:
|
||||||
explicit MapLocation(quint32 uuid, QGeoCoordinate coord, QString name);
|
explicit MapLocation(quint32 uuid, QGeoCoordinate coord, QString name);
|
||||||
|
|
||||||
QVariant getRole(int role) const;
|
QVariant getRole(int role) const;
|
||||||
|
QGeoCoordinate coordinate();
|
||||||
|
void setCoordinate(QGeoCoordinate coord);
|
||||||
|
quint32 uuid();
|
||||||
|
|
||||||
enum Roles {
|
enum Roles {
|
||||||
RoleUuid = Qt::UserRole + 1,
|
RoleUuid = Qt::UserRole + 1,
|
||||||
|
@ -36,6 +39,9 @@ private:
|
||||||
quint32 m_uuid;
|
quint32 m_uuid;
|
||||||
QGeoCoordinate m_coordinate;
|
QGeoCoordinate m_coordinate;
|
||||||
QString m_name;
|
QString m_name;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void coordinateChanged();
|
||||||
};
|
};
|
||||||
|
|
||||||
class MapLocationModel : public QAbstractListModel
|
class MapLocationModel : public QAbstractListModel
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue