1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-05 13:47:26 +02:00

re-resolve tracks when a resolver is added or removed.

The pipeline emits a signal to queries when a resolver is added/removed. The queries
take action based on their solved() status and if not solved() inform the pipeline to
re-resolve them.
This commit is contained in:
Christopher Reichert
2011-06-03 19:01:23 -05:00
parent 7742e3091a
commit 5ec7e3340b
4 changed files with 35 additions and 1 deletions

View File

@@ -82,8 +82,9 @@ void
Pipeline::removeResolver( Resolver* r ) Pipeline::removeResolver( Resolver* r )
{ {
QMutexLocker lock( &m_mut ); QMutexLocker lock( &m_mut );
m_resolvers.removeAll( r ); m_resolvers.removeAll( r );
emit resolverRemoved( r );
} }
@@ -100,6 +101,7 @@ Pipeline::addResolver( Resolver* r, bool sort )
Pipeline::resolverSorter ); Pipeline::resolverSorter );
} }
qDebug() << "Adding resolver" << r->name(); qDebug() << "Adding resolver" << r->name();
emit resolverAdded( r );
/* qDebug() << "Current pipeline:"; /* qDebug() << "Current pipeline:";
foreach( Resolver * r, m_resolvers ) foreach( Resolver * r, m_resolvers )

View File

@@ -79,6 +79,9 @@ public slots:
signals: signals:
void idle(); void idle();
void resolving( const Tomahawk::query_ptr& query ); void resolving( const Tomahawk::query_ptr& query );
void resolverAdded( Resolver* );
void resolverRemoved( Resolver* );
private slots: private slots:
void timeoutShunt( const query_ptr& q ); void timeoutShunt( const query_ptr& q );

View File

@@ -67,6 +67,11 @@ Query::Query( const QString& artist, const QString& track, const QString& album,
{ {
connect( Database::instance(), SIGNAL( indexReady() ), SLOT( refreshResults() ), Qt::QueuedConnection ); connect( Database::instance(), SIGNAL( indexReady() ), SLOT( refreshResults() ), Qt::QueuedConnection );
} }
connect( Pipeline::instance(), SIGNAL( resolverAdded( Resolver* ) ),
SLOT( onResolverAdded() ), Qt::QueuedConnection );
connect( Pipeline::instance(), SIGNAL( resolverRemoved( Resolver* ) ),
SLOT( onResolverRemoved() ), Qt::QueuedConnection );
} }
@@ -148,6 +153,26 @@ Query::onResolvingFinished()
} }
void
Query::onResolverAdded( )
{
if ( !solved() )
{
refreshResults();
}
}
void
Query::onResolverRemoved( )
{
if ( !solved() )
{
refreshResults();
}
}
QList< result_ptr > QList< result_ptr >
Query::results() const Query::results() const
{ {

View File

@@ -105,6 +105,10 @@ public slots:
void onResolvingFinished(); void onResolvingFinished();
// resolve if not solved()
void onResolverAdded( );
void onResolverRemoved( );
private slots: private slots:
void onResultStatusChanged(); void onResultStatusChanged();
void refreshResults(); void refreshResults();