diff options
author | David Faure <david.faure@kdab.com> | 2021-02-26 22:47:41 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-03-09 21:16:54 +0000 |
commit | b9091e4cec8be067509464ff068612a07ed4a95d (patch) | |
tree | 413ae6e9a83dd4390086f05d375426ddcd339165 /src | |
parent | 2ed9bae3dfbdadea6f60eef6e3a1558918b7a36a (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 'src')
-rw-r--r-- | src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp b/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp index 09deee4429..72ff6c1f36 100644 --- a/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp +++ b/src/corelib/itemmodels/qconcatenatetablesproxymodel.cpp @@ -622,9 +622,14 @@ void QConcatenateTablesProxyModelPrivate::_q_slotDataChanged(const QModelIndex & Q_Q(QConcatenateTablesProxyModel); Q_ASSERT(from.isValid()); Q_ASSERT(to.isValid()); + if (from.column() >= m_columnCount) + return; + QModelIndex adjustedTo = to; + if (to.column() >= m_columnCount) + adjustedTo = to.siblingAtColumn(m_columnCount - 1); const QModelIndex myFrom = q->mapFromSource(from); Q_ASSERT(q->checkIndex(myFrom, QAbstractItemModel::CheckIndexOption::IndexIsValid)); - const QModelIndex myTo = q->mapFromSource(to); + const QModelIndex myTo = q->mapFromSource(adjustedTo); Q_ASSERT(q->checkIndex(myTo, QAbstractItemModel::CheckIndexOption::IndexIsValid)); emit q->dataChanged(myFrom, myTo, roles); } |