diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-10-27 11:45:21 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-10-27 11:52:44 (GMT) |
commit | 0897713a560700f574386499a872f59e3fc4ce7d (patch) | |
tree | 28a48428cd0e74add989e9068f70ea1b8551a439 /src/gui/itemviews | |
parent | 5ff7b773a0f59e174001da1f0550a7f0c2b6f485 (diff) | |
download | Qt-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')
-rw-r--r-- | src/gui/itemviews/qtreeview.cpp | 17 | ||||
-rw-r--r-- | src/gui/itemviews/qtreeview_p.h | 3 |
2 files changed, 10 insertions, 10 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 ®ion) 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); diff --git a/src/gui/itemviews/qtreeview_p.h b/src/gui/itemviews/qtreeview_p.h index f89c328..62676d8 100644 --- a/src/gui/itemviews/qtreeview_p.h +++ b/src/gui/itemviews/qtreeview_p.h @@ -67,7 +67,8 @@ struct QTreeViewItem uint expanded : 1; uint spanning : 1; uint hasChildren : 1; // if the item has visible children (even if collapsed) - uint total : 29; // total number of children visible + uint hasMoreSiblings : 1; + uint total : 28; // total number of children visible uint level : 16; // indentation int height : 16; // row height }; |