From 5e0748a1f9ce0fc66b68362df55c6e19a2fae44e Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sat, 16 Jun 2012 10:48:10 +0200 Subject: [PATCH] * Fixed text-alignment in TreeItemDelegate. --- src/libtomahawk/playlist/TreeItemDelegate.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/libtomahawk/playlist/TreeItemDelegate.cpp b/src/libtomahawk/playlist/TreeItemDelegate.cpp index c22847709..b171ed49e 100644 --- a/src/libtomahawk/playlist/TreeItemDelegate.cpp +++ b/src/libtomahawk/playlist/TreeItemDelegate.cpp @@ -61,6 +61,9 @@ TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, if ( !item ) return; + QTextOption textOption( Qt::AlignVCenter | (Qt::Alignment)index.data( Qt::TextAlignmentRole ).toUInt() ); + textOption.setWrapMode( QTextOption::NoWrap ); + QString text; if ( !item->artist().isNull() ) { @@ -120,9 +123,8 @@ TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, painter->setPen( o.palette.text().color() ); - QTextOption to( Qt::AlignVCenter ); 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(); } @@ -174,12 +176,9 @@ TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, painter->drawPixmap( r, cover ); - QTextOption to; - to.setAlignment( Qt::AlignVCenter ); - r = option.rect.adjusted( option.rect.height(), 6, -4, -option.rect.height() + 22 ); text = painter->fontMetrics().elidedText( text, Qt::ElideRight, r.width() ); - painter->drawText( r, text, to ); + painter->drawText( r, text, textOption ); painter->restore(); }