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>
This commit is contained in:
Dirk Hohndel 2018-06-25 16:39:56 +08:00
parent f638b7ef80
commit dde2049027

View file

@ -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()