diff options
-rw-r--r-- | subsurface-core/gpslocation.cpp | 26 | ||||
-rw-r--r-- | subsurface-core/gpslocation.h | 1 |
2 files changed, 27 insertions, 0 deletions
diff --git a/subsurface-core/gpslocation.cpp b/subsurface-core/gpslocation.cpp index c2f8b0e2f..cbcb6910b 100644 --- a/subsurface-core/gpslocation.cpp +++ b/subsurface-core/gpslocation.cpp @@ -324,6 +324,32 @@ void GpsLocation::applyLocations() mark_divelist_changed(true); } +void GpsLocation::updateModel() +{ + GpsListModel *gpsListModel = GpsListModel::instance(); + if (!gpsListModel) { + qDebug() << "no gpsListModel"; + return; + } + int cnt = geoSettings->value("count", 0).toInt(); + if (cnt == 0) { + qDebug() << "no gps fixes"; + gpsListModel->clear(); + return; + } + + // create a table with the GPS information + struct gpsTracker gt; + for (int i = 0; i < cnt; i++) { + gt.latitude.udeg = geoSettings->value(QString("gpsFix%1_lat").arg(i)).toInt(); + gt.longitude.udeg = geoSettings->value(QString("gpsFix%1_lon").arg(i)).toInt(); + gt.when = geoSettings->value(QString("gpsFix%1_time").arg(i)).toULongLong(); + gt.name = geoSettings->value(QString("gpsFix%1_name").arg(i)).toString(); + gpsListModel->addGpsFix(>); + } + qDebug() << "added" << cnt << "gps fixes to model"; +} + void GpsLocation::clearGpsData() { geoSettings->clear(); diff --git a/subsurface-core/gpslocation.h b/subsurface-core/gpslocation.h index 2d2d915d0..3dbe48320 100644 --- a/subsurface-core/gpslocation.h +++ b/subsurface-core/gpslocation.h @@ -49,6 +49,7 @@ public slots: void downloadFromServer(); void postError(QNetworkReply::NetworkError error); void getUseridError(QNetworkReply::NetworkError error); + void updateModel(); void clearGpsData(); }; |