diff options
-rw-r--r-- | src/widgets/itemviews/qtreeview.cpp | 13 | ||||
-rw-r--r-- | src/widgets/styles/qstyleoption.cpp | 4 | ||||
-rw-r--r-- | src/widgets/styles/qstyleoption.h | 4 | ||||
-rw-r--r-- | src/widgets/styles/qstylesheetstyle.cpp | 2 |
4 files changed, 17 insertions, 6 deletions
diff --git a/src/widgets/itemviews/qtreeview.cpp b/src/widgets/itemviews/qtreeview.cpp index 0fd0572741f..2c040b2d635 100644 --- a/src/widgets/itemviews/qtreeview.cpp +++ b/src/widgets/itemviews/qtreeview.cpp @@ -1786,6 +1786,7 @@ void QTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &option, if (alternate) { opt.features.setFlag(QStyleOptionViewItem::Alternate, d->current & 1); } + opt.features &= ~QStyleOptionViewItem::IsDecoratedRootColumn; /* Prior to Qt 4.3, the background of the branch (in selected state and alternate row color was provided by the view. For backward compatibility, @@ -1800,7 +1801,6 @@ void QTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &option, painter->setClipRect(QRect(position, y, width, height)); } // draw background for the branch (selection + alternate row) - opt.rect = branches; // We use showDecorationSelected both to store the style hint, and to indicate // that the entire row has to be selected (see overrides of the value if @@ -1810,10 +1810,15 @@ void QTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &option, const bool oldShowDecorationSelected = opt.showDecorationSelected; opt.showDecorationSelected = style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, &opt, this); - opt.features |= QStyleOptionViewItem::HasDecoration; opt.rect = branches; - style()->drawPrimitive(QStyle::PE_PanelItemViewRow, &opt, painter, this); - opt.features &= ~QStyleOptionViewItem::HasDecoration; + if (opt.rect.width() > 0) { + // the root item also has a branch decoration + opt.features |= QStyleOptionViewItem::IsDecoratedRootColumn; + // we now want to draw the branch decoration + opt.features |= QStyleOptionViewItem::IsDecorationForRootColumn; + style()->drawPrimitive(QStyle::PE_PanelItemViewRow, &opt, painter, this); + opt.features &= ~QStyleOptionViewItem::IsDecorationForRootColumn; + } // draw background of the item (only alternate row). rest of the background // is provided by the delegate diff --git a/src/widgets/styles/qstyleoption.cpp b/src/widgets/styles/qstyleoption.cpp index 27e66b7cb6c..f1fc18003c1 100644 --- a/src/widgets/styles/qstyleoption.cpp +++ b/src/widgets/styles/qstyleoption.cpp @@ -3093,6 +3093,10 @@ QStyleOptionViewItem::QStyleOptionViewItem(int version) \value HasCheckIndicator Indicates that the item has a check state indicator. \value HasDisplay Indicates that the item has a display role. \value HasDecoration Indicates that the item has a decoration role. + \value [since 6.9] IsDecoratedRootColumn Indicates that the item has a tree view branch + part for painting. + \value [since 6.9] IsDecorationForRootColumn Indicates that the item contains the + information to draw the tree view branch part. */ /*! diff --git a/src/widgets/styles/qstyleoption.h b/src/widgets/styles/qstyleoption.h index d63d1c9a0e1..49b37132de3 100644 --- a/src/widgets/styles/qstyleoption.h +++ b/src/widgets/styles/qstyleoption.h @@ -403,7 +403,9 @@ public: Alternate = 0x02, HasCheckIndicator = 0x04, HasDisplay = 0x08, - HasDecoration = 0x10 + HasDecoration = 0x10, + IsDecoratedRootColumn = 0x20, + IsDecorationForRootColumn = 0x40, }; Q_DECLARE_FLAGS(ViewItemFeatures, ViewItemFeature) diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 468c7a51550..f8b3ff027ec 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -4875,7 +4875,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op if (rule.background()->brush.color().alpha() != 1.0) baseStyle()->drawPrimitive(pe, opt, p, w); // Skip border for the branch and draw only the brackground - if (vopt->features & QStyleOptionViewItem::HasDecoration && + if (vopt->features & QStyleOptionViewItem::IsDecorationForRootColumn && (vopt->viewItemPosition == QStyleOptionViewItem::Beginning || vopt->viewItemPosition == QStyleOptionViewItem::OnlyOne) && rule.hasBorder()) { if (rule.hasDrawable()) { |