mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 13:47:26 +02:00
* Fixed TWK-375: TreeItemDelegate's painting for tracks was broken.
This commit is contained in:
@@ -75,9 +75,11 @@ TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
opacity = qMax( (float)0.3, opacity );
|
opacity = qMax( (float)0.3, opacity );
|
||||||
QColor textColor = TomahawkUtils::alphaBlend( option.palette.color( QPalette::Foreground ), option.palette.color( QPalette::Background ), opacity );
|
QColor textColor = TomahawkUtils::alphaBlend( option.palette.color( QPalette::Foreground ), option.palette.color( QPalette::Background ), opacity );
|
||||||
|
|
||||||
if ( const QStyleOptionViewItem *vioption = qstyleoption_cast<const QStyleOptionViewItem *>(&option))
|
|
||||||
{
|
{
|
||||||
QStyleOptionViewItemV4 o( *vioption );
|
QStyleOptionViewItemV4 o = option;
|
||||||
|
initStyleOption( &o, QModelIndex() );
|
||||||
|
|
||||||
|
painter->save();
|
||||||
o.palette.setColor( QPalette::Text, textColor );
|
o.palette.setColor( QPalette::Text, textColor );
|
||||||
|
|
||||||
if ( o.state & QStyle::State_Selected && o.state & QStyle::State_Active )
|
if ( o.state & QStyle::State_Selected && o.state & QStyle::State_Active )
|
||||||
@@ -93,14 +95,15 @@ TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
o.state |= QStyle::State_Selected;
|
o.state |= QStyle::State_Selected;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef Q_OS_MAC
|
int oldX = 0;
|
||||||
int oldX = o.rect.x();
|
if ( m_view->header()->visualIndex( index.column() ) == 0 )
|
||||||
o.rect.setX( 0 );
|
{
|
||||||
#endif
|
oldX = o.rect.x();
|
||||||
|
o.rect.setX( 0 );
|
||||||
|
}
|
||||||
qApp->style()->drawControl( QStyle::CE_ItemViewItem, &o, painter );
|
qApp->style()->drawControl( QStyle::CE_ItemViewItem, &o, painter );
|
||||||
#ifdef Q_OS_MAC
|
if ( oldX > 0 )
|
||||||
o.rect.setX( oldX );
|
o.rect.setX( oldX );
|
||||||
#endif
|
|
||||||
|
|
||||||
{
|
{
|
||||||
QRect r = o.rect.adjusted( 3, 0, 0, 0 );
|
QRect r = o.rect.adjusted( 3, 0, 0, 0 );
|
||||||
@@ -113,14 +116,15 @@ TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
r.adjust( 25, 0, 0, 3 );
|
r.adjust( 25, 0, 0, 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
painter->setPen( o.palette.text().color() );
|
painter->setPen( o.palette.text().color() );
|
||||||
|
|
||||||
QTextOption to( Qt::AlignVCenter );
|
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, to );
|
||||||
}
|
}
|
||||||
|
painter->restore();
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user