diff options
-rw-r--r-- | mobile-widgets/qml/MapWidget.qml | 6 | ||||
-rw-r--r-- | qt-models/maplocationmodel.cpp | 13 | ||||
-rw-r--r-- | qt-models/maplocationmodel.h | 7 |
3 files changed, 11 insertions, 15 deletions
diff --git a/mobile-widgets/qml/MapWidget.qml b/mobile-widgets/qml/MapWidget.qml index 38c8fd081..34731e490 100644 --- a/mobile-widgets/qml/MapWidget.qml +++ b/mobile-widgets/qml/MapWidget.qml @@ -60,7 +60,7 @@ Item { MouseArea { anchors.fill: parent onClicked: { - mapHelper.model.selectedUuid = model.uuid + mapHelper.model.setSelectedUuid(model.uuid, true) mapItemImageAnimation.restart() } } @@ -106,12 +106,12 @@ Item { } function centerOnMapLocation(mapLocation) { - mapHelper.model.selectedUuid = mapLocation.uuid + mapHelper.model.setSelectedUuid(mapLocation.uuid, false) animateMapZoomIn(mapLocation.coordinate) } function deselectMapLocation() { - mapHelper.model.selectedUuid = 0 + mapHelper.model.setSelectedUuid(0, false) animateMapZoomOut() } } 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<quint32>(uuid);
+ const bool fromClickBool = qvariant_cast<bool>(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<int, QByteArray> roleNames() const; -private: - quint32 selectedUuid(); - void setSelectedUuid(quint32); +public: + Q_INVOKABLE void setSelectedUuid(QVariant uuid, QVariant fromClick = true); QVector<MapLocation *> m_mapLocations; QHash<int, QByteArray> m_roles; |