From 1d01fff0061bde6260259a9a2b46f80a31ad1218 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 31 Aug 2019 23:24:21 +0200 Subject: Map: export isSelected as attribute from MapLocationModel Recently we changed the MapLocationModel-items to store whether they are selected. Thus, we can directly export an isSelected flag instead of calling a function taking a dive-site argument. 1) This makes the QML easier to read. 2) This avoids passing pointers through QML which has caused us lots of pain. Signed-off-by: Berthold Stoeger --- qt-models/maplocationmodel.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'qt-models/maplocationmodel.cpp') diff --git a/qt-models/maplocationmodel.cpp b/qt-models/maplocationmodel.cpp index 57fc76179..3aad02980 100644 --- a/qt-models/maplocationmodel.cpp +++ b/qt-models/maplocationmodel.cpp @@ -48,6 +48,8 @@ QVariant MapLocation::getRole(int role) const QString("qrc:///dive-location-marker-icon"); case Roles::RoleZ: return m_selected ? 1 : 0; + case Roles::RoleIsSelected: + return QVariant::fromValue(m_selected); default: return QVariant(); } @@ -105,6 +107,7 @@ QHash MapLocationModel::roleNames() const roles[MapLocation::Roles::RoleName] = "name"; roles[MapLocation::Roles::RolePixmap] = "pixmap"; roles[MapLocation::Roles::RoleZ] = "z"; + roles[MapLocation::Roles::RoleIsSelected] = "isSelected"; return roles; } -- cgit v1.2.3-70-g09d2