diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2009-04-20 07:23:43 (GMT) |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2009-04-20 07:23:43 (GMT) |
commit | 67926b8e4d9e7463597ef113944d78ca326fd9ae (patch) | |
tree | e24fa54e245a8c3b27cd1f740aaf5d296e05621b /src/gui/itemviews | |
parent | 2c762f3b8b284a7c6dc0c499b7052013bad5b707 (diff) | |
parent | 10194aafd10824fe1919aa44083224e8bea442ca (diff) | |
download | Qt-67926b8e4d9e7463597ef113944d78ca326fd9ae.zip Qt-67926b8e4d9e7463597ef113944d78ca326fd9ae.tar.gz Qt-67926b8e4d9e7463597ef113944d78ca326fd9ae.tar.bz2 |
Merge branch '4.5' of git@scm.dev.nokia.troll.no:qt/qt
Conflicts:
src/gui/itemviews/qheaderview_p.h
Diffstat (limited to 'src/gui/itemviews')
-rw-r--r-- | src/gui/itemviews/qheaderview.cpp | 31 | ||||
-rw-r--r-- | src/gui/itemviews/qheaderview_p.h | 3 |
2 files changed, 26 insertions, 8 deletions
diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp index eb36178..6238df5 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); @@ -3365,6 +3361,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); diff --git a/src/gui/itemviews/qheaderview_p.h b/src/gui/itemviews/qheaderview_p.h index 95bd84c..cfb1c3e 100644 --- a/src/gui/itemviews/qheaderview_p.h +++ b/src/gui/itemviews/qheaderview_p.h @@ -90,7 +90,6 @@ public: highlightSelected(false), stretchLastSection(false), cascadingResizing(false), - forceInitializing(false), resizeRecursionBlock(false), stretchSections(0), contentsSections(0), @@ -271,7 +270,6 @@ public: bool highlightSelected; bool stretchLastSection; bool cascadingResizing; - bool forceInitializing; bool resizeRecursionBlock; int stretchSections; int contentsSections; @@ -307,6 +305,7 @@ public: void createSectionSpan(int start, int end, int size, QHeaderView::ResizeMode mode); void removeSectionsFromSpans(int start, int end); void resizeSectionSpan(int visualIndex, int oldSize, int newSize); + void setDefaultSectionSize(int size); inline int headerSectionCount() const { // for debugging int count = 0; |