1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 14:16:32 +02:00

Cleaned up CollectionViewPage ctor and removed obsoleted code.

This commit is contained in:
Christian Muehlhaeuser
2014-10-20 03:11:58 +02:00
parent dc2c4bf168
commit 924ff97294
2 changed files with 24 additions and 37 deletions

View File

@@ -49,7 +49,7 @@ CollectionViewPage::CollectionViewPage( const Tomahawk::collection_ptr& collecti
, m_albumView( new GridView() ) , m_albumView( new GridView() )
, m_model( 0 ) , m_model( 0 )
, m_flatModel( 0 ) , m_flatModel( 0 )
, m_collection( collection ) , m_albumModel( 0 )
{ {
qRegisterMetaType< CollectionViewPageMode >( "CollectionViewPageMode" ); qRegisterMetaType< CollectionViewPageMode >( "CollectionViewPageMode" );
@@ -111,6 +111,23 @@ CollectionViewPage::CollectionViewPage( const Tomahawk::collection_ptr& collecti
m_stack->addWidget( m_albumView ); m_stack->addWidget( m_albumView );
m_stack->addWidget( m_trackView ); m_stack->addWidget( m_trackView );
connect( m_header, SIGNAL( filterTextChanged( QString ) ), SLOT( setFilter( QString ) ) );
loadCollection( collection );
}
CollectionViewPage::~CollectionViewPage()
{
tDebug() << Q_FUNC_INFO;
}
void
CollectionViewPage::loadCollection( const collection_ptr& collection )
{
m_collection = collection;
TreeModel* model = new TreeModel(); TreeModel* model = new TreeModel();
PlayableModel* flatModel = new PlayableModel(); PlayableModel* flatModel = new PlayableModel();
PlayableModel* albumModel = new PlayableModel(); PlayableModel* albumModel = new PlayableModel();
@@ -132,14 +149,6 @@ CollectionViewPage::CollectionViewPage( const Tomahawk::collection_ptr& collecti
if ( collection.objectCast<ScriptCollection>() ) if ( collection.objectCast<ScriptCollection>() )
m_trackView->setEmptyTip( tr( "Cloud collections aren't supported in the flat view yet. We will have them covered soon. Switch to another view to navigate them." ) ); m_trackView->setEmptyTip( tr( "Cloud collections aren't supported in the flat view yet. We will have them covered soon. Switch to another view to navigate them." ) );
connect( m_header, SIGNAL( filterTextChanged( QString ) ), SLOT( setFilter( QString ) ) );
}
CollectionViewPage::~CollectionViewPage()
{
tDebug() << Q_FUNC_INFO;
} }
@@ -153,16 +162,8 @@ CollectionViewPage::setTreeModel( TreeModel* model )
} }
m_model = model; m_model = model;
// m_trackView->setPlayableModel( model );
m_columnView->setTreeModel( model ); m_columnView->setTreeModel( model );
/* m_trackView->setSortingEnabled( false );
m_trackView->sortByColumn( -1 );
m_trackView->proxyModel()->sort( -1 );
m_columnView->proxyModel()->sort( -1 );
m_gridView->proxyModel()->sort( -1 );*/
connect( model, SIGNAL( changed() ), SLOT( onModelChanged() ), Qt::UniqueConnection ); connect( model, SIGNAL( changed() ), SLOT( onModelChanged() ), Qt::UniqueConnection );
onModelChanged(); onModelChanged();
} }
@@ -172,31 +173,23 @@ void
CollectionViewPage::setFlatModel( PlayableModel* model ) CollectionViewPage::setFlatModel( PlayableModel* model )
{ {
if ( m_flatModel ) if ( m_flatModel )
{
// disconnect( m_flatModel, SIGNAL( changed() ), this, SLOT( onModelChanged() ) );
delete m_flatModel; delete m_flatModel;
}
m_flatModel = model; m_flatModel = model;
m_trackView->setPlayableModel( model ); m_trackView->setPlayableModel( model );
m_trackView->setSortingEnabled( true ); m_trackView->setSortingEnabled( true );
m_trackView->sortByColumn( 0, Qt::AscendingOrder ); m_trackView->sortByColumn( 0, Qt::AscendingOrder );
/* connect( model, SIGNAL( changed() ), SLOT( onModelChanged() ), Qt::UniqueConnection );
onModelChanged();*/
} }
void void
CollectionViewPage::setAlbumModel( PlayableModel* model ) CollectionViewPage::setAlbumModel( PlayableModel* model )
{ {
if ( m_albumModel )
delete m_albumModel;
m_albumModel = model; m_albumModel = model;
m_albumView->setPlayableModel( model ); m_albumView->setPlayableModel( model );
/* connect( model, SIGNAL( changed() ), SLOT( onModelChanged() ), Qt::UniqueConnection );
* onModelChanged();*/
} }
@@ -328,6 +321,7 @@ CollectionViewPage::setFilter( const QString& pattern )
void void
CollectionViewPage::restoreViewMode() CollectionViewPage::restoreViewMode()
{ {
//FIXME: needs be moved to TomahawkSettings
TomahawkSettings::instance()->beginGroup( "ui" ); TomahawkSettings::instance()->beginGroup( "ui" );
int modeNumber = TomahawkSettings::instance()->value( "flexibleTreeViewMode", Columns ).toInt(); int modeNumber = TomahawkSettings::instance()->value( "flexibleTreeViewMode", Columns ).toInt();
m_mode = static_cast< CollectionViewPageMode >( modeNumber ); m_mode = static_cast< CollectionViewPageMode >( modeNumber );
@@ -363,14 +357,6 @@ CollectionViewPage::onModelChanged()
} }
void
CollectionViewPage::onWidgetDestroyed( QWidget* widget )
{
Q_UNUSED( widget );
emit destroyed( this );
}
bool bool
CollectionViewPage::isTemporaryPage() const CollectionViewPage::isTemporaryPage() const
{ {

View File

@@ -68,13 +68,14 @@ public slots:
virtual bool setFilter( const QString& pattern ); virtual bool setFilter( const QString& pattern );
void restoreViewMode(); //ViewManager calls this on every show void restoreViewMode(); //ViewManager calls this on every show
void loadCollection( const Tomahawk::collection_ptr& collection );
signals: signals:
void modeChanged( CollectionViewPageMode mode ); void modeChanged( CollectionViewPageMode mode );
void destroyed( QWidget* widget ); void destroyed( QWidget* widget );
private slots: private slots:
void onModelChanged(); void onModelChanged();
void onWidgetDestroyed( QWidget* widget );
private: private:
FilterHeader* m_header; FilterHeader* m_header;