summaryrefslogtreecommitdiffstats
path: root/src/gui/itemviews/qtreeview.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-10-27 11:45:21 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-10-27 11:52:44 (GMT)
commit0897713a560700f574386499a872f59e3fc4ce7d (patch)
tree28a48428cd0e74add989e9068f70ea1b8551a439 /src/gui/itemviews/qtreeview.cpp
parent5ff7b773a0f59e174001da1f0550a7f0c2b6f485 (diff)
downloadQt-0897713a560700f574386499a872f59e3fc4ce7d.zip
Qt-0897713a560700f574386499a872f59e3fc4ce7d.tar.gz
Qt-0897713a560700f574386499a872f59e3fc4ce7d.tar.bz2
QTreeView: Make sure the state QStyle::State_Sibling is correctly set
That state used not to be set for drawing the content of the items. Also, it could be wrong for branches if there was hidden items. Reviewed-by: Thierry Task-number: related to 234930
Diffstat (limited to 'src/gui/itemviews/qtreeview.cpp')
-rw-r--r--src/gui/itemviews/qtreeview.cpp17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp
index 49c8e34..e74ecfc 100644
--- a/src/gui/itemviews/qtreeview.cpp
+++ b/src/gui/itemviews/qtreeview.cpp
@@ -1423,7 +1423,8 @@ void QTreeView::drawTree(QPainter *painter, const QRegion &region) const
const int itemHeight = d->itemHeight(i);
option.rect.setRect(0, y, viewportWidth, itemHeight);
option.state = state | (viewItems.at(i).expanded ? QStyle::State_Open : QStyle::State_None)
- | (viewItems.at(i).hasChildren ? QStyle::State_Children : QStyle::State_None );
+ | (viewItems.at(i).hasChildren ? QStyle::State_Children : QStyle::State_None)
+ | (viewItems.at(i).hasMoreSiblings ? QStyle::State_Sibling : QStyle::State_None);
d->current = i;
d->spanning = viewItems.at(i).spanning;
if (!multipleRects || !drawn.contains(i)) {
@@ -1749,12 +1750,7 @@ void QTreeView::drawBranches(QPainter *painter, const QRect &rect,
const bool expanded = viewItem.expanded;
const bool children = viewItem.hasChildren;
- bool moreSiblings = false;
- if (d->hiddenIndexes.isEmpty())
- moreSiblings = (d->model->rowCount(parent) - 1 > index.row());
- else
- moreSiblings = ((d->viewItems.size() > item +1)
- && (d->viewItems.at(item + 1).index.parent() == parent));
+ bool moreSiblings = viewItem.hasMoreSiblings;
opt.state = QStyle::State_Item | extraFlags
| (moreSiblings ? QStyle::State_Sibling : QStyle::State_None)
@@ -3126,7 +3122,7 @@ void QTreeViewPrivate::layout(int i)
int hidden = 0;
int last = 0;
int children = 0;
-
+ QTreeViewItem *item = 0;
for (int j = first; j < first + count; ++j) {
current = model->index(j - first, 0, parent);
if (isRowHidden(current)) {
@@ -3134,13 +3130,16 @@ void QTreeViewPrivate::layout(int i)
last = j - hidden + children;
} else {
last = j - hidden + children;
- QTreeViewItem *item = &viewItems[last];
+ if (item)
+ item->hasMoreSiblings = true;
+ item = &viewItems[last];
item->index = current;
item->level = level;
item->height = 0;
item->spanning = q->isFirstColumnSpanned(current.row(), parent);
item->expanded = false;
item->total = 0;
+ item->hasMoreSiblings = false;
if (isIndexExpanded(current)) {
item->expanded = true;
layout(last);