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:
void resultsAdded( const QList<Tomahawk::result_ptr>& );
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();

View File

@@ -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 )
{

View File

@@ -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<Tomahawk::result_ptr>& ) ),
SLOT( onResultsAdded( const QList<Tomahawk::result_ptr>& ) ), Qt::DirectConnection );
connect( query.data(), SIGNAL( resultsAdded( QList<Tomahawk::result_ptr> ) ),
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
PlItem::onModelRowsRemoved( const QModelIndex& index, int start, int end )
{

View File

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

View File

@@ -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 );
}

View File

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