bool PlaylistManager::show( const Tomahawk::playlist_ptr& playlist ) { PlaylistView* view; if ( !m_playlistViews.contains( playlist ) ) { view = new PlaylistView(); PlaylistModel* model = new PlaylistModel(); view->setModel( model ); view->setFrameShape( QFrame::NoFrame ); view->setAttribute( Qt::WA_MacShowFocusRect, 0 ); model->loadPlaylist( playlist ); playlist->resolve(); m_playlistViews.insert( playlist, view ); } else { view = m_playlistViews.value( playlist ); } setPage( view ); TomahawkSettings::instance()->appendRecentlyPlayedPlaylist( playlist ); emit numSourcesChanged( SourceList::instance()->count() ); return true; }
bool PlaylistManager::show( const Tomahawk::album_ptr& album ) { PlaylistView* view; if ( !m_albumViews.contains( album ) ) { view = new PlaylistView(); PlaylistModel* model = new PlaylistModel(); view->setModel( model ); view->setFrameShape( QFrame::NoFrame ); view->setAttribute( Qt::WA_MacShowFocusRect, 0 ); model->append( album ); m_albumViews.insert( album, view ); } else { view = m_albumViews.value( album ); } setPage( view ); emit numSourcesChanged( 1 ); return true; }
Tomahawk::ViewPage* ViewManager::showRecentPlaysPage() { if ( !m_recentPlaysWidget ) { PlaylistView* pv = new PlaylistView( m_widget ); pv->setFrameShape( QFrame::NoFrame ); pv->setAttribute( Qt::WA_MacShowFocusRect, 0 ); RecentlyPlayedModel* raModel = new RecentlyPlayedModel( source_ptr(), pv ); raModel->setTitle( tr( "Recently Played Tracks" ) ); raModel->setDescription( tr( "Recently played tracks from all your friends" ) ); raModel->setStyle( TrackModel::Large ); PlaylistLargeItemDelegate* del = new PlaylistLargeItemDelegate( PlaylistLargeItemDelegate::RecentlyPlayed, pv, pv->proxyModel() ); connect( del, SIGNAL( updateIndex( QModelIndex ) ), pv, SLOT( update( QModelIndex ) ) ); pv->setItemDelegate( del ); pv->setPlaylistModel( raModel ); m_recentPlaysWidget = pv; } return show( m_recentPlaysWidget ); }
PlaylistView* ViewManager::createPageForPlaylist( const playlist_ptr& pl ) { PlaylistView* view = new PlaylistView(); PlaylistModel* model = new PlaylistModel(); view->setPlaylistModel( model ); model->loadPlaylist( pl ); view->setFrameShape( QFrame::NoFrame ); view->setAttribute( Qt::WA_MacShowFocusRect, 0 ); pl->resolve(); m_playlistViews.insert( pl, view ); return view; }
Tomahawk::ViewPage* ViewManager::showRecentPlaysPage() { if ( !m_recentPlaysWidget ) { PlaylistView* pv = new PlaylistView( m_widget ); pv->setFrameShape( QFrame::NoFrame ); pv->setAttribute( Qt::WA_MacShowFocusRect, 0 ); RecentlyPlayedModel* raModel = new RecentlyPlayedModel( source_ptr(), pv ); raModel->setStyle( TrackModel::Large ); pv->setItemDelegate( new PlaylistLargeItemDelegate( PlaylistLargeItemDelegate::RecentlyPlayed, pv, pv->proxyModel() ) ); pv->setPlaylistModel( raModel ); m_recentPlaysWidget = pv; } return show( m_recentPlaysWidget ); }