1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-20 07:49:42 +01:00

* Fixed showing offline results in playlists.

This commit is contained in:
Christian Muehlhaeuser 2014-10-05 08:07:24 +02:00
parent ae16fcda43
commit 28c8251efe
2 changed files with 8 additions and 6 deletions

View File

@ -225,7 +225,7 @@ PlaylistItemDelegate::paintShort( QPainter* painter, const QStyleOptionViewItem&
elided = fm.elidedText( upperRightText, Qt::ElideRight, remainingSpace );
painter->drawText( r.adjusted( 0, 1, -remainingSpace, 0 ), upperLeftText, m_topOption );
if ( item->query()->numResults() > 0 && item->query()->results().first()->isOnline() )
if ( item->query()->numResults( true ) > 0 )
painter->setPen( opt.palette.text().color().lighter( 220 ) );
painter->drawText( r.adjusted( r.width() - remainingSpace, 1, 0, 0 ), elided, m_topOption );
@ -477,6 +477,7 @@ PlaylistItemDelegate::drawAvatarsForBox( QPainter* painter,
painter->restore();
}
void
PlaylistItemDelegate::drawRichText( QPainter* painter, const QStyleOptionViewItem& option, const QRect& rect, int flags, QTextDocument& text ) const
{
@ -507,7 +508,7 @@ PlaylistItemDelegate::drawSourceIcon( QPainter* painter, const QRect& rect, Play
{
const int sourceIconSize = rect.height() * height;
QRect resultRect = rect.adjusted( 0, 0, -( sourceIconSize + 8 ), 0 );
if ( item->query()->numResults() == 0 || !item->query()->results().first()->isOnline() )
if ( item->query()->numResults( true ) == 0 )
return resultRect;
const QPixmap sourceIcon = item->query()->results().first()->sourceIcon( TomahawkUtils::RoundedCorners, QSize( sourceIconSize, sourceIconSize ) );
@ -616,9 +617,10 @@ PlaylistItemDelegate::drawTrack( QPainter* painter, const QStyleOptionViewItem&
artistRect.setWidth( artistRect.width() - stateWidth );
}
const bool hasOnlineResults = ( item->query()->numResults( true ) > 0 );
// draw title
qreal opacityCo = 1.0;
if ( item->query()->numResults() == 0 )
if ( !hasOnlineResults )
opacityCo = 0.5;
painter->setOpacity( 1.0 * opacityCo );
@ -642,8 +644,8 @@ PlaylistItemDelegate::drawTrack( QPainter* painter, const QStyleOptionViewItem&
m_artistNameRects[ index ] = painter->fontMetrics().boundingRect( artistRect, Qt::AlignLeft | Qt::AlignVCenter, text );
painter->restore();
// draw number
if ( ( option.state & QStyle::State_Selected || hoveringOver() == index ) && item->query()->numResults() > 0 )
// draw number or source icon
if ( ( option.state & QStyle::State_Selected || hoveringOver() == index ) && hasOnlineResults )
{
const int iconHeight = numberRect.size().height() / 2;
const QRect sourceIconRect( numberRect.x(), numberRect.y() + ( numberRect.size().height() - iconHeight ) / 2, iconHeight, iconHeight );

View File

@ -280,7 +280,7 @@ TrackDetailView::onResultsChanged()
}
}
if ( m_query && m_query->numResults() > 1 )
if ( m_query && m_query->numResults( true ) > 1 )
{
m_resultsBoxLabel->show();
m_resultsBox->show();