diff --git a/qrenderdoc/Widgets/Extended/RDTreeView.cpp b/qrenderdoc/Widgets/Extended/RDTreeView.cpp index a22861614..1f925a79e 100644 --- a/qrenderdoc/Widgets/Extended/RDTreeView.cpp +++ b/qrenderdoc/Widgets/Extended/RDTreeView.cpp @@ -24,6 +24,19 @@ #include "RDTreeView.h" #include +#include + +class RDTreeViewtyleProxy : public QProxyStyle +{ +public: + int styleHint(StyleHint hint, const QStyleOption *option = 0, const QWidget *widget = 0, + QStyleHintReturn *returnData = 0) const + { + if(hint == QStyle::SH_ItemView_ShowDecorationSelected) + return 1; + return QProxyStyle::styleHint(hint, option, widget, returnData); + } +}; RDTreeViewDelegate::RDTreeViewDelegate(RDTreeView *view) : QStyledItemDelegate(view), m_View(view) { @@ -50,6 +63,10 @@ QSize RDTreeViewDelegate::sizeHint(const QStyleOptionViewItem &option, const QMo RDTreeView::RDTreeView(QWidget *parent) : QTreeView(NULL) { setItemDelegate(new RDTreeViewDelegate(this)); + + // set a proxy style that does nothing but return true for + // QStyle::SH_ItemView_ShowDecorationSelected styleHint. + setStyle(new RDTreeViewtyleProxy); } void RDTreeView::drawRow(QPainter *painter, const QStyleOptionViewItem &options, diff --git a/qrenderdoc/Widgets/Extended/RDTreeWidget.cpp b/qrenderdoc/Widgets/Extended/RDTreeWidget.cpp index ad36d1317..74a78b43e 100644 --- a/qrenderdoc/Widgets/Extended/RDTreeWidget.cpp +++ b/qrenderdoc/Widgets/Extended/RDTreeWidget.cpp @@ -725,27 +725,10 @@ void RDTreeWidget::drawBranches(QPainter *painter, const QRect &rect, const QMod } // fill in the background behind the lines for the whole row, since by default it doesn't show up - // behind the tree lines. There's SH_ItemView_ShowDecorationSelected which controls that for the - // selection highlight but that requires a proxy style and there's no equivalent for the - // background colour. - // - // Instead we just manually fill the background colour, and handle the highlight colour when - // appropriate. + // behind the tree lines. - QRect allLinesRect(rect.left(), rect.top(), rect.left() + parents.count() * indentation() + 1, - rect.height()); - if(selectionModel()->isSelected(index)) - { - QPalette::ColorGroup group = QPalette::Normal; - - if(!isEnabled()) - group = QPalette::Disabled; - else if(!hasFocus()) - group = QPalette::Inactive; - - painter->fillRect(allLinesRect, palette().brush(group, QPalette::Highlight)); - } - else if(item->m_back != QBrush()) + QRect allLinesRect(rect.left(), rect.top(), (parents.count() + 1) * indentation(), rect.height()); + if(!selectionModel()->isSelected(index) && item->m_back != QBrush()) { painter->fillRect(allLinesRect, item->m_back); }