summaryrefslogtreecommitdiffstats
path: root/qt-mobile
diff options
context:
space:
mode:
Diffstat (limited to 'qt-mobile')
-rw-r--r--qt-mobile/qmlmanager.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp
index 5503b3ca3..cc0142d4f 100644
--- a/qt-mobile/qmlmanager.cpp
+++ b/qt-mobile/qmlmanager.cpp
@@ -344,7 +344,7 @@ QString QMLManager::commitChanges(QString diveId, QString date, QString location
bool needResort = false;
if (date != get_dive_date_string(d->when)) {
- needResort = true;
+ diveChanged = 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),
@@ -479,10 +479,23 @@ QString QMLManager::commitChanges(QString diveId, QString date, QString location
free(d->notes);
d->notes = strdup(qPrintable(notes));
}
- if (needResort)
+ int oldIdx = get_idx_by_uniq_id(d->id);
+ if (needResort) {
+ // we know that the only thing that might happen in a resort is that
+ // this one dive moves to a different spot in the dive list
sort_table(&dive_table);
+ int newIdx = get_idx_by_uniq_id(d->id);
+ if (newIdx != oldIdx) {
+ DiveObjectHelper *newDive = new DiveObjectHelper(d);
+ DiveListModel::instance()->removeDive(oldIdx);
+ DiveListModel::instance()->insertDive(newIdx, newDive);
+ diveChanged = false; // because we already modified things
+ }
+ }
+ if (diveChanged)
+ DiveListModel::instance()->updateDive(oldIdx, d);
+
if (diveChanged || needResort) {
- refreshDiveList();
mark_divelist_changed(true);
// this is called "commit" for a reason - when the user saves an
// edit they have a reasonable expectation that their data is actually