summaryrefslogtreecommitdiffstats
path: root/qt-models
diff options
context:
space:
mode:
Diffstat (limited to 'qt-models')
-rw-r--r--qt-models/maplocationmodel.cpp22
-rw-r--r--qt-models/maplocationmodel.h2
2 files changed, 24 insertions, 0 deletions
diff --git a/qt-models/maplocationmodel.cpp b/qt-models/maplocationmodel.cpp
index 9666ca009..d8070862e 100644
--- a/qt-models/maplocationmodel.cpp
+++ b/qt-models/maplocationmodel.cpp
@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-2.0
+#include <QDebug>
#include "maplocationmodel.h"
const char *MapLocation::PROPERTY_NAME_COORDINATE = "coordinate";
@@ -39,6 +40,11 @@ void MapLocation::setCoordinate(QGeoCoordinate coord)
emit coordinateChanged();
}
+void MapLocation::setCoordinateNoEmit(QGeoCoordinate coord)
+{
+ m_coordinate = coord;
+}
+
quint32 MapLocation::uuid()
{
return m_uuid;
@@ -136,3 +142,19 @@ MapLocation *MapLocationModel::getMapLocationForUuid(quint32 uuid)
}
return NULL;
}
+
+void MapLocationModel::updateMapLocationCoordinates(quint32 uuid, QGeoCoordinate coord)
+{
+ MapLocation *location;
+ int row = 0;
+ foreach(location, m_mapLocations) {
+ if (uuid == location->uuid()) {
+ location->setCoordinateNoEmit(coord);
+ emit dataChanged(createIndex(0, row), createIndex(0, row));
+ return;
+ }
+ row++;
+ }
+ // should not happen, as this should be called only when editing an existing marker
+ qWarning() << "MapLocationModel::updateMapLocationCoordinates(): cannot find MapLocation for uuid:" << uuid;
+}
diff --git a/qt-models/maplocationmodel.h b/qt-models/maplocationmodel.h
index 114de4c92..e198773a5 100644
--- a/qt-models/maplocationmodel.h
+++ b/qt-models/maplocationmodel.h
@@ -27,6 +27,7 @@ public:
QVariant getRole(int role) const;
QGeoCoordinate coordinate();
void setCoordinate(QGeoCoordinate coord);
+ void setCoordinateNoEmit(QGeoCoordinate coord);
quint32 uuid();
enum Roles {
@@ -62,6 +63,7 @@ public:
void addList(QVector<MapLocation *>);
void clear();
MapLocation *getMapLocationForUuid(quint32 uuid);
+ void updateMapLocationCoordinates(quint32 uuid, QGeoCoordinate coord);
Q_INVOKABLE void setSelectedUuid(QVariant uuid, QVariant fromClick = true);
quint32 selectedUuid();