summaryrefslogtreecommitdiffstats
path: root/src/gui/itemviews/qheaderview.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2010-02-03 17:00:24 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2010-02-04 09:21:32 (GMT)
commit188c2ef11e92d04dcf334309c85a7f1b14945aaa (patch)
treef25391e9b903c82dd426eb299cb7e66b3a9b8de7 /src/gui/itemviews/qheaderview.cpp
parent5cff63b217118e087a6cbd1f27c2a28be83374bb (diff)
downloadQt-188c2ef11e92d04dcf334309c85a7f1b14945aaa.zip
Qt-188c2ef11e92d04dcf334309c85a7f1b14945aaa.tar.gz
Qt-188c2ef11e92d04dcf334309c85a7f1b14945aaa.tar.bz2
QHeaderView: fixes sectionClicked() emitted with wrong section index
The obvious fix is to use the previsously computed 'section' as paramatter. (It is even faster) But one might wonder why logicalIndexAt() does not return the same result before and after flipSortIndicator(). The reason is that while being sorted, in _q_layoutChanged, all the hidden section where unhidden and hidden again. Leaving some pending computation. Task-number: QTBUG-7833 Reviewed-by: Gabriel
Diffstat (limited to 'src/gui/itemviews/qheaderview.cpp')
-rw-r--r--src/gui/itemviews/qheaderview.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/gui/itemviews/qheaderview.cpp b/src/gui/itemviews/qheaderview.cpp
index 8a456e6..1c26e51 100644
--- a/src/gui/itemviews/qheaderview.cpp
+++ b/src/gui/itemviews/qheaderview.cpp
@@ -1853,11 +1853,9 @@ void QHeaderViewPrivate::_q_layoutChanged()
persistentHiddenSections.clear();
return;
}
+
+ QBitArray oldSectionHidden = sectionHidden;
bool sectionCountChanged = false;
- for (int i = 0; i < sectionHidden.count(); ++i) {
- if (sectionHidden.testBit(i))
- q->setSectionHidden(logicalIndex(i), false);
- }
for (int i = 0; i < persistentHiddenSections.count(); ++i) {
QModelIndex index = persistentHiddenSections.at(i);
@@ -1866,6 +1864,7 @@ void QHeaderViewPrivate::_q_layoutChanged()
? index.column()
: index.row());
q->setSectionHidden(logical, true);
+ oldSectionHidden.setBit(logical, false);
} else if (!sectionCountChanged && (modelSectionCount() != sectionCount)) {
sectionCountChanged = true;
break;
@@ -1873,6 +1872,11 @@ void QHeaderViewPrivate::_q_layoutChanged()
}
persistentHiddenSections.clear();
+ for (int i = 0; i < oldSectionHidden.count(); ++i) {
+ if (oldSectionHidden.testBit(i))
+ q->setSectionHidden(logicalIndex(i), false);
+ }
+
// the number of sections changed; we need to reread the state of the model
if (sectionCountChanged)
q->initializeSections();
@@ -2300,7 +2304,7 @@ void QHeaderView::mouseReleaseEvent(QMouseEvent *e)
int section = logicalIndexAt(pos);
if (section != -1 && section == d->pressed) {
d->flipSortIndicator(section);
- emit sectionClicked(logicalIndexAt(pos));
+ emit sectionClicked(section);
}
if (d->pressed != -1)
updateSection(d->pressed);