diff options
author | David Faure <david.faure@kdab.com> | 2021-02-26 22:47:41 +0100 |
---|---|---|
committer | David Faure <david.faure@kdab.com> | 2021-03-09 13:39:45 +0100 |
commit | f6efbd23b59bcf75866ce47fb762c99f2e4a128a (patch) | |
tree | 9b79afab7cc564056c656829e3b72ccc6157f6ce /tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel | |
parent | 09d36158d39abaf01b3647181b74ae531a855dfd (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
Pick-to: 6.1 6.0 5.15
Change-Id: I939e8ec0faf41370472f86785851292e4372f72c
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel')
-rw-r--r-- | tests/auto/corelib/itemmodels/qconcatenatetablesproxymodel/tst_qconcatenatetablesproxymodel.cpp | 11 |
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() |