void DynamicWidget::steeringChanged() { // When steering changes, toss all the tracks that are upcoming, and re-fetch. // We have to find the currently playing item QModelIndex playing; for ( int i = 0; i < m_view->proxyModel()->rowCount( QModelIndex() ); ++i ) { const QModelIndex cur = m_view->proxyModel()->index( i, 0, QModelIndex() ); PlayableItem* item = m_view->proxyModel()->itemFromIndex( m_view->proxyModel()->mapToSource( cur ) ); if ( item && item->isPlaying() ) { playing = cur; break; } } if ( !playing.isValid() ) return; const int upcoming = m_view->proxyModel()->rowCount( QModelIndex() ) - 1 - playing.row(); tDebug() << "Removing tracks after current in station, found" << upcoming; QModelIndexList toRemove; for ( int i = playing.row() + 1; i < m_view->proxyModel()->rowCount( QModelIndex() ); i++ ) { toRemove << m_view->proxyModel()->index( i, 0, QModelIndex() ); } m_view->proxyModel()->removeIndexes( toRemove ); m_playlist->generator()->fetchNext(); }
void PlaylistItemDelegate::paintDetailed( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const { PlayableItem* item = m_model->itemFromIndex( m_model->mapToSource( index ) ); Q_ASSERT( item ); QTextOption textOption( Qt::AlignVCenter | (Qt::Alignment)index.data( Qt::TextAlignmentRole ).toUInt() ); textOption.setWrapMode( QTextOption::NoWrap ); QStyleOptionViewItemV4 opt = option; prepareStyleOption( &opt, index, item ); opt.text.clear(); qApp->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter ); if ( m_view->hoveredIndex().row() == index.row() && m_view->hoveredIndex().column() == index.column() && !index.data().toString().isEmpty() && ( index.column() == PlayableModel::Artist || index.column() == PlayableModel::Album || index.column() == PlayableModel::Track ) ) { opt.rect.setWidth( opt.rect.width() - opt.rect.height() - 2 ); QRect arrowRect( opt.rect.x() + opt.rect.width(), opt.rect.y() + 1, opt.rect.height() - 2, opt.rect.height() - 2 ); QPixmap infoIcon = TomahawkUtils::defaultPixmap( TomahawkUtils::InfoIcon, TomahawkUtils::Original, arrowRect.size() ); painter->drawPixmap( arrowRect, infoIcon ); } painter->save(); if ( index.column() == PlayableModel::Score ) { QColor barColor( 167, 183, 211 ); // This matches the sidebar (sourcetreeview.cpp:672) if ( opt.state & QStyle::State_Selected ) painter->setPen( opt.palette.brightText().color() ); else painter->setPen( barColor ); QRect r = opt.rect.adjusted( 3, 3, -6, -4 ); painter->drawRect( r ); QRect fillR = r; int fillerWidth = (int)( index.data().toFloat() * (float)fillR.width() ); fillR.adjust( 0, 0, -( fillR.width() - fillerWidth ), 0 ); if ( opt.state & QStyle::State_Selected ) painter->setBrush( opt.palette.brightText().color() ); else painter->setBrush( barColor ); painter->drawRect( fillR ); } else if ( item->isPlaying() ) { QRect r = opt.rect.adjusted( 3, 0, 0, 0 ); // Paint Now Playing Speaker Icon if ( m_view->header()->visualIndex( index.column() ) == 0 ) { const int pixMargin = 1; const int pixHeight = r.height() - pixMargin * 2; QRect npr = r.adjusted( pixMargin, pixMargin, pixHeight - r.width() + pixMargin, -pixMargin ); painter->drawPixmap( npr, TomahawkUtils::defaultPixmap( TomahawkUtils::NowPlayingSpeaker, TomahawkUtils::Original, npr.size() ) ); r.adjust( pixHeight + 6, 0, 0, 0 ); } painter->setPen( opt.palette.text().color() ); QString text = painter->fontMetrics().elidedText( index.data().toString(), Qt::ElideRight, r.width() - 3 ); painter->drawText( r.adjusted( 0, 1, 0, 0 ), text, textOption ); } else { painter->setPen( opt.palette.text().color() ); QString text = painter->fontMetrics().elidedText( index.data().toString(), Qt::ElideRight, opt.rect.width() - 6 ); painter->drawText( opt.rect.adjusted( 3, 1, -3, 0 ), text, textOption ); } painter->restore(); }
void PlaylistItemDelegate::paintShort( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index, bool useAvatars ) const { PlayableItem* item = m_model->itemFromIndex( m_model->mapToSource( index ) ); Q_ASSERT( item ); QStyleOptionViewItemV4 opt = option; prepareStyleOption( &opt, index, item ); opt.text.clear(); qApp->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter ); if ( m_view->header()->visualIndex( index.column() ) > 0 ) return; const query_ptr q = item->query()->displayQuery(); QString artist = q->artist(); QString track = q->track(); QPixmap pixmap; QString upperText, lowerText; source_ptr source = item->query()->playedBy().first; if ( source.isNull() ) { upperText = track; lowerText = artist; } else { upperText = QString( "%1 - %2" ).arg( artist ).arg( track ); QString playtime = TomahawkUtils::ageToString( QDateTime::fromTime_t( item->query()->playedBy().second ), true ); if ( source == SourceList::instance()->getLocal() ) lowerText = QString( tr( "played %1 by you" ) ).arg( playtime ); else lowerText = QString( tr( "played %1 by %2" ) ).arg( playtime ).arg( source->friendlyName() ); } painter->save(); { QRect r = opt.rect.adjusted( 3, 6, 0, -6 ); // Paint Now Playing Speaker Icon if ( item->isPlaying() ) { const int pixMargin = 2; const int pixHeight = r.height() - pixMargin * 2; QRect npr = r.adjusted( pixMargin, pixMargin + 1, pixHeight - r.width() + pixMargin, -pixMargin + 1 ); painter->drawPixmap( npr, TomahawkUtils::defaultPixmap( TomahawkUtils::NowPlayingSpeaker, TomahawkUtils::Original, npr.size() ) ); r.adjust( pixHeight + 8, 0, 0, 0 ); } painter->setPen( opt.palette.text().color() ); QRect ir = r.adjusted( 4, 0, -option.rect.width() + option.rect.height() - 8 + r.left(), 0 ); if ( useAvatars ) { if ( !source.isNull() ) pixmap = source->avatar( TomahawkUtils::RoundedCorners, ir.size() ); } else pixmap = item->query()->cover( ir.size(), false ); if ( pixmap.isNull() ) { if ( !useAvatars ) pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultTrackImage, TomahawkUtils::Original, ir.size() ); else pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultSourceAvatar, TomahawkUtils::RoundedCorners, ir.size() ); } painter->drawPixmap( ir, pixmap ); QFont boldFont = opt.font; boldFont.setBold( true ); r.adjust( ir.width() + 12, 0, -12, 0 ); painter->setFont( boldFont ); QString text = painter->fontMetrics().elidedText( upperText, Qt::ElideRight, r.width() ); painter->drawText( r.adjusted( 0, 1, 0, 0 ), text, m_topOption ); painter->setFont( opt.font ); if ( !( option.state & QStyle::State_Selected || item->isPlaying() ) ) painter->setPen( Qt::gray ); text = painter->fontMetrics().elidedText( lowerText, Qt::ElideRight, r.width() ); painter->drawText( r.adjusted( 0, 1, 0, 0 ), text, m_bottomOption ); } painter->restore(); }
void TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const { PlayableItem* item = m_model->sourceModel()->itemFromIndex( m_model->mapToSource( index ) ); if ( !item ) return; QString text; if ( !item->artist().isNull() ) { text = item->artist()->name(); } else if ( !item->album().isNull() ) { text = item->album()->name(); } else if ( !item->result().isNull() || !item->query().isNull() ) { float opacity = item->result().isNull() ? 0.0 : item->result()->score(); opacity = qMax( (float)0.3, opacity ); QColor textColor = TomahawkUtils::alphaBlend( option.palette.color( QPalette::Foreground ), option.palette.color( QPalette::Background ), opacity ); { QStyleOptionViewItemV4 o = option; initStyleOption( &o, QModelIndex() ); painter->save(); o.palette.setColor( QPalette::Text, textColor ); if ( o.state & QStyle::State_Selected && o.state & QStyle::State_Active ) { o.palette.setColor( QPalette::Text, o.palette.color( QPalette::HighlightedText ) ); } if ( item->isPlaying() ) { o.palette.setColor( QPalette::Highlight, o.palette.color( QPalette::Mid ) ); if ( o.state & QStyle::State_Selected ) o.palette.setColor( QPalette::Text, textColor ); o.state |= QStyle::State_Selected; } int oldX = 0; if ( m_view->header()->visualIndex( index.column() ) == 0 ) { oldX = o.rect.x(); o.rect.setX( 0 ); } qApp->style()->drawControl( QStyle::CE_ItemViewItem, &o, painter ); if ( oldX > 0 ) o.rect.setX( oldX ); { QRect r = o.rect.adjusted( 3, 0, 0, 0 ); // Paint Now Playing Speaker Icon if ( item->isPlaying() && m_view->header()->visualIndex( index.column() ) == 0 ) { r.adjust( 0, 0, 0, -3 ); QRect npr = r.adjusted( 3, 1, 18 - r.width(), 1 ); painter->drawPixmap( npr, TomahawkUtils::defaultPixmap( TomahawkUtils::NowPlayingSpeaker, TomahawkUtils::Original, npr.size() ) ); r.adjust( 25, 0, 0, 3 ); } 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->restore(); } return; } else return; if ( text.trimmed().isEmpty() ) text = tr( "Unknown" ); QStyleOptionViewItemV4 opt = option; initStyleOption( &opt, QModelIndex() ); qApp->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter ); if ( option.state & QStyle::State_Selected ) { opt.palette.setColor( QPalette::Text, opt.palette.color( QPalette::HighlightedText ) ); } if ( index.column() > 0 ) return; painter->save(); painter->setRenderHint( QPainter::Antialiasing ); painter->setPen( opt.palette.color( QPalette::Text ) ); QRect r = option.rect.adjusted( 4, 4, -option.rect.width() + option.rect.height() - 4, -4 ); // painter->drawPixmap( r, QPixmap( RESPATH "images/cover-shadow.png" ) ); if ( !m_pixmaps.contains( index ) ) { if ( !item->album().isNull() ) { m_pixmaps.insert( index, QSharedPointer< Tomahawk::PixmapDelegateFader >( new Tomahawk::PixmapDelegateFader( item->album(), r.size(), TomahawkUtils::ScaledCover, false ) ) ); _detail::Closure* closure = NewClosure( m_pixmaps[ index ], SIGNAL( repaintRequest() ), const_cast<TreeItemDelegate*>(this), SLOT( doUpdateIndex( const QPersistentModelIndex& ) ), QPersistentModelIndex( index ) ); closure->setAutoDelete( false ); } else if ( !item->artist().isNull() )
void PlaylistChartItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const { PlayableItem* item = m_model->itemFromIndex( m_model->mapToSource( index ) ); Q_ASSERT( item ); QStyleOptionViewItemV4 opt = option; prepareStyleOption( &opt, index, item ); opt.text.clear(); qApp->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter ); if ( m_view->header()->visualIndex( index.column() ) > 0 ) return; const query_ptr q = item->query()->displayQuery(); unsigned int duration = q->duration(); QString artist = q->artist(); QString track = q->track(); QPixmap avatar; QString upperText, lowerText; painter->save(); { QRect r = opt.rect.adjusted( 4, 6, 0, -6 ); // Paint Now Playing Speaker Icon if ( item->isPlaying() ) { const int pixMargin = 4; const int pixHeight = r.height() - pixMargin * 2; QRect npr = r.adjusted( pixMargin, pixMargin + 1, pixHeight - r.width() + pixMargin, -pixMargin + 1 ); painter->drawPixmap( npr, TomahawkUtils::defaultPixmap( TomahawkUtils::NowPlayingSpeaker, TomahawkUtils::Original, npr.size() ) ); r.adjust( pixHeight + 8, 0, 0, 0 ); } QFont figureFont = opt.font; figureFont.setPointSize( TomahawkUtils::defaultFontSize() + 6 ); figureFont.setWeight( 99 ); QFont boldFont = opt.font; boldFont.setPointSize( TomahawkUtils::defaultFontSize() + 1 ); boldFont.setWeight( 99 ); QFont smallBoldFont = opt.font; smallBoldFont.setPointSize( TomahawkUtils::defaultFontSize() ); smallBoldFont.setWeight( 60 ); QFont durationFont = opt.font; durationFont.setPointSize( TomahawkUtils::defaultFontSize() ); durationFont.setWeight( 80 ); QFontMetrics durationFontMetrics( durationFont ); if ( index.row() == 0 ) { figureFont.setPointSize( TomahawkUtils::defaultFontSize() + 33 ); boldFont.setPointSize( TomahawkUtils::defaultFontSize() + 13 ); smallBoldFont.setPointSize( TomahawkUtils::defaultFontSize() + 9 ); } else if ( index.row() == 1 ) { figureFont.setPointSize( TomahawkUtils::defaultFontSize() + 17 ); boldFont.setPointSize( TomahawkUtils::defaultFontSize() + 9 ); smallBoldFont.setPointSize( TomahawkUtils::defaultFontSize() + 4 ); } else if ( index.row() == 2 ) { figureFont.setPointSize( TomahawkUtils::defaultFontSize() + 9 ); boldFont.setPointSize( TomahawkUtils::defaultFontSize() + 4 ); smallBoldFont.setPointSize( TomahawkUtils::defaultFontSize() + 2 ); } else if ( index.row() >= 10 ) { boldFont.setPointSize( TomahawkUtils::defaultFontSize() ); smallBoldFont.setPointSize( TomahawkUtils::defaultFontSize() - 1 ); } QRect figureRect = r.adjusted( 0, 0, -option.rect.width() + 60 - 6 + r.left(), 0 ); painter->setFont( figureFont ); painter->setPen( option.palette.text().color().lighter( 450 ) ); painter->drawText( figureRect, QString::number( index.row() + 1 ), m_centerOption ); painter->setPen( opt.palette.text().color() ); QRect pixmapRect = r.adjusted( figureRect.width() + 6, 0, -option.rect.width() + figureRect.width() + option.rect.height() - 6 + r.left(), 0 ); if ( !m_pixmaps.contains( index ) ) { m_pixmaps.insert( index, QSharedPointer< Tomahawk::PixmapDelegateFader >( new Tomahawk::PixmapDelegateFader( item->query(), pixmapRect.size(), TomahawkUtils::Original, false ) ) ); _detail::Closure* closure = NewClosure( m_pixmaps[ index ], SIGNAL( repaintRequest() ), const_cast<PlaylistChartItemDelegate*>(this), SLOT( doUpdateIndex( const QPersistentModelIndex& ) ), QPersistentModelIndex( index ) ); closure->setAutoDelete( false ); } const QPixmap pixmap = m_pixmaps[ index ]->currentPixmap(); painter->drawPixmap( pixmapRect, pixmap ); r.adjust( pixmapRect.width() + figureRect.width() + 18, 1, -28, 0 ); QRect leftRect = r.adjusted( 0, 0, -durationFontMetrics.width( TomahawkUtils::timeToString( duration ) ) - 8, 0 ); painter->setFont( boldFont ); QString text = painter->fontMetrics().elidedText( track, Qt::ElideRight, leftRect.width() ); painter->drawText( leftRect, text, m_topOption ); painter->setFont( smallBoldFont ); text = painter->fontMetrics().elidedText( artist, Qt::ElideRight, leftRect.width() ); painter->drawText( index.row() >= 10 ? leftRect : leftRect.adjusted( 0, painter->fontMetrics().height() + 6, 0, 0 ), text, index.row() >= 10 ? m_bottomOption : m_topOption ); if ( duration > 0 ) { painter->setFont( durationFont ); QRect rightRect = r.adjusted( r.width() - durationFontMetrics.width( TomahawkUtils::timeToString( duration ) ), 0, 0, 0 ); text = painter->fontMetrics().elidedText( TomahawkUtils::timeToString( duration ), Qt::ElideRight, rightRect.width() ); painter->drawText( rightRect, text, m_centerRightOption ); } }
void PlaylistItemDelegate::paintShort( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const { PlayableItem* item = m_model->itemFromIndex( m_model->mapToSource( index ) ); Q_ASSERT( item ); QStyleOptionViewItemV4 opt = option; prepareStyleOption( &opt, index, item ); opt.text.clear(); qApp->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter ); if ( m_view->header()->visualIndex( index.column() ) > 0 ) return; const track_ptr track = item->query()->track(); QPixmap pixmap; QString upperLeftText, upperRightText, lowerText; if ( !item->playbackLog().source ) { upperLeftText = track->track(); lowerText = track->artist(); } else { upperLeftText = track->track(); upperRightText = QString( " - %2" ).arg( track->artist() ); QString playtime = TomahawkUtils::ageToString( QDateTime::fromTime_t( item->playbackLog().timestamp ), true ); if ( item->playbackLog().source->isLocal() ) lowerText = QString( tr( "played %1 by you" ) ).arg( playtime ); else lowerText = QString( tr( "played %1 by %2" ) ).arg( playtime ).arg( item->playbackLog().source->friendlyName() ); } painter->save(); { QRect r = opt.rect.adjusted( 3, 6, 0, -6 ); // Paint Now Playing Speaker Icon if ( item->isPlaying() ) { const int pixMargin = 2; const int pixHeight = r.height() - pixMargin * 2; const QRect npr = r.adjusted( pixMargin, pixMargin + 1, pixHeight - r.width() + pixMargin, -pixMargin + 1 ); painter->drawPixmap( npr, TomahawkUtils::defaultPixmap( TomahawkUtils::NowPlayingSpeaker, TomahawkUtils::Original, npr.size() ) ); r.adjust( pixHeight + 8, 0, 0, 0 ); } painter->setPen( opt.palette.text().color() ); QRect ir = r.adjusted( 4, 0, -option.rect.width() + option.rect.height() - 8 + r.left(), 0 ); pixmap = item->query()->track()->cover( ir.size(), true ); if ( pixmap.isNull() ) { pixmap = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultTrackImage, TomahawkUtils::RoundedCorners, ir.size() ); } painter->drawPixmap( ir, pixmap ); r.adjust( ir.width() + 12, 0, -12, 0 ); painter->setFont( m_boldFont ); QFontMetrics fm = painter->fontMetrics(); QString elided = fm.elidedText( upperLeftText, Qt::ElideRight, r.width() ); if ( fm.width( elided ) != fm.width( upperLeftText ) ) //if we had to elide the track title { //we just paint that and we're done painter->drawText( r.adjusted( 0, 1, 0, 0 ), elided, m_topOption ); } else { int remainingSpace = r.width() - fm.width( upperLeftText ); 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() ) painter->setPen( opt.palette.text().color().lighter( 220 ) ); painter->drawText( r.adjusted( r.width() - remainingSpace, 1, 0, 0 ), elided, m_topOption ); } painter->setFont( opt.font ); if ( !( option.state & QStyle::State_Selected || item->isPlaying() ) ) painter->setPen( Qt::gray ); elided = painter->fontMetrics().elidedText( lowerText, Qt::ElideRight, r.width() ); painter->drawText( r.adjusted( 0, 1, 0, 0 ), elided, m_bottomOption ); } painter->restore(); }
void ColumnItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const { PlayableItem* item = m_model->sourceModel()->itemFromIndex( m_model->mapToSource( index ) ); if ( !item ) return; QTextOption textOption( Qt::AlignVCenter | (Qt::Alignment)index.data( Qt::TextAlignmentRole ).toUInt() ); textOption.setWrapMode( QTextOption::NoWrap ); QString text; if ( !item->artist().isNull() ) { text = item->artist()->name(); } else if ( !item->album().isNull() ) { text = item->album()->name(); } else if ( !item->result().isNull() || !item->query().isNull() ) { float opacity = item->result() && item->result()->isOnline() ? 1.0 : 0.0; opacity = qMax( (float)0.3, opacity ); QColor textColor = TomahawkUtils::alphaBlend( option.palette.color( QPalette::Foreground ), option.palette.color( QPalette::Background ), opacity ); { QStyleOptionViewItemV4 o = option; initStyleOption( &o, QModelIndex() ); painter->save(); o.palette.setColor( QPalette::Text, textColor ); if ( m_view->currentIndex() == index ) o.state |= QStyle::State_Selected; else o.state &= ~QStyle::State_Selected; if ( o.state & QStyle::State_Selected && o.state & QStyle::State_Active ) { o.palette.setColor( QPalette::Text, o.palette.color( QPalette::HighlightedText ) ); } if ( item->isPlaying() ) { textColor = TomahawkStyle::NOW_PLAYING_ITEM_TEXT; o.palette.setColor( QPalette::Highlight, TomahawkStyle::NOW_PLAYING_ITEM ); o.palette.setColor( QPalette::Text, TomahawkStyle::NOW_PLAYING_ITEM_TEXT ); o.state |= QStyle::State_Selected; } int oldX = 0; // if ( m_view->header()->visualIndex( index.column() ) == 0 ) { oldX = o.rect.x(); o.rect.setX( 0 ); } qApp->style()->drawControl( QStyle::CE_ItemViewItem, &o, painter ); if ( oldX > 0 ) o.rect.setX( oldX ); /* if ( m_hoveringOver == index && !index.data().toString().isEmpty() && index.column() == 0 ) { o.rect.setWidth( o.rect.width() - o.rect.height() ); QRect arrowRect( o.rect.x() + o.rect.width(), o.rect.y() + 1, o.rect.height() - 2, o.rect.height() - 2 ); QPixmap infoIcon = TomahawkUtils::defaultPixmap( TomahawkUtils::InfoIcon, TomahawkUtils::Original, arrowRect.size() ); painter->drawPixmap( arrowRect, infoIcon ); m_infoButtonRects[ index ] = arrowRect; }*/ { QRect r = o.rect.adjusted( 3, 0, 0, 0 ); // Paint Now Playing Speaker Icon if ( item->isPlaying() ) { const int pixMargin = 1; const int pixHeight = r.height() - pixMargin * 2; QRect npr = r.adjusted( pixMargin, pixMargin, pixHeight - r.width() + pixMargin, -pixMargin ); painter->drawPixmap( npr, TomahawkUtils::defaultPixmap( TomahawkUtils::NowPlayingSpeaker, TomahawkUtils::Original, npr.size() ) ); r.adjust( pixHeight + 6, 0, 0, 0 ); } painter->setPen( o.palette.text().color() ); QString text = index.data().toString(); if ( item->query()->track()->albumpos() > 0 ) { text = QString( "%1. %2" ) .arg( index.data( PlayableModel::AlbumPosRole ).toString() ) .arg( index.data().toString() ); } text = painter->fontMetrics().elidedText( text, Qt::ElideRight, r.width() - 3 ); painter->drawText( r.adjusted( 0, 1, 0, 0 ), text, textOption ); } painter->restore(); } return; } else return; if ( text.trimmed().isEmpty() ) text = tr( "Unknown" ); QStyleOptionViewItemV4 opt = option; initStyleOption( &opt, QModelIndex() ); const QModelIndex curIndex = m_view->currentIndex(); if ( curIndex == index || curIndex.parent() == index || curIndex.parent().parent() == index ) opt.state |= QStyle::State_Selected; else opt.state &= ~QStyle::State_Selected; qApp->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter ); if ( opt.state & QStyle::State_Selected ) { opt.palette.setColor( QPalette::Text, opt.palette.color( QPalette::HighlightedText ) ); } QRect arrowRect( m_view->viewport()->width() - option.rect.height(), option.rect.y() + 1, option.rect.height() - 2, option.rect.height() - 2 ); if ( m_hoveringOver.row() == index.row() && m_hoveringOver.parent() == index.parent() ) { QPixmap infoIcon = TomahawkUtils::defaultPixmap( TomahawkUtils::InfoIcon, TomahawkUtils::Original, arrowRect.size() ); painter->drawPixmap( arrowRect, infoIcon ); m_infoButtonRects[ index ] = arrowRect; } if ( index.column() > 0 ) return; painter->save(); painter->setRenderHint( QPainter::TextAntialiasing ); painter->setPen( opt.palette.color( QPalette::Text ) ); QRect r = option.rect.adjusted( 8, 2, -option.rect.width() + option.rect.height() + 4, -2 ); // painter->drawPixmap( r, QPixmap( RESPATH "images/cover-shadow.png" ) ); if ( !m_pixmaps.contains( index ) ) { if ( !item->album().isNull() ) { m_pixmaps.insert( index, QSharedPointer< Tomahawk::PixmapDelegateFader >( new Tomahawk::PixmapDelegateFader( item->album(), r.size(), TomahawkUtils::Original, false ) ) ); _detail::Closure* closure = NewClosure( m_pixmaps[ index ], SIGNAL( repaintRequest() ), const_cast<ColumnItemDelegate*>(this), SLOT( doUpdateIndex( const QPersistentModelIndex& ) ), QPersistentModelIndex( index ) ); closure->setAutoDelete( false ); } else if ( !item->artist().isNull() )