From e6da35f6055d3ae7acf38d89456d3047f055a9cd Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 2 Nov 2009 14:07:15 +0100 Subject: QStyleSheetStyle: ItemViews: Fixes drawing of items and branches. I am not sure why the code was there, but after some testing, it is better to remove it: - While painting the branch, we should not look at the ::item pseudo class at all. - Items specific stuff is drawn in PE_PanelItemViewItem, not PE_PanelItemViewRow - Selection is handled his way by the native style. background-color is not for selection and should not depends on SH_ItemView_ShowDecorationSelected Reviewed-by: Thierry Task-number: QTBUG-5228 Task-number: 258382 Task-number: QTBUG-4338 --- src/gui/styles/qstylesheetstyle.cpp | 30 +--- .../uiloader/baseline/css_itemview_task258382.ui | 179 +++++++++++++++++++++ 2 files changed, 180 insertions(+), 29 deletions(-) create mode 100644 tests/auto/uiloader/baseline/css_itemview_task258382.ui diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index 32f259b..a224218 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -4277,23 +4277,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op p->fillRect(v2->rect, v2->palette.alternateBase()); subRule.drawRule(p, opt->rect); } else { - QStyleOptionViewItemV2 v2Copy(*v2); - if (v2->showDecorationSelected) { - QRenderRule subRule2 = renderRule(w, opt, PseudoElement_ViewItem); - if (v2->state & QStyle::State_Selected) { - subRule2.configurePalette(&v2Copy.palette, QPalette::NoRole, QPalette::Highlight); - } else if (v2->features & QStyleOptionViewItemV2::Alternate) { - subRule2.configurePalette(&v2Copy.palette, QPalette::NoRole, QPalette::AlternateBase); - } else if (subRule2.hasBackground()) { - p->fillRect(v2->rect, subRule2.background()->brush); - } - } else if (v2->features & QStyleOptionViewItemV2::Alternate) { - quint64 pc = v2->state & QStyle::State_Enabled ? PseudoClass_Enabled : PseudoClass_Disabled; - pc |= PseudoClass_Alternate; - QRenderRule subRule2 = renderRule(w, PseudoElement_ViewItem, pc); - subRule2.configurePalette(&v2Copy.palette, QPalette::NoRole, QPalette::AlternateBase); - } - baseStyle()->drawPrimitive(pe, &v2Copy, p, w); + baseStyle()->drawPrimitive(pe, v2, p, w); } } return; @@ -4358,18 +4342,6 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op break; case PE_PanelItemViewItem: - if (!styleHint(SH_ItemView_ShowDecorationSelected, opt, w)) { - rect = subElementRect(QStyle::SE_ItemViewItemText, opt, w) - | subElementRect(QStyle::SE_ItemViewItemDecoration, opt, w) - | subElementRect(QStyle::SE_ItemViewItemCheckIndicator, opt, w); - } - pseudoElement = PseudoElement_ViewItem; - break; - - case PE_PanelItemViewRow: - ParentStyle::drawPrimitive(pe, opt, p, w); - if (!styleHint(SH_ItemView_ShowDecorationSelected, opt, w)) - return; pseudoElement = PseudoElement_ViewItem; break; diff --git a/tests/auto/uiloader/baseline/css_itemview_task258382.ui b/tests/auto/uiloader/baseline/css_itemview_task258382.ui new file mode 100644 index 0000000..11c56b4 --- /dev/null +++ b/tests/auto/uiloader/baseline/css_itemview_task258382.ui @@ -0,0 +1,179 @@ + + + Form + + + + 0 + 0 + 437 + 352 + + + + Form + + + ::item { border: 1px solid black; background-color: purple; } +::item {margin-left: 20px; } + +QAbstractItemView { selection-background-color: red; +show-decoration- selected: 0; + } + +::item:selected { background-color: yellow; } + + + + + + + 1 + + + + + New Column + + + + + New Item + + + + + New Item + + + + + New Item + + + + New Subitem + + + + New Subitem + + + + + New Item + + + + + New Item + + + + + + + + + + + New Row + + + + + New Row + + + + + New Row + + + + + New Row + + + + + New Row + + + + + New Column + + + + + New Column + + + + + New Column + + + + + New Column + + + + + mljkh mh mjl + + + + + h jlh mjklh + + + + + mjklh mlhj mjlh m + + + + + mlhj lmhj + + + + + mlkj l + + + + + mlkj + + + + + mlkj lmkj + + + + + mlkhj mlh + + + + + mlkj lmkj + + + + + mlkj lmkj + + + + + + + + + -- cgit v0.12