source data changes, in particular for roles other than the sort role, are not forwarded (SortProxyModel::handleDataChanged), thus having a SortProxyModel in the stack makes you "lose" updates.
In a customer project using SPM, I just implemented it using linear search to do the mapping:
int minRow = std::numeric_limits<int>::max();
int maxRow = -1;
for (int sourceRow = topLeft.row(); sourceRow <= bottomRight.row(); ++sourceRow) {
auto it = std::find(m_rowMap.cbegin(), m_rowMap.cend(), sourceRow);
Q_ASSERT(it != m_rowMap.cend());
const auto proxyRow = static_cast<int>(std::distance(m_rowMap.cbegin(), it));
minRow = std::min(minRow, proxyRow);
maxRow = std::max(maxRow, proxyRow);
}
Q_ASSERT(minRow <= maxRow);
emit dataChanged(index(minRow, 0), index(maxRow, 0), roles);
That does the job for my use case, but generic solution probably should use something more efficient.
source data changes, in particular for roles other than the sort role, are not forwarded (SortProxyModel::handleDataChanged), thus having a SortProxyModel in the stack makes you "lose" updates.
In a customer project using SPM, I just implemented it using linear search to do the mapping:
That does the job for my use case, but generic solution probably should use something more efficient.