summaryrefslogtreecommitdiffstats
path: root/src/remoteobjects/qremoteobjectabstractitemmodelreplica.cpp
diff options
context:
space:
mode:
authorJoni Poikelin <joni.poikelin@qt.io>2021-03-30 12:48:11 +0300
committerSona Kurazyan <sona.kurazyan@qt.io>2021-10-13 12:37:19 +0200
commita194a3cf30f024659d3e2223ef7a9fd82319cbb6 (patch)
treea729f04284e0f6a2bb35e02e6f958b31d2f69855 /src/remoteobjects/qremoteobjectabstractitemmodelreplica.cpp
parentb936726d56f33176349ff52ab20306ffc91efac3 (diff)
Fix header change replication
Fixes: QTBUG-91041 Pick-to: 6.2 5.15 Change-Id: I5b56ed81ee9df658e0c596199dfde067bba6cd43 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Brett Stottlemyer <bstottle@ford.com>
Diffstat (limited to 'src/remoteobjects/qremoteobjectabstractitemmodelreplica.cpp')
-rw-r--r--src/remoteobjects/qremoteobjectabstractitemmodelreplica.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/remoteobjects/qremoteobjectabstractitemmodelreplica.cpp b/src/remoteobjects/qremoteobjectabstractitemmodelreplica.cpp
index 099415f..bf13b36 100644
--- a/src/remoteobjects/qremoteobjectabstractitemmodelreplica.cpp
+++ b/src/remoteobjects/qremoteobjectabstractitemmodelreplica.cpp
@@ -264,6 +264,8 @@ void QAbstractItemModelReplicaImplementation::onRowsInserted(const QtPrivate::In
auto parentItem = cacheData(parentIndex);
q->beginInsertRows(parentIndex, start, end);
parentItem->insertChildren(start, end);
+ for (int i = start; i <= end; ++i)
+ m_headerData[1].append(CacheEntry());
q->endInsertRows();
if (!parentItem->hasChildren && parentItem->columnCount > 0) {
parentItem->hasChildren = true;
@@ -290,6 +292,8 @@ void QAbstractItemModelReplicaImplementation::onColumnsInserted(const QtPrivate:
return;
q->beginInsertColumns(parentIndex, start, end);
parentItem->columnCount += end - start + 1;
+ for (int i = start; i <= end; ++i)
+ m_headerData[0].append(CacheEntry());
q->endInsertColumns();
if (!parentItem->hasChildren && parentItem->children.size() > 0) {
parentItem->hasChildren = true;
@@ -311,6 +315,7 @@ void QAbstractItemModelReplicaImplementation::onRowsRemoved(const QtPrivate::Ind
q->beginRemoveRows(parentIndex, start, end);
if (parentItem)
parentItem->removeChildren(start, end);
+ m_headerData[1].erase(m_headerData[1].begin() + start, m_headerData[1].begin() + end + 1);
q->endRemoveRows();
}
@@ -669,7 +674,7 @@ void QAbstractItemModelReplicaImplementation::onHeaderDataChanged(Qt::Orientatio
// TODO clean cache
const int index = orientation == Qt::Horizontal ? 0 : 1;
QList<CacheEntry> &entries = m_headerData[index];
- for (int i = first; i < last; ++i )
+ for (int i = first; i <= last && i < entries.size(); ++i )
entries[i].data.clear();
emit q->headerDataChanged(orientation, first, last);
}