diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2016-01-27 12:11:37 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2016-01-27 15:11:37 -0800 |
commit | bda0b0121673d71235dcb05bdc835a91ffb5090d (patch) | |
tree | 661282aa2666a010de2fea57ccdb6bb081eb4699 /qt-mobile/qmlmanager.cpp | |
parent | e895374e4b4dc119a4b45cf2d0f8a50eb6aa89b1 (diff) | |
download | subsurface-bda0b0121673d71235dcb05bdc835a91ffb5090d.tar.gz |
QML UI: avoid clearing and rebuilding the dive list model
This causes all profiles to be rendered which is a massive performance
concern.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-mobile/qmlmanager.cpp')
-rw-r--r-- | qt-mobile/qmlmanager.cpp | 19 |
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 |