1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-22 13:43:11 +02:00

Don't load covers till scrolling stops in the treeview

This commit is contained in:
Leo Franchi
2012-04-05 22:37:15 -04:00
parent f1aa7b6d28
commit 30e239c311
3 changed files with 8 additions and 8 deletions

View File

@@ -157,13 +157,13 @@ TreeItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
{ {
if ( !item->album().isNull() ) if ( !item->album().isNull() )
{ {
m_pixmaps.insert( index, QSharedPointer< Tomahawk::PixmapDelegateFader >( new Tomahawk::PixmapDelegateFader( item->album(), r.size() ) ) ); m_pixmaps.insert( index, QSharedPointer< Tomahawk::PixmapDelegateFader >( new Tomahawk::PixmapDelegateFader( item->album(), r.size(), false ) ) );
_detail::Closure* closure = NewClosure( m_pixmaps[ index ], SIGNAL( repaintRequest() ), const_cast<TreeItemDelegate*>(this), SLOT( doUpdateIndex( const QPersistentModelIndex& ) ), QPersistentModelIndex( index ) ); _detail::Closure* closure = NewClosure( m_pixmaps[ index ], SIGNAL( repaintRequest() ), const_cast<TreeItemDelegate*>(this), SLOT( doUpdateIndex( const QPersistentModelIndex& ) ), QPersistentModelIndex( index ) );
closure->setAutoDelete( false ); closure->setAutoDelete( false );
} }
else if ( !item->artist().isNull() ) else if ( !item->artist().isNull() )
{ {
m_pixmaps.insert( index, QSharedPointer< Tomahawk::PixmapDelegateFader >( new Tomahawk::PixmapDelegateFader( item->artist(), r.size() ) ) ); m_pixmaps.insert( index, QSharedPointer< Tomahawk::PixmapDelegateFader >( new Tomahawk::PixmapDelegateFader( item->artist(), r.size(), false ) ) );
_detail::Closure* closure = NewClosure( m_pixmaps[ index ], SIGNAL( repaintRequest() ), const_cast<TreeItemDelegate*>(this), SLOT( doUpdateIndex( const QPersistentModelIndex& ) ), QPersistentModelIndex( index ) ); _detail::Closure* closure = NewClosure( m_pixmaps[ index ], SIGNAL( repaintRequest() ), const_cast<TreeItemDelegate*>(this), SLOT( doUpdateIndex( const QPersistentModelIndex& ) ), QPersistentModelIndex( index ) );
closure->setAutoDelete( false ); closure->setAutoDelete( false );
} }

View File

@@ -26,27 +26,27 @@ using namespace Tomahawk;
#define COVER_FADEIN 1000 #define COVER_FADEIN 1000
PixmapDelegateFader::PixmapDelegateFader( const artist_ptr& artist, const QSize& size ) PixmapDelegateFader::PixmapDelegateFader( const artist_ptr& artist, const QSize& size, bool forceLoad )
: m_artist( artist ) : m_artist( artist )
, m_size( size ) , m_size( size )
{ {
if ( !m_artist.isNull() ) if ( !m_artist.isNull() )
{ {
connect( m_artist.data(), SIGNAL( coverChanged() ), this, SLOT( artistChanged() ) ); connect( m_artist.data(), SIGNAL( coverChanged() ), this, SLOT( artistChanged() ) );
m_currentReference = m_artist->cover( size ); m_currentReference = m_artist->cover( size, forceLoad );
} }
init(); init();
} }
PixmapDelegateFader::PixmapDelegateFader( const album_ptr& album, const QSize& size ) PixmapDelegateFader::PixmapDelegateFader( const album_ptr& album, const QSize& size, bool forceLoad )
: m_album( album ) : m_album( album )
, m_size( size ) , m_size( size )
{ {
if ( !m_album.isNull() ) if ( !m_album.isNull() )
{ {
connect( m_album.data(), SIGNAL( coverChanged() ), this, SLOT( albumChanged() ) ); connect( m_album.data(), SIGNAL( coverChanged() ), this, SLOT( albumChanged() ) );
m_currentReference = m_album->cover( size ); m_currentReference = m_album->cover( size, forceLoad );
} }
init(); init();

View File

@@ -39,8 +39,8 @@ class PixmapDelegateFader : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
PixmapDelegateFader( const artist_ptr& artist, const QSize& size ); PixmapDelegateFader( const artist_ptr& artist, const QSize& size, bool forceLoad = true );
PixmapDelegateFader( const album_ptr& album, const QSize& size ); PixmapDelegateFader( const album_ptr& album, const QSize& size, bool forceLoad = true );
virtual ~PixmapDelegateFader(); virtual ~PixmapDelegateFader();