1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-30 19:00:12 +02:00

CollectionViewPage should do all the grunt work. Pass the collection_ptr to its ctor.

This commit is contained in:
Christian Muehlhaeuser
2014-10-20 02:49:11 +02:00
parent 44ffefb1fb
commit 225d5764e7
3 changed files with 20 additions and 16 deletions

View File

@@ -264,20 +264,7 @@ ViewManager::show( const Tomahawk::collection_ptr& collection )
CollectionViewPage* view;
if ( !m_collectionViews.contains( collection ) || m_collectionViews.value( collection ).isNull() )
{
view = new CollectionViewPage();
view->columnView()->proxyModel()->setStyle( PlayableProxyModel::Collection );
TreeModel* model = new TreeModel();
PlayableModel* flatModel = new PlayableModel();
PlayableModel* albumModel = new PlayableModel();
view->setTreeModel( model );
view->setFlatModel( flatModel );
view->setAlbumModel( albumModel );
model->addCollection( collection );
flatModel->appendTracks( collection );
albumModel->appendAlbums( collection );
view = new CollectionViewPage( collection );
setPage( view );

View File

@@ -40,7 +40,7 @@
using namespace Tomahawk;
CollectionViewPage::CollectionViewPage( QWidget* parent )
CollectionViewPage::CollectionViewPage( const Tomahawk::collection_ptr& collection, QWidget* parent )
: QWidget( parent )
, m_header( new FilterHeader( this ) )
, m_columnView( new ColumnView() )
@@ -48,6 +48,7 @@ CollectionViewPage::CollectionViewPage( QWidget* parent )
, m_albumView( new GridView() )
, m_model( 0 )
, m_flatModel( 0 )
, m_collection( collection )
, m_temporary( false )
{
qRegisterMetaType< CollectionViewPageMode >( "CollectionViewPageMode" );
@@ -55,6 +56,8 @@ CollectionViewPage::CollectionViewPage( QWidget* parent )
m_header->setBackground( ImageRegistry::instance()->pixmap( RESPATH "images/collection_background.png", QSize( 0, 0 ) ), false );
setPixmap( TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultCollection, TomahawkUtils::Original, QSize( 256, 256 ) ) );
m_columnView->proxyModel()->setStyle( PlayableProxyModel::Collection );
m_trackView->setColumnHidden( PlayableModel::Composer, true );
m_trackView->setColumnHidden( PlayableModel::Origin, true );
m_trackView->setColumnHidden( PlayableModel::Score, true );
@@ -108,6 +111,18 @@ CollectionViewPage::CollectionViewPage( QWidget* parent )
m_stack->addWidget( m_albumView );
m_stack->addWidget( m_trackView );
TreeModel* model = new TreeModel();
PlayableModel* flatModel = new PlayableModel();
PlayableModel* albumModel = new PlayableModel();
setTreeModel( model );
setFlatModel( flatModel );
setAlbumModel( albumModel );
model->addCollection( collection );
flatModel->appendTracks( collection );
albumModel->appendAlbums( collection );
connect( m_header, SIGNAL( filterTextChanged( QString ) ), SLOT( setFilter( QString ) ) );
}

View File

@@ -42,7 +42,7 @@ public:
enum CollectionViewPageMode
{ Columns = 0, Albums = 1, Flat = 2 };
explicit CollectionViewPage( QWidget* parent = 0 );
explicit CollectionViewPage( const Tomahawk::collection_ptr& collection, QWidget* parent = 0 );
~CollectionViewPage();
virtual QWidget* widget() { return this; }
@@ -96,6 +96,8 @@ private:
PlayableModel* m_albumModel;
QStackedWidget* m_stack;
Tomahawk::collection_ptr m_collection;
CollectionViewPageMode m_mode;
bool m_temporary;
};