Merge "QConcatenateTablesProxyModel: skip dataChanged in hidden columns"
This commit is contained in:
commit
1d567eb63d
@ -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);
|
||||
}
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user