From b9091e4cec8be067509464ff068612a07ed4a95d Mon Sep 17 00:00:00 2001 From: David Faure Date: Fri, 26 Feb 2021 22:47:41 +0100 Subject: QConcatenateTablesProxyModel: skip dataChanged in hidden columns When the source models don't have the same number of columns, the proxy keeps only the smallest number of columns across all source models. Afterwards, if a source model emits dataChanged in a column past that number (a "hidden" column), the proxy needs to ignore it rather than assert. But also, if the source model emits a dataChanged signal across both visible and hidden columns, then the last column number needs to be adjusted so that the signal is correctly processed and forwarded. Task-number: QTBUG-91253 Change-Id: I939e8ec0faf41370472f86785851292e4372f72c Reviewed-by: Giuseppe D'Angelo (cherry picked from commit f6efbd23b59bcf75866ce47fb762c99f2e4a128a) Reviewed-by: Qt Cherry-pick Bot --- .../tst_qconcatenatetablesproxymodel.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp b/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp index 40617c1f7d..43a34f4e9c 100644 --- a/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp @@ -453,6 +453,17 @@ void tst_QConcatenateTablesProxyModel::shouldUseSmallestColumnCount() const QModelIndex indexD = pm.mapFromSource(mod2.index(0, 0)); QVERIFY(indexD.isValid()); QCOMPARE(indexD, pm.index(1, 0)); + + // Test setData in an ignored column (QTBUG-91253) + QSignalSpy dataChangedSpy(&pm, SIGNAL(dataChanged(QModelIndex,QModelIndex))); + mod.setData(mod.index(0, 1), "b"); + QCOMPARE(dataChangedSpy.count(), 0); + + // Test dataChanged across all columns, some visible, some ignored + mod.dataChanged(mod.index(0, 0), mod.index(0, 2)); + QCOMPARE(dataChangedSpy.count(), 1); + QCOMPARE(dataChangedSpy.at(0).at(0).toModelIndex(), pm.index(0, 0)); + QCOMPARE(dataChangedSpy.at(0).at(1).toModelIndex(), pm.index(0, 0)); } void tst_QConcatenateTablesProxyModel::shouldIncreaseColumnCountWhenRemovingFirstModel() -- cgit v1.2.3