mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-11 16:44:05 +02:00
* Fixed PlaylistManager to remember current state of playlists.
This commit is contained in:
@@ -92,10 +92,6 @@ PlaylistManager::PlaylistManager( QObject* parent )
|
||||
|
||||
m_currentInterface = m_superCollectionView->proxyModel();
|
||||
|
||||
m_playlistView = new PlaylistView();
|
||||
m_stack->addWidget( m_playlistView );
|
||||
m_playlistModel = new PlaylistModel();
|
||||
|
||||
m_stack->setContentsMargins( 0, 0, 0, 0 );
|
||||
m_widget->setContentsMargins( 0, 0, 0, 0 );
|
||||
m_widget->layout()->setContentsMargins( 0, 0, 0, 0 );
|
||||
@@ -153,18 +149,27 @@ PlaylistManager::show( const Tomahawk::playlist_ptr& playlist )
|
||||
{
|
||||
unlinkPlaylist();
|
||||
|
||||
m_playlistModel->loadPlaylist( playlist );
|
||||
m_playlistView->setModel( m_playlistModel );
|
||||
m_playlistView->setFrameShape( QFrame::NoFrame );
|
||||
|
||||
if ( !m_loadedPlaylists.contains( playlist ) )
|
||||
if ( !m_playlistViews.contains( playlist ) )
|
||||
{
|
||||
PlaylistView* view = new PlaylistView();
|
||||
PlaylistModel* model = new PlaylistModel();
|
||||
view->setModel( model );
|
||||
view->setFrameShape( QFrame::NoFrame );
|
||||
model->loadPlaylist( playlist );
|
||||
playlist->resolve();
|
||||
m_loadedPlaylists << playlist;
|
||||
}
|
||||
|
||||
m_currentInterface = m_playlistView->proxyModel();
|
||||
m_stack->setCurrentWidget( m_playlistView );
|
||||
m_currentInterface = view->proxyModel();
|
||||
m_playlistViews.insert( playlist, view );
|
||||
|
||||
m_stack->addWidget( view );
|
||||
m_stack->setCurrentWidget( view );
|
||||
}
|
||||
else
|
||||
{
|
||||
PlaylistView* view = m_playlistViews.value( playlist );
|
||||
m_stack->setCurrentWidget( view );
|
||||
m_currentInterface = view->proxyModel();
|
||||
}
|
||||
|
||||
m_superCollectionVisible = false;
|
||||
m_statsAvailable = true;
|
||||
@@ -177,12 +182,14 @@ PlaylistManager::show( const Tomahawk::playlist_ptr& playlist )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PlaylistManager::show(const Tomahawk::dynplaylist_ptr& playlist)
|
||||
PlaylistManager::show( const Tomahawk::dynplaylist_ptr& playlist )
|
||||
{
|
||||
unlinkPlaylist();
|
||||
|
||||
if( !m_dynamicWidgets.contains( playlist ) ) {
|
||||
if( !m_dynamicWidgets.contains( playlist ) )
|
||||
{
|
||||
m_dynamicWidgets[ playlist ] = new Tomahawk::DynamicWidget( playlist, m_stack );
|
||||
m_stack->addWidget( m_dynamicWidgets[ playlist ] );
|
||||
playlist->resolve();
|
||||
@@ -247,11 +254,26 @@ PlaylistManager::show( const Tomahawk::album_ptr& album )
|
||||
qDebug() << Q_FUNC_INFO << &album << album.data();
|
||||
unlinkPlaylist();
|
||||
|
||||
m_playlistModel->clear();
|
||||
m_playlistModel->append( album );
|
||||
m_stack->setCurrentWidget( m_playlistView );
|
||||
if ( !m_albumViews.contains( album ) )
|
||||
{
|
||||
PlaylistView* view = new PlaylistView();
|
||||
PlaylistModel* model = new PlaylistModel();
|
||||
view->setModel( model );
|
||||
view->setFrameShape( QFrame::NoFrame );
|
||||
model->append( album );
|
||||
|
||||
m_currentInterface = m_playlistView->proxyModel();
|
||||
m_currentInterface = view->proxyModel();
|
||||
m_albumViews.insert( album, view );
|
||||
|
||||
m_stack->addWidget( view );
|
||||
m_stack->setCurrentWidget( view );
|
||||
}
|
||||
else
|
||||
{
|
||||
PlaylistView* view = m_albumViews.value( album );
|
||||
m_stack->setCurrentWidget( view );
|
||||
m_currentInterface = view->proxyModel();
|
||||
}
|
||||
|
||||
m_superCollectionVisible = false;
|
||||
m_statsAvailable = false;
|
||||
|
@@ -105,16 +105,15 @@ private:
|
||||
AlbumView* m_superAlbumView;
|
||||
CollectionFlatModel* m_superCollectionFlatModel;
|
||||
CollectionView* m_superCollectionView;
|
||||
PlaylistView* m_playlistView;
|
||||
|
||||
QList<Tomahawk::playlist_ptr> m_loadedPlaylists;
|
||||
QList< Tomahawk::collection_ptr > m_superCollections;
|
||||
PlaylistModel* m_playlistModel;
|
||||
|
||||
QHash< Tomahawk::dynplaylist_ptr, Tomahawk::DynamicWidget* > m_dynamicWidgets;
|
||||
QHash< Tomahawk::collection_ptr, CollectionView* > m_collectionViews;
|
||||
QHash< Tomahawk::collection_ptr, AlbumView* > m_collectionAlbumViews;
|
||||
QHash< Tomahawk::artist_ptr, PlaylistView* > m_artistViews;
|
||||
QHash< Tomahawk::album_ptr, PlaylistView* > m_albumViews;
|
||||
QHash< Tomahawk::playlist_ptr, PlaylistView* > m_playlistViews;
|
||||
QHash< Tomahawk::source_ptr, SourceInfoWidget* > m_sourceViews;
|
||||
|
||||
PlaylistInterface* m_currentInterface;
|
||||
|
Reference in New Issue
Block a user