summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2016-12-18 11:32:27 +0000
committerStephen Kelly <steveire@gmail.com>2016-12-18 21:34:36 +0000
commit7adfe7494bb4a2c1d3a036fe9dfd946bc00c5d49 (patch)
tree6325897fee2a3b413b9c09e2eff43f75c05d1a90 /src/widgets
parent7c402ad3d15ff5e7c2b7319b1bea821f6f67e26c (diff)
Update model-view documentation about layoutChanged
This has always been true, but hasn't been documented well enough, so triagers are giving incorrect information in bug reports (eg QTBUG-47711 and QTBUG-53221). That incorrect information is being treated as truth by Qt users which take action based on incorrect information. That is a problem, so try to make the documentation clear. Change-Id: I4e44a9a0675cdd7d9289ec209ae32d5a92899fc9 Reviewed-by: David Faure <david.faure@kdab.com>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/doc/src/model-view-programming.qdoc19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/widgets/doc/src/model-view-programming.qdoc b/src/widgets/doc/src/model-view-programming.qdoc
index e727d7fe56..84819e8c1a 100644
--- a/src/widgets/doc/src/model-view-programming.qdoc
+++ b/src/widgets/doc/src/model-view-programming.qdoc
@@ -2070,9 +2070,22 @@
Normally, the begin and end functions are capable of informing other components
about changes to the model's underlying structure. For more complex changes to the
- model's structure, perhaps involving internal reorganization or sorting of data,
- it is necessary to emit the \l{QAbstractItemModel::layoutChanged()}{layoutChanged()}
- signal to cause any attached views to be updated.
+ model's structure, perhaps involving internal reorganization, sorting of data or
+ any other structural change, it is necessary to perform the following sequence:
+
+ \li Emit the \l{QAbstractItemModel::layoutAboutToBeChanged()}{layoutAboutToBeChanged()} signal
+ \li Update internal data which represents the structure of the model.
+ \li Update persistent indexes using \l{QAbstractItemModel::changePersistentIndexList()}{changePersistentIndexList()}
+ \li Emit the \l{QAbstractItemModel::layoutChanged()}{layoutChanged()} signal.
+
+ This sequence can be used for any structural update in lieu of the more
+ high-level and convenient protected methods. For example, if a model of
+ two million rows needs to have all odd numbered rows removed, that
+ is 1 million discountiguous ranges of 1 element each. It would be
+ possible to use beginRemoveRows and endRemoveRows 1 million times, but
+ that would obviously be inefficient. Instead, this can be signalled as a
+ single layout change which updates all necessary persistent indexes at
+ once.
\section3 Lazy population of model data