From 4d3686edec2a7bca03223df8800b14928a076fc9 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 22 Sep 2019 14:52:25 +0200 Subject: [PATCH] Cleanup: Pass gpsTrackers directly to GpsListModel::update() Instead of using the GpsLocation singleton in GpsListModel::update() to extract the gpsTrackers, pass the gpsTrackers as function argument. The caller has direct access to the GpsLocation object anyway and this make things less entangled. Signed-off-by: Berthold Stoeger --- mobile-widgets/qmlmanager.cpp | 2 +- qt-models/gpslistmodel.cpp | 3 +-- qt-models/gpslistmodel.h | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index 3c9adebbd..62c167653 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -1556,7 +1556,7 @@ void QMLManager::applyGpsData() void QMLManager::populateGpsData() { if (GpsListModel::instance()) - GpsListModel::instance()->update(); + GpsListModel::instance()->update(QVector::fromList(locationProvider->currentGPSInfo().values())); } void QMLManager::clearGpsData() diff --git a/qt-models/gpslistmodel.cpp b/qt-models/gpslistmodel.cpp index 8a623bf00..7849561d3 100644 --- a/qt-models/gpslistmodel.cpp +++ b/qt-models/gpslistmodel.cpp @@ -7,9 +7,8 @@ GpsListModel::GpsListModel(QObject *parent) : QAbstractListModel(parent) { } -void GpsListModel::update() +void GpsListModel::update(QVector trackers) { - QVector trackers = QVector::fromList(GpsLocation::instance()->currentGPSInfo().values()); beginResetModel(); m_gpsFixes = trackers; endResetModel(); diff --git a/qt-models/gpslistmodel.h b/qt-models/gpslistmodel.h index 14145d065..a49855a4d 100644 --- a/qt-models/gpslistmodel.h +++ b/qt-models/gpslistmodel.h @@ -24,7 +24,7 @@ public: int rowCount(const QModelIndex &parent = QModelIndex()) const; QHash roleNames() const; QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - void update(); + void update(QVector trackers); private: QVector m_gpsFixes; };