diff --git a/include/tomahawk/query.h b/include/tomahawk/query.h index f92c84384..3ce6064eb 100644 --- a/include/tomahawk/query.h +++ b/include/tomahawk/query.h @@ -51,13 +51,13 @@ public: signals: void resultsAdded( const QList& ); - void resultsRemoved( Tomahawk::result_ptr ); + void resultsRemoved( const Tomahawk::result_ptr& ); void solvedStateChanged( bool state ); public slots: /// (indirectly) called by resolver plugins when results are found void addResults( const QList< Tomahawk::result_ptr >& ); - void removeResult( Tomahawk::result_ptr ); + void removeResult( const Tomahawk::result_ptr& ); private slots: void resultUnavailable(); diff --git a/src/pipeline.cpp b/src/pipeline.cpp index c78a2d6db..b5a294221 100644 --- a/src/pipeline.cpp +++ b/src/pipeline.cpp @@ -17,6 +17,7 @@ Pipeline::Pipeline( QObject* parent ) } + void Pipeline::databaseReady() { @@ -24,6 +25,7 @@ Pipeline::databaseReady() APP->database()->loadIndex(); } + void Pipeline::indexReady() { qDebug() << Q_FUNC_INFO << "shuting this many pending queries:" << m_queries_pending.size(); @@ -36,12 +38,14 @@ void Pipeline::indexReady() m_queries_pending.clear(); } + void Pipeline::removeResolver( Resolver* r ) { m_resolvers.removeAll( r ); } + void Pipeline::addResolver( Resolver* r, bool sort ) { diff --git a/src/playlist/plitem.cpp b/src/playlist/plitem.cpp index 3f77c1bcb..dd341fc9c 100644 --- a/src/playlist/plitem.cpp +++ b/src/playlist/plitem.cpp @@ -85,8 +85,11 @@ PlItem::setupItem( const Tomahawk::query_ptr& query, PlItem* parent ) if ( query->numResults() ) onResultsAdded( query->results() ); - connect( query.data(), SIGNAL( resultsAdded( const QList& ) ), - SLOT( onResultsAdded( const QList& ) ), Qt::DirectConnection ); + connect( query.data(), SIGNAL( resultsAdded( QList ) ), + SLOT( onResultsAdded( QList ) ), Qt::DirectConnection ); + + connect( query.data(), SIGNAL( resultsRemoved( Tomahawk::result_ptr ) ), + SLOT( onResultsRemoved( Tomahawk::result_ptr ) ), Qt::DirectConnection ); } @@ -98,6 +101,14 @@ PlItem::onResultsAdded( const QList& results ) } +void +PlItem::onResultsRemoved( const Tomahawk::result_ptr& result ) +{ + qDebug() << Q_FUNC_INFO; + emit dataChanged(); +} + + void PlItem::onModelRowsRemoved( const QModelIndex& index, int start, int end ) { diff --git a/src/playlist/plitem.h b/src/playlist/plitem.h index 222077835..95afdd69e 100644 --- a/src/playlist/plitem.h +++ b/src/playlist/plitem.h @@ -40,6 +40,7 @@ signals: private slots: void onResultsAdded( const QList& result ); + void onResultsRemoved( const Tomahawk::result_ptr& result ); void onModelRowsRemoved( const QModelIndex& index, int start, int end ); private: diff --git a/src/query.cpp b/src/query.cpp index 409db7a1b..ff5cbddfa 100644 --- a/src/query.cpp +++ b/src/query.cpp @@ -47,34 +47,39 @@ Query::addResults( const QList< Tomahawk::result_ptr >& newresults ) void Query::resultUnavailable() { + qDebug() << Q_FUNC_INFO; + Result* result = (Result*) sender(); Q_ASSERT( result ); - for(int i = 0; i < m_results.length(); ++i ) + for ( int i = 0; i < m_results.length(); ++i ) { - if( m_results.value( i ).data() == result ) + if ( m_results.value( i ).data() == result ) { + result_ptr r = m_results.value( i ); m_results.removeAt( i ); + + emit resultsRemoved( r ); break; } } + + if ( m_results.isEmpty() ) // FIXME proper score checking + emit solvedStateChanged( false ); } void -Query::removeResult( Tomahawk::result_ptr result ) +Query::removeResult( const Tomahawk::result_ptr& result ) { - bool becameUnsolved = false; { QMutexLocker lock( &m_mut ); m_results.removeAll( result ); - - if ( m_results.isEmpty() ) // FIXME proper score checking - becameUnsolved = true; - } emit resultsRemoved( result ); - if( becameUnsolved ) emit solvedStateChanged( false ); + + if ( m_results.isEmpty() ) // FIXME proper score checking + emit solvedStateChanged( false ); } diff --git a/src/source.cpp b/src/source.cpp index bc4055bb2..1bbc38e53 100644 --- a/src/source.cpp +++ b/src/source.cpp @@ -76,7 +76,9 @@ void Source::remove() { qDebug() << Q_FUNC_INFO; + m_cc = 0; + emit offline(); APP->sourcelist().remove( this ); m_collections.clear(); }