1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 06:07:37 +02:00

make stations behave when multiple result signals are emitted by the pipeline

This commit is contained in:
Leo Franchi
2011-05-06 11:55:24 -04:00
parent 8c3745896c
commit 8b2ade25de
2 changed files with 26 additions and 17 deletions

View File

@@ -84,6 +84,7 @@ DynamicModel::newTrackGenerated( const Tomahawk::query_ptr& query )
if( m_onDemandRunning ) { if( m_onDemandRunning ) {
connect( query.data(), SIGNAL( resolvingFinished( bool ) ), this, SLOT( trackResolveFinished( bool ) ) ); connect( query.data(), SIGNAL( resolvingFinished( bool ) ), this, SLOT( trackResolveFinished( bool ) ) );
m_waitingFor << query.data();
append( query ); append( query );
} }
} }
@@ -112,7 +113,10 @@ DynamicModel::trackResolveFinished( bool success )
{ {
Q_UNUSED( success ); Q_UNUSED( success );
Query* q = qobject_cast<Query*>(sender()); Query* q = qobject_cast<Query*>( sender() );
if( !m_waitingFor.contains( q ) )
return;
if( !q->playable() ) { if( !q->playable() ) {
qDebug() << "Got not resolved track:" << q->track() << q->artist() << m_lastResolvedRow << m_currentAttempts; qDebug() << "Got not resolved track:" << q->track() << q->artist() << m_lastResolvedRow << m_currentAttempts;
@@ -139,6 +143,7 @@ DynamicModel::trackResolveFinished( bool success )
emit checkForOverflow(); emit checkForOverflow();
} }
m_waitingFor.removeAll( q );
} }

View File

@@ -1,5 +1,5 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> === /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
* *
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org> * Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* *
* Tomahawk is free software: you can redistribute it and/or modify * Tomahawk is free software: you can redistribute it and/or modify
@@ -27,7 +27,7 @@ namespace Tomahawk
class StationModelItem; class StationModelItem;
/** /**
* Extends PlaylistModel with support for handling stations * Extends PlaylistModel with support for handling stations
*/ */
@@ -37,22 +37,22 @@ class DynamicModel : public PlaylistModel
public: public:
DynamicModel( QObject* parent = 0 ); DynamicModel( QObject* parent = 0 );
virtual ~DynamicModel(); virtual ~DynamicModel();
void startOnDemand(); void startOnDemand();
void stopOnDemand( bool stopPlaying = true ); void stopOnDemand( bool stopPlaying = true );
void changeStation(); void changeStation();
virtual QString description() const; virtual QString description() const;
void loadPlaylist( const dynplaylist_ptr& playlist, bool loadEntries = true ); void loadPlaylist( const dynplaylist_ptr& playlist, bool loadEntries = true );
virtual void removeIndex( const QModelIndex& index, bool moreToCome = false ); virtual void removeIndex( const QModelIndex& index, bool moreToCome = false );
bool searchingForNext() const { return m_searchingForNext; } bool searchingForNext() const { return m_searchingForNext; }
void setFilterUnresolvable( bool filter ) { m_filterUnresolvable = filter; } void setFilterUnresolvable( bool filter ) { m_filterUnresolvable = filter; }
bool filterUnresolvable() const { return m_filterUnresolvable; } bool filterUnresolvable() const { return m_filterUnresolvable; }
// a batchof static tracks wre generated // a batchof static tracks wre generated
void tracksGenerated( const QList< query_ptr > entries, int limitResolvedTo = -1 ); void tracksGenerated( const QList< query_ptr > entries, int limitResolvedTo = -1 );
signals: signals:
@@ -60,25 +60,29 @@ signals:
void checkForOverflow(); void checkForOverflow();
void trackGenerationFailure( const QString& msg ); void trackGenerationFailure( const QString& msg );
void tracksAdded(); void tracksAdded();
private slots: private slots:
void newTrackGenerated( const Tomahawk::query_ptr& query ); void newTrackGenerated( const Tomahawk::query_ptr& query );
void trackResolveFinished( bool ); void trackResolveFinished( bool );
void newTrackLoading(); void newTrackLoading();
void filteringTrackResolved( bool successful ); void filteringTrackResolved( bool successful );
private: private:
void filterUnresolved( const QList< query_ptr >& entries ); void filterUnresolved( const QList< query_ptr >& entries );
void addToPlaylist( const QList< query_ptr >& entries, bool clearFirst ); void addToPlaylist( const QList< query_ptr >& entries, bool clearFirst );
dynplaylist_ptr m_playlist; dynplaylist_ptr m_playlist;
// for filtering unresolvable // for filtering unresolvable
int m_limitResolvedTo; int m_limitResolvedTo;
QList< query_ptr > m_toResolveList; QList< query_ptr > m_toResolveList;
QList< query_ptr > m_resolvedList; QList< query_ptr > m_resolvedList;
// for managing upcoming queue
QList< Query* > m_waitingFor;
bool m_onDemandRunning; bool m_onDemandRunning;
bool m_changeOnNext; bool m_changeOnNext;
bool m_searchingForNext; bool m_searchingForNext;
@@ -88,7 +92,7 @@ private:
int m_currentAttempts; int m_currentAttempts;
int m_lastResolvedRow; int m_lastResolvedRow;
}; };
}; };
#endif #endif