1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-19 12:21:52 +02:00

* Make use of new Playlist::get() API.

This commit is contained in:
Christian Muehlhaeuser
2013-04-27 04:47:51 +02:00
parent 499ba45c73
commit 049b6ef8a5
5 changed files with 12 additions and 37 deletions

View File

@@ -50,18 +50,14 @@ DatabaseCommand_DeleteDynamicPlaylist::exec( DatabaseImpl* lib )
void void
DatabaseCommand_DeleteDynamicPlaylist::postCommitHook() DatabaseCommand_DeleteDynamicPlaylist::postCommitHook()
{ {
qDebug() << Q_FUNC_INFO << "Reporting:" << m_playlistguid; tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "Reporting:" << m_playlistguid;
if ( !source() || !source()->dbCollection() ) if ( !source() || !source()->dbCollection() )
{ {
Q_ASSERT( false ); Q_ASSERT( false );
return; return;
} }
// we arent sure which it is, but it can't be more than one. so try both dynplaylist_ptr playlist = DynamicPlaylist::get( m_playlistguid );
dynplaylist_ptr playlist = source()->dbCollection()->autoPlaylist( m_playlistguid );
if ( !playlist )
playlist = source()->dbCollection()->station( m_playlistguid );
if ( playlist ) if ( playlist )
{ {
playlist->reportDeleted( playlist ); playlist->reportDeleted( playlist );

View File

@@ -58,18 +58,14 @@ DatabaseCommand_RenamePlaylist::exec( DatabaseImpl* lib )
void void
DatabaseCommand_RenamePlaylist::postCommitHook() DatabaseCommand_RenamePlaylist::postCommitHook()
{ {
playlist_ptr playlist = source()->dbCollection()->playlist( m_playlistguid ); playlist_ptr playlist = Playlist::get( m_playlistguid );
// fallback, check for auto and stations too
if( playlist.isNull() )
playlist = source()->dbCollection()->autoPlaylist( m_playlistguid );
if( playlist.isNull() )
playlist = source()->dbCollection()->station( m_playlistguid );
Q_ASSERT( !playlist.isNull() ); Q_ASSERT( !playlist.isNull() );
if ( !playlist )
return;
qDebug() << "Renaming old playlist" << playlist->title() << "to" << m_playlistTitle << m_playlistguid; tDebug() << "Renaming playlist" << playlist->title() << "to" << m_playlistTitle << m_playlistguid;
playlist->setTitle( m_playlistTitle ); playlist->setTitle( m_playlistTitle );
if( source()->isLocal() ) if ( source()->isLocal() )
Servent::instance()->triggerDBSync(); Servent::instance()->triggerDBSync();
} }

View File

@@ -95,16 +95,7 @@ RecentPlaylistsModel::playlistsLoaded( const QList<DatabaseCommand_LoadAllSorted
DatabaseCommand_LoadAllSortedPlaylists::SourcePlaylistPair plPair; DatabaseCommand_LoadAllSortedPlaylists::SourcePlaylistPair plPair;
foreach ( plPair, playlistGuids ) foreach ( plPair, playlistGuids )
{ {
source_ptr source = SourceList::instance()->get( plPair.first ); const playlist_ptr& pl = Playlist::get( plPair.second );
if ( !source )
continue;
playlist_ptr pl = source->dbCollection()->playlist( plPair.second );
if ( !pl )
pl = source->dbCollection()->autoPlaylist( plPair.second );
if ( !pl )
pl = source->dbCollection()->station( plPair.second );
if ( !pl ) if ( !pl )
{ {
tDebug() << "ERROR: Found a playlist that is not associated with any source:" << plPair.first << plPair.second; tDebug() << "ERROR: Found a playlist that is not associated with any source:" << plPair.first << plPair.second;

View File

@@ -227,18 +227,10 @@ RecentlyPlayedPlaylistsModel::rowCount( const QModelIndex& ) const
void void
RecentlyPlayedPlaylistsModel::plAdded( const QString& plguid, int sId ) RecentlyPlayedPlaylistsModel::plAdded( const QString& plguid, int sourceId )
{ {
source_ptr source = SourceList::instance()->get( sId ); Q_UNUSED( sourceId );
if ( !source ) const playlist_ptr& pl = Playlist::get( plguid );
return;
playlist_ptr pl = source->dbCollection()->playlist( plguid );
if ( !pl )
pl = source->dbCollection()->autoPlaylist( plguid );
if ( !pl )
pl = source->dbCollection()->station( plguid );
if ( !pl ) if ( !pl )
return; return;

View File

@@ -54,7 +54,7 @@ private slots:
void onPlaylistsRemoved( QList<Tomahawk::playlist_ptr> ); void onPlaylistsRemoved( QList<Tomahawk::playlist_ptr> );
void loadFromSettings(); void loadFromSettings();
void plAdded( const QString& plid, int sid ); void plAdded( const QString& plguid, int sourceId );
void playlistRevisionLoaded(); void playlistRevisionLoaded();
private: private: