1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 03:10:12 +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( this, SIGNAL( updateIndex( QModelIndex ) ), parent, SLOT( update( QModelIndex ) ) );
connect( proxy, SIGNAL( modelReset() ), SLOT( modelChanged() ) ); connect( proxy, SIGNAL( modelReset() ), SLOT( modelChanged() ) );
connect( parent, SIGNAL( modelChanged() ), 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 ) 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 ); connect( AudioEngine::instance(), SIGNAL( timerMilliSeconds( qint64 ) ), SLOT( onAudioEngineTick( qint64 ) ), Qt::UniqueConnection );
m_nowPlaying = QPersistentModelIndex( index ); m_nowPlaying = QPersistentModelIndex( index );
} }
@@ -895,17 +894,10 @@ PlaylistItemDelegate::onAudioEngineTick( qint64 /* ms */ )
void void
PlaylistItemDelegate::onPlaybackStarted() PlaylistItemDelegate::onPlaybackChange()
{
disconnect( AudioEngine::instance(), SIGNAL( timerMilliSeconds( qint64 ) ), this, SLOT( onAudioEngineTick( qint64 ) ) );
doUpdateIndex( m_nowPlaying );
m_nowPlaying = QModelIndex();
}
void
PlaylistItemDelegate::onPlaybackStopped()
{ {
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 ) ) ); disconnect( AudioEngine::instance(), SIGNAL( timerMilliSeconds( qint64 ) ), this, SLOT( onAudioEngineTick( qint64 ) ) );
doUpdateIndex( m_nowPlaying ); doUpdateIndex( m_nowPlaying );
m_nowPlaying = QModelIndex(); m_nowPlaying = QModelIndex();

View File

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