mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
* Fixed text-alignment in TreeItemDelegate.
This commit is contained in:
@@ -61,6 +61,9 @@ TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
if ( !item )
|
if ( !item )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
QTextOption textOption( Qt::AlignVCenter | (Qt::Alignment)index.data( Qt::TextAlignmentRole ).toUInt() );
|
||||||
|
textOption.setWrapMode( QTextOption::NoWrap );
|
||||||
|
|
||||||
QString text;
|
QString text;
|
||||||
if ( !item->artist().isNull() )
|
if ( !item->artist().isNull() )
|
||||||
{
|
{
|
||||||
@@ -120,9 +123,8 @@ TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
|
|
||||||
painter->setPen( o.palette.text().color() );
|
painter->setPen( o.palette.text().color() );
|
||||||
|
|
||||||
QTextOption to( Qt::AlignVCenter );
|
|
||||||
QString text = painter->fontMetrics().elidedText( index.data().toString(), Qt::ElideRight, r.width() - 3 );
|
QString text = painter->fontMetrics().elidedText( index.data().toString(), Qt::ElideRight, r.width() - 3 );
|
||||||
painter->drawText( r.adjusted( 0, 1, 0, 0 ), text, to );
|
painter->drawText( r.adjusted( 0, 1, 0, 0 ), text, textOption );
|
||||||
}
|
}
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
@@ -174,12 +176,9 @@ TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
|
|
||||||
painter->drawPixmap( r, cover );
|
painter->drawPixmap( r, cover );
|
||||||
|
|
||||||
QTextOption to;
|
|
||||||
to.setAlignment( Qt::AlignVCenter );
|
|
||||||
|
|
||||||
r = option.rect.adjusted( option.rect.height(), 6, -4, -option.rect.height() + 22 );
|
r = option.rect.adjusted( option.rect.height(), 6, -4, -option.rect.height() + 22 );
|
||||||
text = painter->fontMetrics().elidedText( text, Qt::ElideRight, r.width() );
|
text = painter->fontMetrics().elidedText( text, Qt::ElideRight, r.width() );
|
||||||
painter->drawText( r, text, to );
|
painter->drawText( r, text, textOption );
|
||||||
|
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user