summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2016-01-10 19:34:21 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-01-10 20:44:22 -0800
commit4f10f7f7ae9b791f08cf97ec64f9a8a0468145c2 (patch)
tree9ec134327d12b9e223dcd519ac1361433d0ad139
parent956b8643194137ade01aac095857066db30b7f73 (diff)
downloadsubsurface-4f10f7f7ae9b791f08cf97ec64f9a8a0468145c2.tar.gz
QML UI: refresh divelist after GPS data was successfully applied
And create a helper to do so to make the code simpler. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-mobile/qmlmanager.cpp20
-rw-r--r--qt-mobile/qmlmanager.h1
-rw-r--r--subsurface-core/gpslocation.cpp5
-rw-r--r--subsurface-core/gpslocation.h2
4 files changed, 19 insertions, 9 deletions
diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp
index df20de11d..7d50884ab 100644
--- a/qt-mobile/qmlmanager.cpp
+++ b/qt-mobile/qmlmanager.cpp
@@ -312,6 +312,17 @@ void QMLManager::loadDivesWithValidCredentials()
setLoadFromCloud(true);
}
+void QMLManager::refreshDiveList()
+{
+ int i;
+ struct dive *d;
+ DiveListModel::instance()->clear();
+ for_each_dive(i, d) {
+ DiveListModel::instance()->addDive(d);
+ }
+
+}
+
// update the dive and return the notes field, stripped of the HTML junk
QString QMLManager::commitChanges(QString diveId, QString date, QString location, QString gps, QString duration, QString depth,
QString airtemp, QString watertemp, QString suit, QString buddy, QString diveMaster, QString notes)
@@ -455,11 +466,7 @@ QString QMLManager::commitChanges(QString diveId, QString date, QString location
if (needResort)
sort_table(&dive_table);
if (diveChanged || needResort) {
- int i;
- DiveListModel::instance()->clear();
- for_each_dive(i, d) {
- DiveListModel::instance()->addDive(d);
- }
+ refreshDiveList();
mark_divelist_changed(true);
}
return notes;
@@ -501,7 +508,8 @@ QString QMLManager::getCurrentPosition()
void QMLManager::applyGpsData()
{
- locationProvider->applyLocations();
+ if (locationProvider->applyLocations())
+ refreshDiveList();
}
void QMLManager::sendGpsData()
diff --git a/qt-mobile/qmlmanager.h b/qt-mobile/qmlmanager.h
index 05dae9925..e346e02f3 100644
--- a/qt-mobile/qmlmanager.h
+++ b/qt-mobile/qmlmanager.h
@@ -86,6 +86,7 @@ public slots:
QString getDate(QString diveId);
QString getCurrentPosition();
void deleteGpsFix(quint64 when);
+ void refreshDiveList();
private:
QString m_cloudUserName;
diff --git a/subsurface-core/gpslocation.cpp b/subsurface-core/gpslocation.cpp
index 361a1b23c..e5f38dc1d 100644
--- a/subsurface-core/gpslocation.cpp
+++ b/subsurface-core/gpslocation.cpp
@@ -208,14 +208,14 @@ static void copy_gps_location(struct gpsTracker &gps, struct dive *d)
}
#define SAME_GROUP 6 * 3600 /* six hours */
-void GpsLocation::applyLocations()
+bool GpsLocation::applyLocations()
{
int i;
bool changed = false;
int last = 0;
int cnt = m_trackers.count();
if (cnt == 0)
- return;
+ return false;
// create a table with the GPS information
QList<struct gpsTracker> gpsTable = m_trackers.values();
@@ -317,6 +317,7 @@ void GpsLocation::applyLocations()
}
if (changed)
mark_divelist_changed(true);
+ return changed;
}
QMap<qint64, gpsTracker> GpsLocation::currentGPSInfo() const
diff --git a/subsurface-core/gpslocation.h b/subsurface-core/gpslocation.h
index 20ed26ed9..0e183d9f8 100644
--- a/subsurface-core/gpslocation.h
+++ b/subsurface-core/gpslocation.h
@@ -25,7 +25,7 @@ public:
GpsLocation(void (*showMsgCB)(const char *msg), QObject *parent);
~GpsLocation();
static GpsLocation *instance();
- void applyLocations();
+ bool applyLocations();
int getGpsNum() const;
QString getUserid(QString user, QString passwd);
bool hasLocationsSource();