From dde2049027a483b2e211747e6f18d560a88c28bf Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 25 Jun 2018 16:39:56 +0800 Subject: 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 --- qt-models/divelistmodel.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'qt-models') 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() -- cgit v1.2.3-70-g09d2