summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDavid Faure <david.faure@kdab.com>2021-02-26 22:47:41 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-03-09 16:17:08 +0000
commitd7a2177a7a544c550fcd0b3fc92528bcdb9582f6 (patch)
treec275a1ab353f0dddb80515b1e400b3660d847f6b /tests
parent7ce1b646ca5ff9ecc789d64a83168b74b90f621d (diff)
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 <giuseppe.dangelo@kdab.com> (cherry picked from commit f6efbd23b59bcf75866ce47fb762c99f2e4a128a) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp11
1 files changed, 11 insertions, 0 deletions
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()