diff options
| author | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-01 14:02:04 +0100 |
|---|---|---|
| committer | Mikaël Capelle <capelle.mikael@gmail.com> | 2021-01-02 15:38:19 +0100 |
| commit | 3560093f1b37fcf2386e81aaac2fa78005a173ad (patch) | |
| tree | 7d1b60602316cc19b3b61d45d79622a1fd4e6dc4 /src | |
| parent | e5f43788e874e638e1d4dbab20451c36e52df10d (diff) | |
Override separator color instead of mixing it.
Diffstat (limited to 'src')
| -rw-r--r-- | src/modlistview.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/src/modlistview.cpp b/src/modlistview.cpp index da4d79cf..f6a564ac 100644 --- a/src/modlistview.cpp +++ b/src/modlistview.cpp @@ -47,7 +47,17 @@ public: ModListStyledItemDelegated(ModListView* view) :
QStyledItemDelegate(view), m_view(view) { }
- void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override {
+ void initStyleOption(QStyleOptionViewItem* option, const QModelIndex& index) const override
+ {
+ QStyledItemDelegate::initStyleOption(option, index);
+ auto color = childrenColor(index, m_view, Qt::BackgroundRole);
+ if (color.isValid()) {
+ option->backgroundBrush = color;
+ }
+ }
+
+ void paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const override
+ {
QStyleOptionViewItem opt(option);
if (index.column() == 0 && m_view->hasCollapsibleSeparators()) {
if (!index.model()->hasChildren(index) && index.parent().isValid()) {
@@ -58,13 +68,6 @@ public: }
}
QStyledItemDelegate::paint(painter, opt, index);
-
- auto color = childrenColor(index, m_view, Qt::BackgroundRole);
- if (color.isValid()) {
- // int shift = 3 * opt.rect.height() / 4;
- // opt.rect.adjust(0, shift, 0, 0);
- painter->fillRect(opt.rect, color);
- }
}
};
|
