Tweak default item sizing in RDTreeView to better handle font scales

* We're somewhat trying to match Qt's behaviour here, as we want to ensure that
  the items are always sized as if they have space for an icon when
  ignoreIconSize() is true. In this case there's a +2 added "to avoid icons
  overlapping" but only after the decorationsize is max'd with the font size. In
  cases where the font is bigger than the icon, this is important.
This commit is contained in:
baldurk
2021-05-20 11:34:36 +01:00
parent a1a0dee085
commit 5a65cbf62c
+5 -4
View File
@@ -99,8 +99,12 @@ QSize RDTreeViewDelegate::sizeHint(const QStyleOptionViewItem &option, const QMo
{
QSize ret = RichTextViewDelegate::sizeHint(option, index);
int minHeight = option.fontMetrics.height();
if(!m_View->ignoreIconSize())
minHeight = qMax(option.decorationSize.height(), minHeight);
if(m_View->ignoreIconSize())
ret.setHeight(qMax(option.decorationSize.height() + 2, ret.height()));
ret.setHeight(qMax(qMax(option.decorationSize.height(), minHeight) + 2, ret.height()));
// expand a pixel for the grid lines
if(m_View->visibleGridLines())
@@ -108,9 +112,6 @@ QSize RDTreeViewDelegate::sizeHint(const QStyleOptionViewItem &option, const QMo
// ensure we have at least the margin on top of font size. If the style applied more, don't add to
// it.
int minHeight = option.fontMetrics.height();
if(!m_View->ignoreIconSize())
minHeight = qMax(option.decorationSize.height(), minHeight);
ret.setHeight(qMax(ret.height(), minHeight + m_View->verticalItemMargin()));
return ret;