summaryrefslogtreecommitdiffstats
path: root/src/gui/itemviews/qheaderview.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/itemviews/qheaderview.cpp')
-rw-r--r--src/gui/itemviews/qheaderview.cpp31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp
index 5bd82d4..dc63b25 100644
--- a/src/gui/itemviews/qheaderview.cpp
+++ b/src/gui/itemviews/qheaderview.cpp
@@ -1388,8 +1388,7 @@ int QHeaderView::defaultSectionSize() const
void QHeaderView::setDefaultSectionSize(int size)
{
Q_D(QHeaderView);
- d->defaultSectionSize = size;
- d->forceInitializing = true;
+ d->setDefaultSectionSize(size);
}
/*!
@@ -1894,9 +1893,6 @@ void QHeaderView::initializeSections()
//make sure we update the hidden sections
if (newCount < oldCount)
d->updateHiddenSections(0, newCount-1);
- } else if (d->forceInitializing) {
- initializeSections(0, newCount - 1);
- d->forceInitializing = false;
}
}
@@ -1952,7 +1948,7 @@ void QHeaderView::initializeSections(int start, int end)
if (!d->sectionHidden.isEmpty())
d->sectionHidden.resize(d->sectionCount);
- if (d->sectionCount > oldCount || d->forceInitializing)
+ if (d->sectionCount > oldCount)
d->createSectionSpan(start, end, (end - start + 1) * d->defaultSectionSize, d->globalResizeMode);
//Q_ASSERT(d->headerLength() == d->length);
@@ -3364,6 +3360,29 @@ void QHeaderViewPrivate::cascadingResize(int visual, int newSize)
viewport->update();
}
+void QHeaderViewPrivate::setDefaultSectionSize(int size)
+{
+ Q_Q(QHeaderView);
+ defaultSectionSize = size;
+ int currentVisualIndex = 0;
+ for (int i = 0; i < sectionSpans.count(); ++i) {
+ QHeaderViewPrivate::SectionSpan &span = sectionSpans[i];
+ if (span.size > 0) {
+ //we resize it if it is not hidden (ie size > 0)
+ const int newSize = span.count * size;
+ if (newSize != span.size) {
+ length += newSize - span.size; //the whole length is changed
+ const int oldSectionSize = span.sectionSize();
+ span.size = span.count * size;
+ for (int i = currentVisualIndex; i < currentVisualIndex + span.count; ++i) {
+ emit q->sectionResized(logicalIndex(i), oldSectionSize, size);
+ }
+ }
+ }
+ currentVisualIndex += span.count;
+ }
+}
+
void QHeaderViewPrivate::resizeSectionSpan(int visualIndex, int oldSize, int newSize)
{
Q_Q(QHeaderView);