diff --git a/src/libtomahawk/playlist/queueproxymodel.cpp b/src/libtomahawk/playlist/queueproxymodel.cpp index 9685d4744..2f5864931 100644 --- a/src/libtomahawk/playlist/queueproxymodel.cpp +++ b/src/libtomahawk/playlist/queueproxymodel.cpp @@ -18,17 +18,19 @@ #include "queueproxymodel.h" +#include "playlist/trackview.h" #include "viewmanager.h" #include "utils/logger.h" using namespace Tomahawk; -QueueProxyModel::QueueProxyModel( QObject* parent ) +QueueProxyModel::QueueProxyModel( TrackView* parent ) : PlaylistProxyModel( parent ) { qDebug() << Q_FUNC_INFO; + connect( parent, SIGNAL( itemActivated( QModelIndex ) ), this, SLOT( onIndexActivated( QModelIndex ) ) ); connect( this, SIGNAL( sourceTrackCountChanged( unsigned int ) ), this, SLOT( onTrackCountChanged( unsigned int ) ) ); } @@ -38,11 +40,17 @@ QueueProxyModel::~QueueProxyModel() } +void +QueueProxyModel::onIndexActivated( const QModelIndex& index ) +{ + setCurrentIndex( QModelIndex() ); + removeIndex( index ); +} + + Tomahawk::result_ptr QueueProxyModel::siblingItem( int itemsAway ) { - qDebug() << Q_FUNC_INFO << rowCount( QModelIndex() ); - setCurrentIndex( QModelIndex() ); Tomahawk::result_ptr res = PlaylistProxyModel::siblingItem( itemsAway ); diff --git a/src/libtomahawk/playlist/queueproxymodel.h b/src/libtomahawk/playlist/queueproxymodel.h index 16dd5273e..d9368648d 100644 --- a/src/libtomahawk/playlist/queueproxymodel.h +++ b/src/libtomahawk/playlist/queueproxymodel.h @@ -24,13 +24,14 @@ #include "dllmacro.h" class QMetaData; +class TrackView; class DLLEXPORT QueueProxyModel : public PlaylistProxyModel { Q_OBJECT public: - explicit QueueProxyModel( QObject* parent = 0 ); + explicit QueueProxyModel( TrackView* parent = 0 ); ~QueueProxyModel(); virtual Tomahawk::result_ptr siblingItem( int itemsAway ); @@ -38,6 +39,7 @@ public: using PlaylistProxyModel::siblingItem; private slots: + void onIndexActivated( const QModelIndex& index ); void onTrackCountChanged( unsigned int count ); }; diff --git a/src/libtomahawk/playlist/queueview.cpp b/src/libtomahawk/playlist/queueview.cpp index 656ac8178..2668638bc 100644 --- a/src/libtomahawk/playlist/queueview.cpp +++ b/src/libtomahawk/playlist/queueview.cpp @@ -39,7 +39,7 @@ QueueView::QueueView( AnimatedSplitter* parent ) setHiddenSize( QSize( 0, 22 ) ); - ui->queue->setProxyModel( new QueueProxyModel( this ) ); + ui->queue->setProxyModel( new QueueProxyModel( ui->queue ) ); ui->queue->setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Ignored ); ui->queue->setFrameShape( QFrame::NoFrame ); ui->queue->setAttribute( Qt::WA_MacShowFocusRect, 0 ); diff --git a/src/libtomahawk/playlist/trackview.cpp b/src/libtomahawk/playlist/trackview.cpp index 341815a1e..4cdf14f85 100644 --- a/src/libtomahawk/playlist/trackview.cpp +++ b/src/libtomahawk/playlist/trackview.cpp @@ -183,6 +183,8 @@ TrackView::onItemActivated( const QModelIndex& index ) m_proxyModel->setCurrentIndex( index ); AudioEngine::instance()->playItem( m_proxyModel, item->query()->results().first() ); } + + emit itemActivated( index ); } diff --git a/src/libtomahawk/playlist/trackview.h b/src/libtomahawk/playlist/trackview.h index f3956bf80..8d04ed249 100644 --- a/src/libtomahawk/playlist/trackview.h +++ b/src/libtomahawk/playlist/trackview.h @@ -40,7 +40,7 @@ class DLLEXPORT TrackView : public QTreeView Q_OBJECT public: -explicit TrackView( QWidget* parent = 0 ); + explicit TrackView( QWidget* parent = 0 ); ~TrackView(); virtual QString guid() const { return m_guid; } @@ -66,11 +66,14 @@ explicit TrackView( QWidget* parent = 0 ); void setUpdatesContextView( bool b ) { m_updateContextView = b; } public slots: - void onItemActivated( const QModelIndex& index ); + virtual void onItemActivated( const QModelIndex& index ); void playItem(); void onMenuTriggered( int action ); +signals: + void itemActivated( const QModelIndex& index ); + protected: virtual void resizeEvent( QResizeEvent* event );