Skip to content
This repository has been archived by the owner on Apr 14, 2024. It is now read-only.

Commit

Permalink
Fix icon-only delegate
Browse files Browse the repository at this point in the history
The delegate was still rendering display text. But we didn't realize
because the only place where this delegate was used was returning a
QVariant() for DisplayText role earlier. Once we started returning a
valid QString (for copy-paste purposes), this bug showed up.

This didn't work because we further delegate the actual painting to
the base QStyledItemDelegate which re-initializes option.features
from the item index values, so removing HasDisplay does not work.

The fix is to override the displayText() to return a null string.
  • Loading branch information
pstavirs committed Oct 13, 2023
1 parent 1e84869 commit ebe6aef
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion client/icononlydelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ class IconOnlyDelegate : public QStyledItemDelegate
{
QStyleOptionViewItem opt = option;
opt.decorationPosition = QStyleOptionViewItem::Top;
opt.features &= ~QStyleOptionViewItem::HasDisplay;
QStyledItemDelegate::paint(painter, opt, index);
}

QString displayText(const QVariant&, const QLocale&) const
{
return QString();
}
};

#endif
Expand Down

0 comments on commit ebe6aef

Please sign in to comment.