From 4a126b553f218b0a695b3709f099ac81fa53b1d8 Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Wed, 19 Jul 2017 03:02:34 +0300 Subject: [PATCH] maplocationmodel: add the helper method getMapLocationForUuid() getMapLocationForUuid() accepts a UUID, searches the MapLocation table and returns a pointer. Make use of the new method in setSelectedUuid(). Signed-off-by: Lubomir I. Ivanov --- qt-models/maplocationmodel.cpp | 7 ++++++- qt-models/maplocationmodel.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/qt-models/maplocationmodel.cpp b/qt-models/maplocationmodel.cpp index e01b46621..5ae3609e3 100644 --- a/qt-models/maplocationmodel.cpp +++ b/qt-models/maplocationmodel.cpp @@ -101,10 +101,15 @@ quint32 MapLocationModel::selectedUuid() void MapLocationModel::setSelectedUuid(quint32 uuid) { m_selectedUuid = uuid; + emit selectedLocationChanged(getMapLocationForUuid(uuid)); +} + +MapLocation *MapLocationModel::getMapLocationForUuid(quint32 uuid) +{ MapLocation *location = NULL; foreach(location, m_mapLocations) { if (location->getRole(MapLocation::Roles::RoleUuid) == uuid) break; } - emit selectedLocationChanged(location); + return location; } diff --git a/qt-models/maplocationmodel.h b/qt-models/maplocationmodel.h index 7a1730653..ea720b983 100644 --- a/qt-models/maplocationmodel.h +++ b/qt-models/maplocationmodel.h @@ -52,6 +52,7 @@ public: void add(MapLocation *); void addList(QVector); void clear(); + MapLocation *getMapLocationForUuid(quint32 uuid); protected: QHash roleNames() const;