summaryrefslogtreecommitdiffstats
path: root/src/gui/itemviews
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-11-23 10:59:05 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-11-23 11:14:11 (GMT)
commitb4dbbd30c8092a81984cca30248db087353fe66e (patch)
tree7d338a46623118bf262fe58ac5731ddf040a5ced /src/gui/itemviews
parent76b66d6da548ce4a247727f14e09b1d301330db5 (diff)
downloadQt-b4dbbd30c8092a81984cca30248db087353fe66e.zip
Qt-b4dbbd30c8092a81984cca30248db087353fe66e.tar.gz
Qt-b4dbbd30c8092a81984cca30248db087353fe66e.tar.bz2
Fix QHeaderView when the model is reset and section have moved.
The logicalIndices and visualIndices array where not clean of the old sections, resulting in corrupted header. Task-number: QTBUG-6058 Reviewed-by: Thierry
Diffstat (limited to 'src/gui/itemviews')
-rw-r--r--src/gui/itemviews/qheaderview.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp
index 5df8481..6f0fba6 100644
--- a/src/gui/itemviews/qheaderview.cpp
+++ b/src/gui/itemviews/qheaderview.cpp
@@ -1913,7 +1913,6 @@ void QHeaderView::initializeSections(int start, int end)
Q_ASSERT(start >= 0);
Q_ASSERT(end >= 0);
- d->executePostedLayout();
d->invalidateCachedSizeHint();
if (end + 1 < d->sectionCount) {
@@ -1939,11 +1938,25 @@ void QHeaderView::initializeSections(int start, int end)
d->sectionCount = end + 1;
if (!d->logicalIndices.isEmpty()) {
- d->logicalIndices.resize(d->sectionCount);
- d->visualIndices.resize(d->sectionCount);
- for (int i = start; i < d->sectionCount; ++i){
- d->logicalIndices[i] = i;
- d->visualIndices[i] = i;
+ if (oldCount <= d->sectionCount) {
+ d->logicalIndices.resize(d->sectionCount);
+ d->visualIndices.resize(d->sectionCount);
+ for (int i = oldCount; i < d->sectionCount; ++i) {
+ d->logicalIndices[i] = i;
+ d->visualIndices[i] = i;
+ }
+ } else {
+ int j = 0;
+ for (int i = 0; i < oldCount; ++i) {
+ int v = d->logicalIndices.at(i);
+ if (v < d->sectionCount) {
+ d->logicalIndices[j] = v;
+ d->visualIndices[v] = j;
+ j++;
+ }
+ }
+ d->logicalIndices.resize(d->sectionCount);
+ d->visualIndices.resize(d->sectionCount);
}
}