+ QModelIndex parent = index.parent();
+ QModelIndex i;
+
+ QString title = getMeta( index, COLUMN_TITLE );
+ QString duration = getMeta( index, COLUMN_DURATION );
+ if( !duration.isEmpty() ) title += QString(" [%1]").arg( duration );
+
+ QString artist = getMeta( index, COLUMN_ARTIST );
+ QString album = getMeta( index, COLUMN_ALBUM );
+ QString trackNum = getMeta( index, COLUMN_TRACK_NUMBER );
+ QString artistAlbum = artist
+ + ( artist.isEmpty() ? QString() : QString( ": " ) )
+ + album
+ + ( album.isEmpty() || trackNum.isEmpty() ?
+ QString() : QString( " [#%1]" ).arg( trackNum ) );
+
+ QPixmap artPix = getArtPixmap( index, QSize( LISTVIEW_ART_SIZE, LISTVIEW_ART_SIZE ) );
+
+ //Draw selection rectangle
+ QApplication::style()->drawPrimitive( QStyle::PE_PanelItemViewItem, &option, painter );
+
+ //Paint background if item is playing
+ if( index.data( PLModel::IsCurrentRole ).toBool() )
+ paintPlayingItemBg( painter, option );
+
+ QRect artRect( artPix.rect() );
+ artRect.moveCenter( QPoint( artRect.center().x() + 3,
+ option.rect.center().y() ) );
+ //Draw album art
+ painter->drawPixmap( artRect, artPix );
+
+ //Start drawing text
+ painter->save();
+
+ if( option.state & QStyle::State_Selected )
+ painter->setPen( option.palette.color( QPalette::HighlightedText ) );
+
+ QTextOption textOpt( Qt::AlignVCenter | Qt::AlignLeft );
+ textOpt.setWrapMode( QTextOption::NoWrap );
+
+ QFont f( index.data( Qt::FontRole ).value<QFont>() );
+
+ //Draw title info
+ f.setItalic( true );
+ painter->setFont( f );
+ QFontMetrics fm( painter->fontMetrics() );
+
+ QRect textRect = option.rect.adjusted( LISTVIEW_ART_SIZE + 10, 0, -10, 0 );
+ if( !artistAlbum.isEmpty() )
+ {
+ textRect.setHeight( fm.height() );
+ textRect.moveBottom( option.rect.center().y() - 1 );
+ }
+
+ painter->drawText( textRect,
+ fm.elidedText( title, Qt::ElideRight, textRect.width() ),
+ textOpt );
+
+ // Draw artist and album info
+ if( !artistAlbum.isEmpty() )
+ {
+ f.setItalic( false );
+ painter->setFont( f );
+ fm = painter->fontMetrics();
+
+ textRect.moveTop( textRect.bottom() + 2 );
+
+ painter->drawText( textRect,
+ fm.elidedText( artistAlbum, Qt::ElideRight, textRect.width() ),
+ textOpt );
+ }
+
+ painter->restore();