1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-12 09:04:33 +02:00

* Remove results if a collecion goes offline. This also updates live PlaylistModels.

This commit is contained in:
Christian Muehlhaeuser
2010-10-25 06:05:57 +02:00
parent c74823a73c
commit d83cc6841f
6 changed files with 36 additions and 13 deletions

View File

@@ -51,13 +51,13 @@ public:
signals: signals:
void resultsAdded( const QList<Tomahawk::result_ptr>& ); void resultsAdded( const QList<Tomahawk::result_ptr>& );
void resultsRemoved( Tomahawk::result_ptr ); void resultsRemoved( const Tomahawk::result_ptr& );
void solvedStateChanged( bool state ); void solvedStateChanged( bool state );
public slots: public slots:
/// (indirectly) called by resolver plugins when results are found /// (indirectly) called by resolver plugins when results are found
void addResults( const QList< Tomahawk::result_ptr >& ); void addResults( const QList< Tomahawk::result_ptr >& );
void removeResult( Tomahawk::result_ptr ); void removeResult( const Tomahawk::result_ptr& );
private slots: private slots:
void resultUnavailable(); void resultUnavailable();

View File

@@ -17,6 +17,7 @@ Pipeline::Pipeline( QObject* parent )
} }
void void
Pipeline::databaseReady() Pipeline::databaseReady()
{ {
@@ -24,6 +25,7 @@ Pipeline::databaseReady()
APP->database()->loadIndex(); APP->database()->loadIndex();
} }
void Pipeline::indexReady() void Pipeline::indexReady()
{ {
qDebug() << Q_FUNC_INFO << "shuting this many pending queries:" << m_queries_pending.size(); qDebug() << Q_FUNC_INFO << "shuting this many pending queries:" << m_queries_pending.size();
@@ -36,12 +38,14 @@ void Pipeline::indexReady()
m_queries_pending.clear(); m_queries_pending.clear();
} }
void void
Pipeline::removeResolver( Resolver* r ) Pipeline::removeResolver( Resolver* r )
{ {
m_resolvers.removeAll( r ); m_resolvers.removeAll( r );
} }
void void
Pipeline::addResolver( Resolver* r, bool sort ) Pipeline::addResolver( Resolver* r, bool sort )
{ {

View File

@@ -85,8 +85,11 @@ PlItem::setupItem( const Tomahawk::query_ptr& query, PlItem* parent )
if ( query->numResults() ) if ( query->numResults() )
onResultsAdded( query->results() ); onResultsAdded( query->results() );
connect( query.data(), SIGNAL( resultsAdded( const QList<Tomahawk::result_ptr>& ) ), connect( query.data(), SIGNAL( resultsAdded( QList<Tomahawk::result_ptr> ) ),
SLOT( onResultsAdded( const QList<Tomahawk::result_ptr>& ) ), Qt::DirectConnection ); SLOT( onResultsAdded( QList<Tomahawk::result_ptr> ) ), 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<Tomahawk::result_ptr>& results )
} }
void
PlItem::onResultsRemoved( const Tomahawk::result_ptr& result )
{
qDebug() << Q_FUNC_INFO;
emit dataChanged();
}
void void
PlItem::onModelRowsRemoved( const QModelIndex& index, int start, int end ) PlItem::onModelRowsRemoved( const QModelIndex& index, int start, int end )
{ {

View File

@@ -40,6 +40,7 @@ signals:
private slots: private slots:
void onResultsAdded( const QList<Tomahawk::result_ptr>& result ); void onResultsAdded( const QList<Tomahawk::result_ptr>& result );
void onResultsRemoved( const Tomahawk::result_ptr& result );
void onModelRowsRemoved( const QModelIndex& index, int start, int end ); void onModelRowsRemoved( const QModelIndex& index, int start, int end );
private: private:

View File

@@ -47,34 +47,39 @@ Query::addResults( const QList< Tomahawk::result_ptr >& newresults )
void void
Query::resultUnavailable() Query::resultUnavailable()
{ {
qDebug() << Q_FUNC_INFO;
Result* result = (Result*) sender(); Result* result = (Result*) sender();
Q_ASSERT( result ); 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 ); m_results.removeAt( i );
emit resultsRemoved( r );
break; break;
} }
} }
if ( m_results.isEmpty() ) // FIXME proper score checking
emit solvedStateChanged( false );
} }
void void
Query::removeResult( Tomahawk::result_ptr result ) Query::removeResult( const Tomahawk::result_ptr& result )
{ {
bool becameUnsolved = false;
{ {
QMutexLocker lock( &m_mut ); QMutexLocker lock( &m_mut );
m_results.removeAll( result ); m_results.removeAll( result );
if ( m_results.isEmpty() ) // FIXME proper score checking
becameUnsolved = true;
} }
emit resultsRemoved( result ); emit resultsRemoved( result );
if( becameUnsolved ) emit solvedStateChanged( false );
if ( m_results.isEmpty() ) // FIXME proper score checking
emit solvedStateChanged( false );
} }

View File

@@ -76,7 +76,9 @@ void
Source::remove() Source::remove()
{ {
qDebug() << Q_FUNC_INFO; qDebug() << Q_FUNC_INFO;
m_cc = 0; m_cc = 0;
emit offline();
APP->sourcelist().remove( this ); APP->sourcelist().remove( this );
m_collections.clear(); m_collections.clear();
} }