Gui: Fix background of non-alternate rows of Property View

This forces background to be rendered using `itemBackground` QProperty.

Fixes: #15263
This commit is contained in:
Kacper Donat
2024-07-09 21:53:40 +02:00
committed by Yorik van Havre
parent 20ffb68961
commit 44ab477480
2 changed files with 14 additions and 14 deletions

View File

@@ -529,28 +529,27 @@ void PropertyEditor::onRowsRemoved(const QModelIndex &, int, int)
removingRows = 0;
}
void PropertyEditor::drawBranches(QPainter *painter, const QRect &rect, const QModelIndex &index) const
void PropertyEditor::drawBranches(QPainter* painter,
const QRect& rect,
const QModelIndex& index) const
{
QTreeView::drawBranches(painter, rect, index);
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
//QStyleOptionViewItem opt = viewOptions();
#else
//QStyleOptionViewItem opt;
//initViewItemOption(&opt);
#endif
auto property = static_cast<PropertyItem*>(index.internalPointer());
if (property && property->isSeparator()) {
painter->fillRect(rect, this->background);
//} else if (selectionModel()->isSelected(index)) {
// painter->fillRect(rect, opt.palette.brush(QPalette::Highlight));
}
}
//QPen savedPen = painter->pen();
//QColor color = static_cast<QRgb>(QApplication::style()->styleHint(QStyle::SH_Table_GridLineColor, &opt));
//painter->setPen(QPen(color));
//painter->drawLine(rect.x(), rect.bottom(), rect.right(), rect.bottom());
//painter->setPen(savedPen);
void Gui::PropertyEditor::PropertyEditor::drawRow(QPainter* painter,
const QStyleOptionViewItem& options,
const QModelIndex& index) const
{
// render background also for non alternate rows based on the `itemBackground` property.
painter->fillRect(options.rect, itemBackground());
QTreeView::drawRow(painter, options, index);
}
void PropertyEditor::buildUp(PropertyModel::PropertyList &&props, bool _checkDocument)

View File

@@ -108,6 +108,7 @@ protected:
void rowsInserted (const QModelIndex & parent, int start, int end) override;
void rowsAboutToBeRemoved (const QModelIndex & parent, int start, int end) override;
void drawBranches(QPainter *painter, const QRect &rect, const QModelIndex &index) const override;
void drawRow(QPainter *painter, const QStyleOptionViewItem &options, const QModelIndex &index) const override;
#if QT_VERSION < QT_VERSION_CHECK(6,0,0)
QStyleOptionViewItem viewOptions() const override;
#else