1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-11 16:44:05 +02:00

* Correctly unset pause / spinner on GridView when a new track is loading.

This commit is contained in:
Christian Muehlhaeuser
2012-07-04 05:37:07 +02:00
parent 1309334f99
commit 97a3d6fcd3
2 changed files with 19 additions and 11 deletions

View File

@@ -122,8 +122,8 @@ GridItemDelegate::paint( QPainter* painter, const QStyleOptionViewItem& option,
m_covers.insert( index, QSharedPointer< Tomahawk::PixmapDelegateFader >( new Tomahawk::PixmapDelegateFader( item->query(), r.size(), TomahawkUtils::Grid ) ) );
}
_detail::Closure* closure = NewClosure( m_covers[ index ], SIGNAL( repaintRequest() ), const_cast<GridItemDelegate*>(this), SLOT( doUpdateIndex( QPersistentModelIndex ) ), QPersistentModelIndex( index ) );
closure->setAutoDelete( false );
NewClosure( m_covers[ index ], SIGNAL( repaintRequest() ),
const_cast<GridItemDelegate*>(this), SLOT( doUpdateIndex( QPersistentModelIndex ) ), QPersistentModelIndex( index ) )->setAutoDelete( false );
}
QSharedPointer< Tomahawk::PixmapDelegateFader > fader = m_covers[ index ];
@@ -243,17 +243,18 @@ GridItemDelegate::onPlayClicked( const QPersistentModelIndex& index )
PlayableItem* item = m_model->sourceModel()->itemFromIndex( m_model->mapToSource( index ) );
if ( item )
{
_detail::Closure* closure;
NewClosure( AudioEngine::instance(), SIGNAL( loading( Tomahawk::result_ptr ) ),
const_cast<GridItemDelegate*>(this), SLOT( onPlaybackStarted( QPersistentModelIndex ) ), QPersistentModelIndex( index ) );
closure = NewClosure( AudioEngine::instance(), SIGNAL( loading( Tomahawk::result_ptr ) ),
const_cast<GridItemDelegate*>(this), SLOT( onPlaybackStarted( QPersistentModelIndex ) ), QPersistentModelIndex( index ) );
m_closures.remove( index );
closure = NewClosure( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ),
const_cast<GridItemDelegate*>(this), SLOT( onPlaylistChanged( QPersistentModelIndex ) ), QPersistentModelIndex( index ) );
closure = NewClosure( AudioEngine::instance(), SIGNAL( stopped() ),
const_cast<GridItemDelegate*>(this), SLOT( onPlaylistChanged( QPersistentModelIndex ) ), QPersistentModelIndex( index ) );
m_closures.insertMulti( index, NewClosure( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ),
const_cast<GridItemDelegate*>(this), SLOT( onPlaylistChanged( QPersistentModelIndex ) ), QPersistentModelIndex( index ) ) );
m_closures.insertMulti( index, NewClosure( AudioEngine::instance(), SIGNAL( stopped() ),
const_cast<GridItemDelegate*>(this), SLOT( onPlaylistChanged( QPersistentModelIndex ) ), QPersistentModelIndex( index ) ) );
closure->setAutoDelete( false );
foreach ( _detail::Closure* closure, m_closures.values( index ) )
closure->setAutoDelete( false );
connect( AudioEngine::instance(), SIGNAL( stopped() ), SLOT( onPlaybackFinished() ) );
@@ -485,6 +486,9 @@ GridItemDelegate::onPlaylistChanged( const QPersistentModelIndex& index )
if ( finished )
{
foreach ( _detail::Closure* closure, m_closures.values( index ) )
closure->deleteLater();
if ( m_pauseButton.contains( index ) )
{
m_pauseButton[ index ]->deleteLater();

View File

@@ -29,6 +29,10 @@ namespace Tomahawk {
class PixmapDelegateFader;
}
namespace _detail {
class Closure;
}
class QEvent;
class QTimeLine;
class PlayableProxyModel;
@@ -86,8 +90,8 @@ private:
mutable QHash< QPersistentModelIndex, QWidget* > m_spinner;
mutable QHash< QPersistentModelIndex, ImageButton* > m_playButton;
mutable QHash< QPersistentModelIndex, ImageButton* > m_pauseButton;
mutable QHash< QPersistentModelIndex, QTimeLine* > m_hoverFaders;
mutable QHash< QPersistentModelIndex, _detail::Closure* > m_closures;
};
#endif // GRIDITEMDELEGATE_H