From 9e31e03498108ae030a06958026fc33143cc7cf7 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Sun, 9 Dec 2012 09:09:42 +0100 Subject: [PATCH] * GridView now allows (like Track- & TreeView) to have its PlaylistInterface overwritten. --- src/libtomahawk/playlist/GridView.cpp | 19 +++++++++++++++++-- src/libtomahawk/playlist/GridView.h | 4 ++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/libtomahawk/playlist/GridView.cpp b/src/libtomahawk/playlist/GridView.cpp index b884eecfb..9c71f48ee 100644 --- a/src/libtomahawk/playlist/GridView.cpp +++ b/src/libtomahawk/playlist/GridView.cpp @@ -110,8 +110,6 @@ GridView::GridView( QWidget* parent ) setAutoResize( false ); setProxyModel( new PlayableProxyModel( this ) ); - m_playlistInterface = playlistinterface_ptr( new GridPlaylistInterface( m_proxyModel, this ) ); - connect( this, SIGNAL( doubleClicked( QModelIndex ) ), SLOT( onItemActivated( QModelIndex ) ) ); connect( this, SIGNAL( customContextMenuRequested( QPoint ) ), SLOT( onCustomContextMenu( QPoint ) ) ); @@ -136,6 +134,9 @@ GridView::setProxyModel( PlayableProxyModel* model ) m_proxyModel = model; connect( m_proxyModel, SIGNAL( filterChanged( QString ) ), SLOT( onFilterChanged( QString ) ) ); + if ( m_delegate ) + delete m_delegate; + m_delegate = new GridItemDelegate( this, m_proxyModel ); connect( m_delegate, SIGNAL( updateIndex( QModelIndex ) ), this, SLOT( update( QModelIndex ) ) ); connect( m_delegate, SIGNAL( startedPlaying( QPersistentModelIndex ) ), this, SLOT( onDelegatePlaying( QPersistentModelIndex ) ) ); @@ -432,4 +433,18 @@ GridView::currentTrackRect() const } +playlistinterface_ptr +GridView::playlistInterface() const +{ + return proxyModel()->playlistInterface(); +} + + +void +GridView::setPlaylistInterface( const Tomahawk::playlistinterface_ptr& playlistInterface ) +{ + proxyModel()->setPlaylistInterface( playlistInterface ); +} + + #include "GridView.moc" diff --git a/src/libtomahawk/playlist/GridView.h b/src/libtomahawk/playlist/GridView.h index a5b006d2b..2db377ae2 100644 --- a/src/libtomahawk/playlist/GridView.h +++ b/src/libtomahawk/playlist/GridView.h @@ -65,7 +65,8 @@ public: void setEmptyTip( const QString& tip ); virtual QWidget* widget() { return this; } - virtual Tomahawk::playlistinterface_ptr playlistInterface() const { return m_playlistInterface; } + virtual Tomahawk::playlistinterface_ptr playlistInterface() const; + void setPlaylistInterface( const Tomahawk::playlistinterface_ptr& playlistInterface ); virtual QString title() const { return m_model->title(); } virtual QString description() const { return m_model->description(); } @@ -110,7 +111,6 @@ private: GridItemDelegate* m_delegate; AnimatedSpinner* m_loadingSpinner; OverlayWidget* m_overlay; - Tomahawk::playlistinterface_ptr m_playlistInterface; QModelIndex m_contextMenuIndex; QPersistentModelIndex m_playing;