1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-01 03:40:16 +02:00
This commit is contained in:
Leo Franchi
2011-04-05 21:06:24 -04:00
parent 3d93a82d08
commit 69011e3f90

View File

@@ -1,5 +1,5 @@
/* === This file is part of Tomahawk Player - <http://tomahawk-player.org> === /* === This file is part of Tomahawk Player - <http://tomahawk-player.org> ===
* *
* Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org> * Copyright 2010-2011, Christian Muehlhaeuser <muesli@tomahawk-player.org>
* *
* Tomahawk is free software: you can redistribute it and/or modify * Tomahawk is free software: you can redistribute it and/or modify
@@ -163,14 +163,14 @@ PlaylistManager::show( const Tomahawk::playlist_ptr& playlist )
playlist->resolve(); playlist->resolve();
m_playlistViews.insert( playlist, view ); m_playlistViews.insert( playlist, view );
connect( playlist.data(), SIGNAL( deleted( Tomahawk::playlist_ptr ) ), this, SLOT( onPlaylistDeleted( Tomahawk::playlist_ptr ) ) ); connect( playlist.data(), SIGNAL( deleted( Tomahawk::playlist_ptr ) ), this, SLOT( onPlaylistDeleted( Tomahawk::playlist_ptr ) ) );
} }
else else
{ {
view = m_playlistViews.value( playlist ); view = m_playlistViews.value( playlist );
} }
setPage( view ); setPage( view );
TomahawkSettings::instance()->appendRecentlyPlayedPlaylist( playlist ); TomahawkSettings::instance()->appendRecentlyPlayedPlaylist( playlist );
emit numSourcesChanged( SourceList::instance()->count() ); emit numSourcesChanged( SourceList::instance()->count() );
@@ -179,7 +179,7 @@ PlaylistManager::show( const Tomahawk::playlist_ptr& playlist )
} }
bool bool
PlaylistManager::show( const Tomahawk::dynplaylist_ptr& playlist ) PlaylistManager::show( const Tomahawk::dynplaylist_ptr& playlist )
{ {
if ( !m_dynamicWidgets.contains( playlist ) ) if ( !m_dynamicWidgets.contains( playlist ) )
@@ -187,17 +187,17 @@ PlaylistManager::show( const Tomahawk::dynplaylist_ptr& playlist )
m_dynamicWidgets[ playlist ] = new Tomahawk::DynamicWidget( playlist, m_stack ); m_dynamicWidgets[ playlist ] = new Tomahawk::DynamicWidget( playlist, m_stack );
connect( playlist.data(), SIGNAL( deleted( Tomahawk::dynplaylist_ptr ) ), this, SLOT( onDynamicDeleted( Tomahawk::dynplaylist_ptr ) ) ); connect( playlist.data(), SIGNAL( deleted( Tomahawk::dynplaylist_ptr ) ), this, SLOT( onDynamicDeleted( Tomahawk::dynplaylist_ptr ) ) );
playlist->resolve(); playlist->resolve();
} }
setPage( m_dynamicWidgets.value( playlist ) ); setPage( m_dynamicWidgets.value( playlist ) );
if ( playlist->mode() == Tomahawk::OnDemand ) if ( playlist->mode() == Tomahawk::OnDemand )
m_queueView->hide(); m_queueView->hide();
else else
m_queueView->show(); m_queueView->show();
TomahawkSettings::instance()->appendRecentlyPlayedPlaylist( playlist ); TomahawkSettings::instance()->appendRecentlyPlayedPlaylist( playlist );
emit numSourcesChanged( SourceList::instance()->count() ); emit numSourcesChanged( SourceList::instance()->count() );
@@ -225,7 +225,7 @@ PlaylistManager::show( const Tomahawk::artist_ptr& artist )
{ {
view = m_artistViews.value( artist ); view = m_artistViews.value( artist );
} }
setPage( view ); setPage( view );
emit numSourcesChanged( 1 ); emit numSourcesChanged( 1 );
@@ -252,7 +252,7 @@ PlaylistManager::show( const Tomahawk::album_ptr& album )
{ {
view = m_albumViews.value( album ); view = m_albumViews.value( album );
} }
setPage( view ); setPage( view );
emit numSourcesChanged( 1 ); emit numSourcesChanged( 1 );
@@ -359,10 +359,10 @@ PlaylistManager::showSuperCollection()
} }
} }
m_superCollectionFlatModel->addCollections( toAdd ); m_superCollectionFlatModel->addCollections( toAdd );
m_superCollectionFlatModel->setTitle( tr( "All available tracks" ) ); m_superCollectionFlatModel->setTitle( tr( "All available tracks" ) );
m_superAlbumModel->setTitle( tr( "All available albums" ) ); m_superAlbumModel->setTitle( tr( "All available albums" ) );
if ( m_currentMode == 0 ) if ( m_currentMode == 0 )
{ {
setPage( m_superCollectionView ); setPage( m_superCollectionView );
@@ -472,7 +472,7 @@ PlaylistManager::historyForward()
{ {
if ( m_historyPosition >= m_pageHistory.count() - 1 ) if ( m_historyPosition >= m_pageHistory.count() - 1 )
return; return;
showHistory( m_historyPosition + 1 ); showHistory( m_historyPosition + 1 );
} }
@@ -557,13 +557,10 @@ PlaylistManager::setPage( ViewPage* page, bool trackHistory )
// UGH! // UGH!
if( QObject* obj = dynamic_cast< QObject* >( currentPage() ) ) { if( QObject* obj = dynamic_cast< QObject* >( currentPage() ) ) {
// if the signal exists (just to hide the qobject runtime warning...) // if the signal exists (just to hide the qobject runtime warning...)
if( obj->metaObject()->indexOfSignal( "descriptionChanged(QString)" ) > -1 ) if( obj->metaObject()->indexOfSignal( "descriptionChanged(QString)" ) > -1 )
connect( obj, SIGNAL( descriptionChanged( QString ) ), m_infobar, SLOT( setDescription( QString ) ) ); connect( obj, SIGNAL( descriptionChanged( QString ) ), m_infobar, SLOT( setDescription( QString ) ) );
if( obj->metaObject()->indexOfSignal( "deleted()" ) > -1 )
connect( obj, SIGNAL( deleted() ), this, SLOT( pageDeleted() ) );
} }
m_stack->setCurrentWidget( page->widget() ); m_stack->setCurrentWidget( page->widget() );
updateView(); updateView();
} }
@@ -623,7 +620,7 @@ PlaylistManager::updateView()
emit modeChanged( currentPlaylistInterface()->viewMode() ); emit modeChanged( currentPlaylistInterface()->viewMode() );
} }
if ( currentPage()->queueVisible() ) if ( currentPage()->queueVisible() )
m_queueView->show(); m_queueView->show();
else else
m_queueView->hide(); m_queueView->hide();
@@ -641,28 +638,28 @@ PlaylistManager::updateView()
m_infobar->setPixmap( currentPage()->pixmap() ); m_infobar->setPixmap( currentPage()->pixmap() );
} }
void void
PlaylistManager::onDynamicDeleted( const Tomahawk::dynplaylist_ptr& pl ) PlaylistManager::onDynamicDeleted( const Tomahawk::dynplaylist_ptr& pl )
{ {
QWidget* w = m_dynamicWidgets.value( pl ); QWidget* w = m_dynamicWidgets.value( pl );
m_dynamicWidgets.remove( pl ); m_dynamicWidgets.remove( pl );
onWidgetDestroyed( w ); onWidgetDestroyed( w );
} }
void void
PlaylistManager::onPlaylistDeleted( const Tomahawk::playlist_ptr& pl ) PlaylistManager::onPlaylistDeleted( const Tomahawk::playlist_ptr& pl )
{ {
QWidget* w = m_playlistViews.value( pl ); QWidget* w = m_playlistViews.value( pl );
m_playlistViews.remove( pl ); m_playlistViews.remove( pl );
onWidgetDestroyed( w ); onWidgetDestroyed( w );
} }
void void
PlaylistManager::onWidgetDestroyed( QWidget* widget ) PlaylistManager::onWidgetDestroyed( QWidget* widget )
{ {
qDebug() << "Destroyed child:" << widget << widget->metaObject()->className(); qDebug() << "Destroyed child:" << widget << widget->metaObject()->className();
bool resetWidget = ( m_stack->currentWidget() == widget ); bool resetWidget = ( m_stack->currentWidget() == widget );
@@ -679,7 +676,7 @@ PlaylistManager::onWidgetDestroyed( QWidget* widget )
break; break;
} }
} }
if ( resetWidget ) if ( resetWidget )
{ {
if ( m_pageHistory.count() ) if ( m_pageHistory.count() )
@@ -704,7 +701,7 @@ PlaylistManager::setShuffled( bool enabled )
} }
void void
PlaylistManager::createPlaylist( const Tomahawk::source_ptr& src, PlaylistManager::createPlaylist( const Tomahawk::source_ptr& src,
const QVariant& contents ) const QVariant& contents )
{ {
@@ -714,7 +711,7 @@ PlaylistManager::createPlaylist( const Tomahawk::source_ptr& src,
} }
void void
PlaylistManager::createDynamicPlaylist( const Tomahawk::source_ptr& src, PlaylistManager::createDynamicPlaylist( const Tomahawk::source_ptr& src,
const QVariant& contents ) const QVariant& contents )
{ {