diff --git a/src/libtomahawk/playlist/QueueProxyModel.cpp b/src/libtomahawk/playlist/QueueProxyModel.cpp index c2023642a..522723758 100644 --- a/src/libtomahawk/playlist/QueueProxyModel.cpp +++ b/src/libtomahawk/playlist/QueueProxyModel.cpp @@ -32,6 +32,8 @@ using namespace Tomahawk; QueueProxyModel::QueueProxyModel( TrackView* parent ) : PlayableProxyModel( parent ) { + connect( this, SIGNAL( indexPlayable( QModelIndex ) ), SLOT( onIndexChanged( QModelIndex ) ) ); + connect( this, SIGNAL( indexResolved( QModelIndex ) ), SLOT( onIndexChanged( QModelIndex ) ) ); connect( parent, SIGNAL( itemActivated( QModelIndex ) ), SLOT( onIndexActivated( QModelIndex ) ) ); connect( AudioEngine::instance(), SIGNAL( loading( Tomahawk::result_ptr ) ), SLOT( onPlaybackStarted( Tomahawk::result_ptr ) ) ); } @@ -42,6 +44,21 @@ QueueProxyModel::~QueueProxyModel() } +void +QueueProxyModel::onIndexChanged( const QModelIndex& index ) +{ + PlayableItem* item = itemFromIndex( mapToSource( index ) ); + if ( item && item->query() ) + { + tDebug() << item->query()->toString() << item->query()->resolvingFinished() << item->query()->playable(); + } + if ( !item || !item->query() || ( item->query()->resolvingFinished() && !item->query()->playable() ) ) + { + removeIndex( index ); + } +} + + void QueueProxyModel::onPlaybackStarted( const Tomahawk::result_ptr& result ) { diff --git a/src/libtomahawk/playlist/QueueProxyModel.h b/src/libtomahawk/playlist/QueueProxyModel.h index f2755a03a..ad8d20641 100644 --- a/src/libtomahawk/playlist/QueueProxyModel.h +++ b/src/libtomahawk/playlist/QueueProxyModel.h @@ -36,6 +36,7 @@ public: virtual ~QueueProxyModel(); private slots: + void onIndexChanged( const QModelIndex& index ); void onIndexActivated( const QModelIndex& index ); void onPlaybackStarted( const Tomahawk::result_ptr& result ); };