QIdentityProxyModel: avoid emitting reset in no-op setSourceModel
QSortFilterProxyModel does this exactly, it was missing in QIdentityProxyModel. Change-Id: If14bc7a377c1ad9235dd70222e3bfbf88eef11c0 Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io> (cherry picked from commit 5e971101f016e6e7d015594c539612e770e2999d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
db28f1912c
commit
4d644342ad
@ -291,10 +291,13 @@ QVariant QIdentityProxyModel::headerData(int section, Qt::Orientation orientatio
|
||||
*/
|
||||
void QIdentityProxyModel::setSourceModel(QAbstractItemModel* newSourceModel)
|
||||
{
|
||||
beginResetModel();
|
||||
|
||||
Q_D(QIdentityProxyModel);
|
||||
|
||||
if (newSourceModel == d->model)
|
||||
return;
|
||||
|
||||
beginResetModel();
|
||||
|
||||
// Call QObject::disconnect() unconditionally, if there is an existing source
|
||||
// model, it's disconnected, and if there isn't, then calling disconnect() on
|
||||
// a default-constructed Connection does nothing
|
||||
|
@ -357,10 +357,19 @@ void tst_QIdentityProxyModel::reset()
|
||||
resetCommand.doCommand();
|
||||
}
|
||||
|
||||
QVERIFY(modelBeforeSpy.size() == 1 && 1 == proxyBeforeSpy.size());
|
||||
QVERIFY(modelAfterSpy.size() == 1 && 1 == proxyAfterSpy.size());
|
||||
QCOMPARE(modelBeforeSpy.size(), 1);
|
||||
QCOMPARE(modelAfterSpy.size(), 1);
|
||||
QCOMPARE(proxyBeforeSpy.size(), 1);
|
||||
QCOMPARE(proxyAfterSpy.size(), 1);
|
||||
|
||||
verifyIdentity(&model);
|
||||
|
||||
// setSourceModel again shouldn't emit reset
|
||||
m_proxy->setSourceModel(&model);
|
||||
|
||||
QCOMPARE(proxyBeforeSpy.size(), 1);
|
||||
QCOMPARE(proxyAfterSpy.size(), 1);
|
||||
|
||||
m_proxy->setSourceModel(0);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user