mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
* Don't even try to paint invalid GridItems.
This commit is contained in:
@@ -82,16 +82,13 @@ void
|
|||||||
GridItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
GridItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index ) const
|
||||||
{
|
{
|
||||||
PlayableItem* item = m_model->sourceModel()->itemFromIndex( m_model->mapToSource( index ) );
|
PlayableItem* item = m_model->sourceModel()->itemFromIndex( m_model->mapToSource( index ) );
|
||||||
if ( !item )
|
if ( !item || !index.isValid() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
QStyleOptionViewItemV4 opt = option;
|
QStyleOptionViewItemV4 opt = option;
|
||||||
initStyleOption( &opt, QModelIndex() );
|
initStyleOption( &opt, QModelIndex() );
|
||||||
qApp->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter );
|
qApp->style()->drawControl( QStyle::CE_ItemViewItem, &opt, painter );
|
||||||
|
|
||||||
painter->save();
|
|
||||||
painter->setRenderHint( QPainter::Antialiasing );
|
|
||||||
|
|
||||||
QRect r = option.rect;
|
QRect r = option.rect;
|
||||||
QString top, bottom;
|
QString top, bottom;
|
||||||
if ( !item->album().isNull() )
|
if ( !item->album().isNull() )
|
||||||
@@ -105,11 +102,18 @@ GridItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
|
|||||||
{
|
{
|
||||||
top = item->artist()->name();
|
top = item->artist()->name();
|
||||||
}
|
}
|
||||||
else
|
else if ( !item->query().isNull() )
|
||||||
{
|
{
|
||||||
top = item->query()->track();
|
top = item->query()->track();
|
||||||
bottom = item->query()->artist();
|
bottom = item->query()->artist();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
painter->save();
|
||||||
|
painter->setRenderHint( QPainter::Antialiasing );
|
||||||
|
|
||||||
if ( !m_covers.contains( index ) )
|
if ( !m_covers.contains( index ) )
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user