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 <neolit123@gmail.com>
This commit is contained in:
Lubomir I. Ivanov 2017-07-19 03:02:34 +03:00 committed by Dirk Hohndel
parent a920d683a1
commit 4a126b553f
2 changed files with 7 additions and 1 deletions

View file

@ -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;
}

View file

@ -52,6 +52,7 @@ public:
void add(MapLocation *);
void addList(QVector<MapLocation *>);
void clear();
MapLocation *getMapLocationForUuid(quint32 uuid);
protected:
QHash<int, QByteArray> roleNames() const;