From 5ea702199bba685e78c9592b4016dc3afed12833 Mon Sep 17 00:00:00 2001 From: "Lubomir I. Ivanov" Date: Mon, 24 Jul 2017 17:00:06 +0300 Subject: maplocationmodel: make setSelectedUuid() accept "fromClick" flag The idea of this flag is to be able to only to emit the selectedLocationChanged() signal when the user clicked on the map (fromClick == true). MapWidgetHelper::selectedLocationChanged() listens for this signal and only then it will select nearby dives based on a "small-cicle". If "fromClick" is false, it's the backend or the dive list that updated the selection and MapWidgetHelper::selectedLocationChanged() should no be called. Signed-off-by: Lubomir I. Ivanov --- qt-models/maplocationmodel.cpp | 13 +++++-------- qt-models/maplocationmodel.h | 7 +++---- 2 files changed, 8 insertions(+), 12 deletions(-) (limited to 'qt-models') diff --git a/qt-models/maplocationmodel.cpp b/qt-models/maplocationmodel.cpp index 5ae3609e3..52841400d 100644 --- a/qt-models/maplocationmodel.cpp +++ b/qt-models/maplocationmodel.cpp @@ -93,15 +93,12 @@ void MapLocationModel::clear() endRemoveRows(); } -quint32 MapLocationModel::selectedUuid() +void MapLocationModel::setSelectedUuid(QVariant uuid, QVariant fromClick) { - return m_selectedUuid; -} - -void MapLocationModel::setSelectedUuid(quint32 uuid) -{ - m_selectedUuid = uuid; - emit selectedLocationChanged(getMapLocationForUuid(uuid)); + m_selectedUuid = qvariant_cast(uuid); + const bool fromClickBool = qvariant_cast(fromClick); + if (fromClickBool) + emit selectedLocationChanged(getMapLocationForUuid(m_selectedUuid)); } MapLocation *MapLocationModel::getMapLocationForUuid(quint32 uuid) diff --git a/qt-models/maplocationmodel.h b/qt-models/maplocationmodel.h index ea720b983..e17c0ede8 100644 --- a/qt-models/maplocationmodel.h +++ b/qt-models/maplocationmodel.h @@ -38,7 +38,7 @@ class MapLocationModel : public QAbstractListModel { Q_OBJECT Q_PROPERTY(int count READ count NOTIFY countChanged) - Q_PROPERTY(quint32 selectedUuid READ selectedUuid WRITE setSelectedUuid NOTIFY selectedLocationChanged) + Q_PROPERTY(quint32 selectedUuid MEMBER m_selectedUuid NOTIFY selectedLocationChanged) public: MapLocationModel(QObject *parent = NULL); @@ -57,9 +57,8 @@ public: protected: QHash roleNames() const; -private: - quint32 selectedUuid(); - void setSelectedUuid(quint32); +public: + Q_INVOKABLE void setSelectedUuid(QVariant uuid, QVariant fromClick = true); QVector m_mapLocations; QHash m_roles; -- cgit v1.2.3-70-g09d2