summaryrefslogtreecommitdiffstats
path: root/subsurface-core
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2016-01-07 21:34:21 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-01-07 21:41:52 -0800
commit06dcc9ab8d6d7ca7d9967fa9db4c8e87ae376dec (patch)
tree2c897f0f5cd5a7e7044470e127257c99921f4361 /subsurface-core
parent8a98dd485a80790cd80be9332230675b42c8051c (diff)
downloadsubsurface-06dcc9ab8d6d7ca7d9967fa9db4c8e87ae376dec.tar.gz
Populate the model with the GPS fixes
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'subsurface-core')
-rw-r--r--subsurface-core/gpslocation.cpp26
-rw-r--r--subsurface-core/gpslocation.h1
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(&gt);
+ }
+ 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();
};