QHeaderView: consider Qt::DecorationRole size within paintSection()
When an icon was given through Qt::DecorationRole, the available space for the text was not adjusted which created a graphical glitch. Task-number: QTBUG-62091 Change-Id: I0f20b6de95deed14fb882efde5c81b83ab3e9a7e Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
This commit is contained in:
parent
fd3f732489
commit
2950de715e
@ -2848,14 +2848,18 @@ void QHeaderView::paintSection(QPainter *painter, const QRect &rect, int logical
|
|||||||
if (isSortIndicatorShown() && sortIndicatorSection() == logicalIndex && isHeaderArrowOnTheSide)
|
if (isSortIndicatorShown() && sortIndicatorSection() == logicalIndex && isHeaderArrowOnTheSide)
|
||||||
margin += style()->pixelMetric(QStyle::PM_HeaderMarkSize, 0, this);
|
margin += style()->pixelMetric(QStyle::PM_HeaderMarkSize, 0, this);
|
||||||
|
|
||||||
if (d->textElideMode != Qt::ElideNone)
|
const QVariant variant = d->model->headerData(logicalIndex, d->orientation,
|
||||||
opt.text = opt.fontMetrics.elidedText(opt.text, d->textElideMode , rect.width() - margin);
|
|
||||||
|
|
||||||
QVariant variant = d->model->headerData(logicalIndex, d->orientation,
|
|
||||||
Qt::DecorationRole);
|
Qt::DecorationRole);
|
||||||
opt.icon = qvariant_cast<QIcon>(variant);
|
opt.icon = qvariant_cast<QIcon>(variant);
|
||||||
if (opt.icon.isNull())
|
if (opt.icon.isNull())
|
||||||
opt.icon = qvariant_cast<QPixmap>(variant);
|
opt.icon = qvariant_cast<QPixmap>(variant);
|
||||||
|
if (!opt.icon.isNull()) // see CT_HeaderSection
|
||||||
|
margin += style()->pixelMetric(QStyle::PM_SmallIconSize, 0, this) +
|
||||||
|
style()->pixelMetric(QStyle::PM_HeaderMargin, 0, this);
|
||||||
|
|
||||||
|
if (d->textElideMode != Qt::ElideNone)
|
||||||
|
opt.text = opt.fontMetrics.elidedText(opt.text, d->textElideMode , rect.width() - margin);
|
||||||
|
|
||||||
QVariant foregroundBrush = d->model->headerData(logicalIndex, d->orientation,
|
QVariant foregroundBrush = d->model->headerData(logicalIndex, d->orientation,
|
||||||
Qt::ForegroundRole);
|
Qt::ForegroundRole);
|
||||||
if (foregroundBrush.canConvert<QBrush>())
|
if (foregroundBrush.canConvert<QBrush>())
|
||||||
|
Loading…
Reference in New Issue
Block a user