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>
This commit is contained in:
Dirk Hohndel 2016-01-10 19:34:21 -08:00
parent 956b864319
commit 4f10f7f7ae
4 changed files with 19 additions and 9 deletions

View file

@ -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()

View file

@ -86,6 +86,7 @@ public slots:
QString getDate(QString diveId);
QString getCurrentPosition();
void deleteGpsFix(quint64 when);
void refreshDiveList();
private:
QString m_cloudUserName;