1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-04-07 17:42:35 +02:00

* Prevent stuck now playing indicator.

This commit is contained in:
Christian Muehlhaeuser 2011-11-23 12:28:34 +01:00
parent 8cff1f7b76
commit fc5bf30a79
4 changed files with 17 additions and 6 deletions

View File

@ -39,13 +39,13 @@ TrackModel::TrackModel( QObject* parent )
, m_readOnly( true )
, m_style( Detailed )
{
connect( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), SLOT( onPlaybackStarted( Tomahawk::result_ptr ) ), Qt::DirectConnection );
connect( AudioEngine::instance(), SIGNAL( stopped() ), SLOT( onPlaybackStopped() ), Qt::DirectConnection );
}
TrackModel::~TrackModel()
{
delete m_rootItem;
}
@ -475,6 +475,17 @@ TrackModel::itemFromIndex( const QModelIndex& index ) const
}
void
TrackModel::onPlaybackStarted( const Tomahawk::result_ptr& result )
{
TrackModelItem* oldEntry = itemFromIndex( m_currentIndex );
if ( oldEntry && ( oldEntry->query().isNull() || !oldEntry->query()->numResults() || oldEntry->query()->results().first().data() != result.data() ) )
{
oldEntry->setIsPlaying( false );
}
}
void
TrackModel::onPlaybackStopped()
{

View File

@ -126,6 +126,7 @@ public slots:
virtual void setShuffled( bool /*shuffled*/ ) {}
private slots:
void onPlaybackStarted( const Tomahawk::result_ptr& result );
void onPlaybackStopped();
private:

View File

@ -43,7 +43,7 @@ TreeModel::TreeModel( QObject* parent )
{
setIcon( QPixmap( RESPATH "images/music-icon.png" ) );
connect( AudioEngine::instance(), SIGNAL( finished( Tomahawk::result_ptr ) ), SLOT( onPlaybackFinished( Tomahawk::result_ptr ) ), Qt::DirectConnection );
connect( AudioEngine::instance(), SIGNAL( started( Tomahawk::result_ptr ) ), SLOT( onPlaybackStarted( Tomahawk::result_ptr ) ), Qt::DirectConnection );
connect( AudioEngine::instance(), SIGNAL( stopped() ), SLOT( onPlaybackStopped() ), Qt::DirectConnection );
connect( Tomahawk::InfoSystem::InfoSystem::instance(),
@ -948,11 +948,10 @@ TreeModel::infoSystemFinished( QString target )
void
TreeModel::onPlaybackFinished( const Tomahawk::result_ptr& result )
TreeModel::onPlaybackStarted( const Tomahawk::result_ptr& result )
{
TreeModelItem* oldEntry = itemFromIndex( m_currentIndex );
qDebug() << oldEntry->result().data() << result.data();
if ( oldEntry && !oldEntry->result().isNull() && oldEntry->result().data() == result.data() )
if ( oldEntry && ( oldEntry->result().isNull() || oldEntry->result().data() != result.data() ) )
{
oldEntry->setIsPlaying( false );
}

View File

@ -149,7 +149,7 @@ private slots:
void infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData requestData, QVariant output );
void infoSystemFinished( QString target );
void onPlaybackFinished( const Tomahawk::result_ptr& result );
void onPlaybackStarted( const Tomahawk::result_ptr& result );
void onPlaybackStopped();
void onDataChanged();