From 8455bfee76ed3f1bd3bba8bd3688a7afa94ae0bb Mon Sep 17 00:00:00 2001 From: Wang ChunLin Date: Fri, 23 Oct 2020 11:02:30 +0800 Subject: Fix QSFPM not emitting dataChanged when source model is set QSortFilterProxyModel did not emit dataChanged when calling setSourceModel() after modifying the source model. QSortFilterProxyModel::setSourceModel and QSortFilterProxyModelPrivate::_q_sourceReset(), _q_clearMapping is called to delete the source_index_mapping. They also need to call create_mapping function to re-create it. Fixes: QTBUG-87781 Pick-to: 5.15 Change-Id: Idbe34696c9d3a2fbf354b653c870bac61378811d Reviewed-by: Volker Hilsheimer --- src/corelib/itemmodels/qsortfilterproxymodel.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/corelib/itemmodels/qsortfilterproxymodel.cpp b/src/corelib/itemmodels/qsortfilterproxymodel.cpp index f748a95160..fb09c22798 100644 --- a/src/corelib/itemmodels/qsortfilterproxymodel.cpp +++ b/src/corelib/itemmodels/qsortfilterproxymodel.cpp @@ -1479,6 +1479,7 @@ void QSortFilterProxyModelPrivate::_q_sourceReset() _q_clearMapping(); // All internal structures are deleted in clear() q->endResetModel(); + create_mapping(QModelIndex()); update_source_sort_column(); if (dynamic_sortfilter && update_source_sort_column()) sort(); @@ -2042,6 +2043,7 @@ void QSortFilterProxyModel::setSourceModel(QAbstractItemModel *sourceModel) connect(d->model, SIGNAL(modelReset()), this, SLOT(_q_sourceReset())); endResetModel(); + d->create_mapping(QModelIndex()); if (d->update_source_sort_column() && d->dynamic_sortfilter) d->sort(); } -- cgit v1.2.3