diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2018-06-25 16:39:56 +0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-06-25 20:20:35 +0800 |
commit | dde2049027a483b2e211747e6f18d560a88c28bf (patch) | |
tree | 6e2f5c83664790cd4a14774a65d0c97188475f89 /qt-models/divelistmodel.cpp | |
parent | f638b7ef8054e09dfb81829c04c03f0b2ececf65 (diff) | |
download | subsurface-dde2049027a483b2e211747e6f18d560a88c28bf.tar.gz |
QML UI: correctly update the model
In order to trigger the redraw of an edited dive we need to make sure
the model realizes that it has been updated. So far the only way to make
sure this happens reliably appears to be to remove the item and
re-insert it. Seems weird, but with this the bug of not redrawing the
profile after an edit appears fixed.
Fixes #1419
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-models/divelistmodel.cpp')
-rw-r--r-- | qt-models/divelistmodel.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/qt-models/divelistmodel.cpp b/qt-models/divelistmodel.cpp index 23427002a..8dc119ad8 100644 --- a/qt-models/divelistmodel.cpp +++ b/qt-models/divelistmodel.cpp @@ -94,8 +94,10 @@ void DiveListModel::removeDiveById(int id) void DiveListModel::updateDive(int i, dive *d) { DiveObjectHelper *newDive = new DiveObjectHelper(d); - m_dives.replace(i, newDive); - emit dataChanged(createIndex(i, 0), createIndex(i, 0)); + // we need to make sure that QML knows that this dive has changed - + // the only reliable way I've found is to remove and re-insert it + removeDive(i); + insertDive(i, newDive); } void DiveListModel::clear() |