summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel/qabstractitemmodel.cpp
diff options
context:
space:
mode:
authorStephen Kelly <stephen.kelly@kdab.com>2010-09-23 12:14:18 (GMT)
committerGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2011-06-27 16:13:45 (GMT)
commit0f6853e9c775dd8fbb64f66119c2c9b2ea23da29 (patch)
tree880ec281b07648a14b0a4b95473001b5fb8b5eb5 /src/corelib/kernel/qabstractitemmodel.cpp
parent031958c130904c16a4bafa5617aaa197469efa9e (diff)
downloadQt-0f6853e9c775dd8fbb64f66119c2c9b2ea23da29.zip
Qt-0f6853e9c775dd8fbb64f66119c2c9b2ea23da29.tar.gz
Qt-0f6853e9c775dd8fbb64f66119c2c9b2ea23da29.tar.bz2
Provide the resetInternalData slot to cleanly reset data in proxy subclasses.
Direct subclasses of QAbstractItemModel are unnaffected as they can update internal data in a slot connected to the sourceModel's modelReset signal or layoutChanged signal. Rehabilitated for 4.8. Should be reverted again in Qt 5. Reviewed-by: gabi Merge-request: 694
Diffstat (limited to 'src/corelib/kernel/qabstractitemmodel.cpp')
-rw-r--r--src/corelib/kernel/qabstractitemmodel.cpp22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp
index b7ac6aa..54cc301 100644
--- a/src/corelib/kernel/qabstractitemmodel.cpp
+++ b/src/corelib/kernel/qabstractitemmodel.cpp
@@ -1348,6 +1348,26 @@ void QAbstractItemModelPrivate::columnsRemoved(const QModelIndex &parent,
*/
/*!
+ \since 4.8
+
+ This slot is called just after the internal data of a model is cleared
+ while it is being reset.
+
+ This slot is provided the convenience of subclasses of concrete proxy
+ models, such as subclasses of QSortFilterProxyModel which maintain extra
+ data.
+
+ \snippet doc/src/snippets/code/src_corelib_kernel_qabstractitemmodel.cpp 10
+
+ \sa modelAboutToBeReset(), modelReset()
+*/
+void QAbstractItemModel::resetInternalData()
+{
+
+}
+
+
+/*!
Constructs an abstract item model with the given \a parent.
*/
QAbstractItemModel::QAbstractItemModel(QObject *parent)
@@ -2888,6 +2908,7 @@ void QAbstractItemModel::reset()
Q_D(QAbstractItemModel);
emit modelAboutToBeReset();
d->invalidatePersistentIndexes();
+ QMetaObject::invokeMethod(this, "resetInternalData");
emit modelReset();
}
@@ -2930,6 +2951,7 @@ void QAbstractItemModel::endResetModel()
{
Q_D(QAbstractItemModel);
d->invalidatePersistentIndexes();
+ QMetaObject::invokeMethod(this, "resetInternalData");
emit modelReset();
}