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:
@@ -27,10 +27,11 @@ using namespace Tomahawk;
|
|||||||
|
|
||||||
WelcomePlaylistModel::WelcomePlaylistModel( QObject* parent )
|
WelcomePlaylistModel::WelcomePlaylistModel( QObject* parent )
|
||||||
: QAbstractListModel( parent )
|
: QAbstractListModel( parent )
|
||||||
|
, m_waitingForSome( true )
|
||||||
{
|
{
|
||||||
loadFromSettings();
|
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( 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 );
|
connect( AudioEngine::instance(),SIGNAL( playlistChanged( PlaylistInterface* ) ), this, SLOT( playlistChanged( PlaylistInterface* ) ), Qt::QueuedConnection );
|
||||||
|
|
||||||
@@ -40,8 +41,12 @@ WelcomePlaylistModel::WelcomePlaylistModel( QObject* parent )
|
|||||||
void
|
void
|
||||||
WelcomePlaylistModel::loadFromSettings()
|
WelcomePlaylistModel::loadFromSettings()
|
||||||
{
|
{
|
||||||
|
if( !m_waitingForSome )
|
||||||
|
return;
|
||||||
|
|
||||||
beginResetModel();
|
beginResetModel();
|
||||||
m_recplaylists.clear();
|
m_recplaylists.clear();
|
||||||
|
m_waitingForSome = false;
|
||||||
|
|
||||||
QStringList playlist_guids = TomahawkSettings::instance()->recentlyPlayedPlaylistGuids();
|
QStringList playlist_guids = TomahawkSettings::instance()->recentlyPlayedPlaylistGuids();
|
||||||
|
|
||||||
@@ -58,7 +63,8 @@ WelcomePlaylistModel::loadFromSettings()
|
|||||||
|
|
||||||
if( !m_cached.contains( playlist_guids[i] ) )
|
if( !m_cached.contains( playlist_guids[i] ) )
|
||||||
m_cached[playlist_guids[i]] = pl;
|
m_cached[playlist_guids[i]] = pl;
|
||||||
}
|
} else
|
||||||
|
m_waitingForSome = true;
|
||||||
}
|
}
|
||||||
endResetModel();
|
endResetModel();
|
||||||
|
|
||||||
@@ -66,6 +72,7 @@ WelcomePlaylistModel::loadFromSettings()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
QVariant
|
QVariant
|
||||||
WelcomePlaylistModel::data( const QModelIndex& index, int role ) const
|
WelcomePlaylistModel::data( const QModelIndex& index, int role ) const
|
||||||
{
|
{
|
||||||
@@ -107,6 +114,7 @@ WelcomePlaylistModel::data( const QModelIndex& index, int role ) const
|
|||||||
void
|
void
|
||||||
WelcomePlaylistModel::onSourceAdded( const Tomahawk::source_ptr& source )
|
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> ) ) );
|
connect( source->collection().data(), SIGNAL( playlistsDeleted( QList<Tomahawk::playlist_ptr> ) ), SLOT( onPlaylistsRemoved( QList<Tomahawk::playlist_ptr> ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -52,6 +52,8 @@ private:
|
|||||||
QList< Tomahawk::playlist_ptr > m_recplaylists;
|
QList< Tomahawk::playlist_ptr > m_recplaylists;
|
||||||
QHash< QString, Tomahawk::playlist_ptr > m_cached;
|
QHash< QString, Tomahawk::playlist_ptr > m_cached;
|
||||||
mutable QHash< Tomahawk::playlist_ptr, QString > m_artists;
|
mutable QHash< Tomahawk::playlist_ptr, QString > m_artists;
|
||||||
|
|
||||||
|
bool m_waitingForSome;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // WELCOMEPLAYLISTMODEL_H
|
#endif // WELCOMEPLAYLISTMODEL_H
|
||||||
|
Reference in New Issue
Block a user