From a35d1bd0e79e83b5ef49b76087e7cfe5a38d829c Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Thu, 2 May 2019 00:09:59 +0200 Subject: Map: show multiple selected dive sites If multiple dives are selected, highlight all corresponding sites. For that, replace the MapLocationModel::m_selectedDs pointer by a QVector<>. Fill the vector in MapLocationModel::reload() and add a isSelected() member function. Signed-off-by: Berthold Stoeger --- qt-models/maplocationmodel.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'qt-models/maplocationmodel.h') diff --git a/qt-models/maplocationmodel.h b/qt-models/maplocationmodel.h index 6c28c6c99..6f075cc84 100644 --- a/qt-models/maplocationmodel.h +++ b/qt-models/maplocationmodel.h @@ -50,7 +50,6 @@ class MapLocationModel : public QAbstractListModel { Q_OBJECT Q_PROPERTY(int count READ count NOTIFY countChanged) - Q_PROPERTY(QVariant selectedDs READ selectedDs NOTIFY selectedDsChanged) public: MapLocationModel(QObject *parent = NULL); @@ -65,7 +64,9 @@ public: MapLocation *getMapLocation(const struct dive_site *ds); void updateMapLocationCoordinates(const struct dive_site *ds, QGeoCoordinate coord); Q_INVOKABLE void setSelected(struct dive_site *ds, bool fromClick = true); - QVariant selectedDs(); + // The dive site is passed as a QVariant, because a null-QVariant is not automatically + // transformed into a null pointer and warning messages are spewed onto the console. + Q_INVOKABLE bool isSelected(const QVariant &ds) const; protected: QHash roleNames() const override; @@ -73,11 +74,10 @@ protected: private: QVector m_mapLocations; QHash m_roles; - struct dive_site *m_selectedDs; + QVector m_selectedDs; signals: void countChanged(int c); - void selectedDsChanged(); void selectedLocationChanged(MapLocation *); }; -- cgit v1.2.3-70-g09d2