mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-01 03:40:16 +02:00
Cache playlist guids to speed up reloading
This commit is contained in:
@@ -48,9 +48,17 @@ WelcomePlaylistModel::loadFromSettings()
|
|||||||
for( int i = playlist_guids.size() - 1; i >= 0; i-- )
|
for( int i = playlist_guids.size() - 1; i >= 0; i-- )
|
||||||
{
|
{
|
||||||
qDebug() << "loading playlist" << playlist_guids[i];
|
qDebug() << "loading playlist" << playlist_guids[i];
|
||||||
Tomahawk::playlist_ptr pl = Tomahawk::Playlist::load( playlist_guids[i] );
|
|
||||||
if ( !pl.isNull() )
|
playlist_ptr pl = m_cached.value( playlist_guids[i], playlist_ptr() );
|
||||||
|
if( pl.isNull() )
|
||||||
|
pl = Tomahawk::Playlist::load( playlist_guids[i] );
|
||||||
|
|
||||||
|
if ( !pl.isNull() ) {
|
||||||
m_recplaylists << pl;
|
m_recplaylists << pl;
|
||||||
|
|
||||||
|
if( !m_cached.contains( playlist_guids[i] ) )
|
||||||
|
m_cached[playlist_guids[i]] = pl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
endResetModel();
|
endResetModel();
|
||||||
|
|
||||||
@@ -108,6 +116,8 @@ WelcomePlaylistModel::onPlaylistsRemoved( QList< playlist_ptr > playlists )
|
|||||||
foreach( const playlist_ptr& pl, playlists ) {
|
foreach( const playlist_ptr& pl, playlists ) {
|
||||||
if( m_recplaylists.contains( pl ) ) {
|
if( m_recplaylists.contains( pl ) ) {
|
||||||
m_artists.remove( pl );
|
m_artists.remove( pl );
|
||||||
|
m_cached.remove( pl->guid() );
|
||||||
|
|
||||||
int idx = m_recplaylists.indexOf( pl );
|
int idx = m_recplaylists.indexOf( pl );
|
||||||
beginRemoveRows( QModelIndex(), idx, idx );
|
beginRemoveRows( QModelIndex(), idx, idx );
|
||||||
m_recplaylists.removeAt( idx );
|
m_recplaylists.removeAt( idx );
|
||||||
|
@@ -50,6 +50,7 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QList< Tomahawk::playlist_ptr > m_recplaylists;
|
QList< Tomahawk::playlist_ptr > m_recplaylists;
|
||||||
|
QHash< QString, Tomahawk::playlist_ptr > m_cached;
|
||||||
mutable QHash< Tomahawk::playlist_ptr, QString > m_artists;
|
mutable QHash< Tomahawk::playlist_ptr, QString > m_artists;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user