1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-04-15 13:32:35 +02:00

* No need to keep all delegates connected to the AudioEngine all the time. Only one holds a playing item.

This commit is contained in:
Christian Muehlhaeuser 2014-08-19 08:34:21 +02:00
parent 93b7fb3ce7
commit 89fa760397
2 changed files with 6 additions and 15 deletions

View File

@ -91,9 +91,6 @@ PlaylistItemDelegate::PlaylistItemDelegate( TrackView* parent, PlayableProxyMode
connect( this, SIGNAL( updateIndex( QModelIndex ) ), parent, SLOT( update( QModelIndex ) ) );
connect( proxy, SIGNAL( modelReset() ), SLOT( modelChanged() ) );
connect( parent, SIGNAL( modelChanged() ), SLOT( modelChanged() ) );
connect( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), SLOT( onPlaybackStarted() ) );
connect( AudioEngine::instance(), SIGNAL( stopped() ), SLOT( onPlaybackStopped() ) );
}
@ -653,6 +650,8 @@ PlaylistItemDelegate::drawTrack( QPainter* painter, const QStyleOptionViewItem&
{
if ( m_nowPlaying != index )
{
connect( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), SLOT( onPlaybackChange() ), Qt::UniqueConnection );
connect( AudioEngine::instance(), SIGNAL( stopped() ), SLOT( onPlaybackChange() ), Qt::UniqueConnection );
connect( AudioEngine::instance(), SIGNAL( timerMilliSeconds( qint64 ) ), SLOT( onAudioEngineTick( qint64 ) ), Qt::UniqueConnection );
m_nowPlaying = QPersistentModelIndex( index );
}
@ -895,17 +894,10 @@ PlaylistItemDelegate::onAudioEngineTick( qint64 /* ms */ )
void
PlaylistItemDelegate::onPlaybackStarted()
{
disconnect( AudioEngine::instance(), SIGNAL( timerMilliSeconds( qint64 ) ), this, SLOT( onAudioEngineTick( qint64 ) ) );
doUpdateIndex( m_nowPlaying );
m_nowPlaying = QModelIndex();
}
void
PlaylistItemDelegate::onPlaybackStopped()
PlaylistItemDelegate::onPlaybackChange()
{
disconnect( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), this, SLOT( onPlaybackChange() ) );
disconnect( AudioEngine::instance(), SIGNAL( stopped() ), this, SLOT( onPlaybackChange() ) );
disconnect( AudioEngine::instance(), SIGNAL( timerMilliSeconds( qint64 ) ), this, SLOT( onAudioEngineTick( qint64 ) ) );
doUpdateIndex( m_nowPlaying );
m_nowPlaying = QModelIndex();

View File

@ -109,8 +109,7 @@ protected:
protected slots:
virtual void modelChanged();
virtual void onAudioEngineTick( qint64 ms );
virtual void onPlaybackStarted();
virtual void onPlaybackStopped();
virtual void onPlaybackChange();
private:
mutable QHash< QPersistentModelIndex, QSharedPointer< Tomahawk::PixmapDelegateFader > > m_pixmaps;