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 <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-09-22 14:52:25 +02:00
parent eae9a99615
commit 8576edd8d6
3 changed files with 3 additions and 4 deletions

View file

@ -1556,7 +1556,7 @@ void QMLManager::applyGpsData()
void QMLManager::populateGpsData()
{
if (GpsListModel::instance())
GpsListModel::instance()->update();
GpsListModel::instance()->update(QVector<gpsTracker>::fromList(locationProvider->currentGPSInfo().values()));
}
void QMLManager::clearGpsData()

View file

@ -7,9 +7,8 @@ GpsListModel::GpsListModel(QObject *parent) : QAbstractListModel(parent)
{
}
void GpsListModel::update()
void GpsListModel::update(QVector<gpsTracker> trackers)
{
QVector<gpsTracker> trackers = QVector<gpsTracker>::fromList(GpsLocation::instance()->currentGPSInfo().values());
beginResetModel();
m_gpsFixes = trackers;
endResetModel();

View file

@ -24,7 +24,7 @@ public:
int rowCount(const QModelIndex &parent = QModelIndex()) const;
QHash<int, QByteArray> roleNames() const;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
void update();
void update(QVector<gpsTracker> trackers);
private:
QVector<gpsTracker> m_gpsFixes;
};