mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
CollectionViewPage should do all the grunt work. Pass the collection_ptr to its ctor.
This commit is contained in:
@@ -264,20 +264,7 @@ ViewManager::show( const Tomahawk::collection_ptr& collection )
|
|||||||
CollectionViewPage* view;
|
CollectionViewPage* view;
|
||||||
if ( !m_collectionViews.contains( collection ) || m_collectionViews.value( collection ).isNull() )
|
if ( !m_collectionViews.contains( collection ) || m_collectionViews.value( collection ).isNull() )
|
||||||
{
|
{
|
||||||
view = new CollectionViewPage();
|
view = new CollectionViewPage( collection );
|
||||||
|
|
||||||
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 );
|
|
||||||
|
|
||||||
setPage( view );
|
setPage( view );
|
||||||
|
|
||||||
|
@@ -40,7 +40,7 @@
|
|||||||
using namespace Tomahawk;
|
using namespace Tomahawk;
|
||||||
|
|
||||||
|
|
||||||
CollectionViewPage::CollectionViewPage( QWidget* parent )
|
CollectionViewPage::CollectionViewPage( const Tomahawk::collection_ptr& collection, QWidget* parent )
|
||||||
: QWidget( parent )
|
: QWidget( parent )
|
||||||
, m_header( new FilterHeader( this ) )
|
, m_header( new FilterHeader( this ) )
|
||||||
, m_columnView( new ColumnView() )
|
, m_columnView( new ColumnView() )
|
||||||
@@ -48,6 +48,7 @@ CollectionViewPage::CollectionViewPage( QWidget* parent )
|
|||||||
, m_albumView( new GridView() )
|
, m_albumView( new GridView() )
|
||||||
, m_model( 0 )
|
, m_model( 0 )
|
||||||
, m_flatModel( 0 )
|
, m_flatModel( 0 )
|
||||||
|
, m_collection( collection )
|
||||||
, m_temporary( false )
|
, m_temporary( false )
|
||||||
{
|
{
|
||||||
qRegisterMetaType< CollectionViewPageMode >( "CollectionViewPageMode" );
|
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 );
|
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 ) ) );
|
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::Composer, true );
|
||||||
m_trackView->setColumnHidden( PlayableModel::Origin, true );
|
m_trackView->setColumnHidden( PlayableModel::Origin, true );
|
||||||
m_trackView->setColumnHidden( PlayableModel::Score, true );
|
m_trackView->setColumnHidden( PlayableModel::Score, true );
|
||||||
@@ -108,6 +111,18 @@ CollectionViewPage::CollectionViewPage( QWidget* parent )
|
|||||||
m_stack->addWidget( m_albumView );
|
m_stack->addWidget( m_albumView );
|
||||||
m_stack->addWidget( m_trackView );
|
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 ) ) );
|
connect( m_header, SIGNAL( filterTextChanged( QString ) ), SLOT( setFilter( QString ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -42,7 +42,7 @@ public:
|
|||||||
enum CollectionViewPageMode
|
enum CollectionViewPageMode
|
||||||
{ Columns = 0, Albums = 1, Flat = 2 };
|
{ Columns = 0, Albums = 1, Flat = 2 };
|
||||||
|
|
||||||
explicit CollectionViewPage( QWidget* parent = 0 );
|
explicit CollectionViewPage( const Tomahawk::collection_ptr& collection, QWidget* parent = 0 );
|
||||||
~CollectionViewPage();
|
~CollectionViewPage();
|
||||||
|
|
||||||
virtual QWidget* widget() { return this; }
|
virtual QWidget* widget() { return this; }
|
||||||
@@ -96,6 +96,8 @@ private:
|
|||||||
PlayableModel* m_albumModel;
|
PlayableModel* m_albumModel;
|
||||||
QStackedWidget* m_stack;
|
QStackedWidget* m_stack;
|
||||||
|
|
||||||
|
Tomahawk::collection_ptr m_collection;
|
||||||
|
|
||||||
CollectionViewPageMode m_mode;
|
CollectionViewPageMode m_mode;
|
||||||
bool m_temporary;
|
bool m_temporary;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user