diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2017-04-15 19:06:46 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-04-16 07:43:48 -0700 |
commit | 20f525ceddbeee225c444c8cc0158004562b20df (patch) | |
tree | 739383ba5696d0bfb83f1f8325cdab534b6aaa09 | |
parent | 03b2b854bf557ed8ca18b20065ee01cb5e1a424f (diff) | |
download | subsurface-20f525ceddbeee225c444c8cc0158004562b20df.tar.gz |
QML UI: correctly update dive list after editing timestamp
Once we re-inserted the dive in the list we aren't done, quite the
contrary - we now need to make sure that we handle any other changes
and mark the dive list as updated.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | mobile-widgets/qmlmanager.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/mobile-widgets/qmlmanager.cpp b/mobile-widgets/qmlmanager.cpp index d53e5357a..1b5521e33 100644 --- a/mobile-widgets/qmlmanager.cpp +++ b/mobile-widgets/qmlmanager.cpp @@ -906,7 +906,7 @@ void QMLManager::commitChanges(QString diveId, QString date, QString location, Q // now that we have it all figured out, let's see what we need // to update DiveListModel *dm = DiveListModel::instance(); - int oldModelIdx = dm->getDiveIdx(d->id); + int modelIdx = dm->getDiveIdx(d->id); 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 @@ -914,9 +914,10 @@ void QMLManager::commitChanges(QString diveId, QString date, QString location, Q sort_table(&dive_table); int newIdx = get_idx_by_uniq_id(d->id); if (newIdx != oldIdx) { - DiveListModel::instance()->removeDive(oldModelIdx); - DiveListModel::instance()->insertDive(oldModelIdx - (newIdx - oldIdx), myDive); - diveChanged = false; // because we already modified things + DiveListModel::instance()->removeDive(modelIdx); + modelIdx += (newIdx - oldIdx); + DiveListModel::instance()->insertDive(modelIdx, myDive); + diveChanged = true; // because we already modified things } } if (diveChanged) { @@ -931,7 +932,7 @@ void QMLManager::commitChanges(QString diveId, QString date, QString location, Q d->meandepth.mm = d->dc.meandepth.mm = 0; d->dc = *fake_dc(&d->dc, true); } - DiveListModel::instance()->updateDive(oldModelIdx, d); + DiveListModel::instance()->updateDive(modelIdx, d); invalidate_dive_cache(d); mark_divelist_changed(true); } |