summaryrefslogtreecommitdiffstats
path: root/src/widgets/itemviews
diff options
context:
space:
mode:
authorQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-02-22 09:19:56 +0100
committerQt Forward Merge Bot <qt_forward_merge_bot@qt-project.org>2018-02-22 09:19:56 +0100
commit9f33b84b0937a53e8e31e0c1e34506eecef6f2e4 (patch)
tree91e9bac96d61c08babd5b6415f276d44888e79dd /src/widgets/itemviews
parent4cbc7f798017d76e018dc3f04968703624b6a6cf (diff)
parentb97765efd452921f75c1d04820c4b5e9e9d49100 (diff)
Merge remote-tracking branch 'origin/5.11' into dev
Diffstat (limited to 'src/widgets/itemviews')
-rw-r--r--src/widgets/itemviews/qheaderview.cpp34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp
index c90a61d4ff..b0359de3ea 100644
--- a/src/widgets/itemviews/qheaderview.cpp
+++ b/src/widgets/itemviews/qheaderview.cpp
@@ -2168,15 +2168,19 @@ void QHeaderViewPrivate::_q_sectionsAboutToBeChanged()
sectionItems[visual].size = lastSectionSize;
}
for (int i = 0; i < sectionItems.size(); ++i) {
- const auto &s = sectionItems.at(i);
+ auto s = sectionItems.at(i);
// only add if the section is not default and not visually moved
if (s.size == defaultSectionSize && !s.isHidden && s.resizeMode == globalResizeMode)
continue;
+ const int logical = logicalIndex(i);
+ if (s.isHidden)
+ s.size = hiddenSectionSize.value(logical);
+
// ### note that we are using column or row 0
layoutChangePersistentSections.append({orientation == Qt::Horizontal
- ? model->index(0, logicalIndex(i), root)
- : model->index(logicalIndex(i), 0, root),
+ ? model->index(0, logical, root)
+ : model->index(logical, 0, root),
s});
if (layoutChangePersistentSections.size() > 1000)
@@ -2201,6 +2205,30 @@ void QHeaderViewPrivate::_q_sectionsChanged()
return;
}
+ bool hasPersistantIndexes = false;
+ for (const auto &item : oldPersistentSections) {
+ if (item.index.isValid()) {
+ hasPersistantIndexes = true;
+ break;
+ }
+ }
+
+ // Though far from perfect we here try to retain earlier/existing behavior
+ // ### See QHeaderViewPrivate::_q_layoutAboutToBeChanged()
+ // When we don't have valid hasPersistantIndexes it can be due to
+ // - all sections are default sections
+ // - the row/column 0 which is used for persistent indexes is gone
+ // - all non-default sections were removed
+ // case one is trivial, in case two we assume nothing else changed (it's the best
+ // guess we can do - everything else can not be handled correctly for now)
+ // case three can not be handled correctly with layoutChanged - removeSections
+ // should be used instead for this
+ if (!hasPersistantIndexes) {
+ if (oldCount != newCount)
+ q->initializeSections();
+ return;
+ }
+
// adjust section size
if (newCount != oldCount) {
const int min = qBound(0, oldCount, newCount - 1);