summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2016-01-05 22:57:40 -0800
committerGravatar Dirk Hohndel <dirk@hohndel.org>2016-01-05 22:59:29 -0800
commit4db5e840bf3662e84cc76f3ef3df4fa30e4f7dfc (patch)
tree44dadec576666789aab548d39e006745d27069d0
parente774c8077b516652dc0139a5bac93e60f0ed9b9f (diff)
downloadsubsurface-4db5e840bf3662e84cc76f3ef3df4fa30e4f7dfc.tar.gz
QML UI: refresh the dive list after edit
This fixes two issues. In general, after edits the dive list wasn't updated so it showed data inconsistent with what the dive details showed (clearly bogus). Even more annoyingly, when we change the date or time of a dive it could obviously move around in the dive list. So we need to resort the dive table and recreate the dive list. For really long dive lists this is possibly overkill, but in my testing this seemed very quick and much easier than trying to manually get this right, even in the case where the list wasn't resorted. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-mobile/qmlmanager.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp
index 9b6911b3a..439490b8d 100644
--- a/qt-mobile/qmlmanager.cpp
+++ b/qt-mobile/qmlmanager.cpp
@@ -314,9 +314,10 @@ void QMLManager::commitChanges(QString diveId, QString date, QString location, Q
return;
}
bool diveChanged = false;
+ bool needResort = false;
if (date != get_dive_date_string(d->when)) {
- diveChanged = true;
+ needResort = true;
QDateTime newDate;
// what a pain - Qt will not parse dates if the day of the week is incorrect
// so if the user changed the date but didn't update the day of the week (most likely behavior, actually),
@@ -438,8 +439,14 @@ void QMLManager::commitChanges(QString diveId, QString date, QString location, Q
free(d->notes);
d->notes = strdup(qPrintable(notes));
}
- if (diveChanged) {
- DiveListModel::instance()->updateDive(d);
+ if (needResort)
+ sort_table(&dive_table);
+ if (diveChanged || needResort) {
+ int i;
+ DiveListModel::instance()->clear();
+ for_each_dive(i, d) {
+ DiveListModel::instance()->addDive(d);
+ }
mark_divelist_changed(true);
}
}