1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-15 10:33:59 +02:00

fix recent playlists

This commit is contained in:
Leo Franchi
2011-05-02 23:05:59 -04:00
parent bc1ce656ae
commit 5b0ed433f5
2 changed files with 12 additions and 2 deletions

View File

@@ -27,10 +27,11 @@ using namespace Tomahawk;
WelcomePlaylistModel::WelcomePlaylistModel( QObject* parent )
: QAbstractListModel( parent )
, m_waitingForSome( true )
{
loadFromSettings();
connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), SLOT( loadFromSettings() ), Qt::QueuedConnection );
connect( SourceList::instance(), SIGNAL( sourceAdded( Tomahawk::source_ptr ) ), this, SLOT( onSourceAdded( Tomahawk::source_ptr ) ), Qt::QueuedConnection );
connect( TomahawkSettings::instance(), SIGNAL( recentlyPlayedPlaylistAdded( Tomahawk::playlist_ptr ) ), this, SLOT( plAdded( Tomahawk::playlist_ptr ) ) );
connect( AudioEngine::instance(),SIGNAL( playlistChanged( PlaylistInterface* ) ), this, SLOT( playlistChanged( PlaylistInterface* ) ), Qt::QueuedConnection );
@@ -40,8 +41,12 @@ WelcomePlaylistModel::WelcomePlaylistModel( QObject* parent )
void
WelcomePlaylistModel::loadFromSettings()
{
if( !m_waitingForSome )
return;
beginResetModel();
m_recplaylists.clear();
m_waitingForSome = false;
QStringList playlist_guids = TomahawkSettings::instance()->recentlyPlayedPlaylistGuids();
@@ -58,7 +63,8 @@ WelcomePlaylistModel::loadFromSettings()
if( !m_cached.contains( playlist_guids[i] ) )
m_cached[playlist_guids[i]] = pl;
}
} else
m_waitingForSome = true;
}
endResetModel();
@@ -66,6 +72,7 @@ WelcomePlaylistModel::loadFromSettings()
}
QVariant
WelcomePlaylistModel::data( const QModelIndex& index, int role ) const
{
@@ -107,6 +114,7 @@ WelcomePlaylistModel::data( const QModelIndex& index, int role ) const
void
WelcomePlaylistModel::onSourceAdded( const Tomahawk::source_ptr& source )
{
connect( source->collection().data(), SIGNAL( playlistsAdded( QList<Tomahawk::playlist_ptr> ) ), SLOT( loadFromSettings() ) );
connect( source->collection().data(), SIGNAL( playlistsDeleted( QList<Tomahawk::playlist_ptr> ) ), SLOT( onPlaylistsRemoved( QList<Tomahawk::playlist_ptr> ) ) );
}

View File

@@ -52,6 +52,8 @@ private:
QList< Tomahawk::playlist_ptr > m_recplaylists;
QHash< QString, Tomahawk::playlist_ptr > m_cached;
mutable QHash< Tomahawk::playlist_ptr, QString > m_artists;
bool m_waitingForSome;
};
#endif // WELCOMEPLAYLISTMODEL_H