1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-20 15:59:42 +01:00

Don't update playlist if no tracks have changed

This commit is contained in:
Leo Franchi 2012-03-04 21:54:30 -05:00
parent 6b68598d1d
commit 292d8c9530
4 changed files with 15 additions and 4 deletions

View File

@ -71,7 +71,11 @@ XspfUpdater::playlistLoaded()
foreach ( const plentry_ptr ple, playlist()->entries() )
tracks << ple->query();
QList< query_ptr > mergedTracks = TomahawkUtils::mergePlaylistChanges( tracks, loader->entries() );
bool changed = false;
QList< query_ptr > mergedTracks = TomahawkUtils::mergePlaylistChanges( tracks, loader->entries(), changed );
if ( !changed )
return;
QList<Tomahawk::plentry_ptr> el = playlist()->entriesFromQueries( mergedTracks, true );
playlist()->createNewRevision( uuid(), playlist()->currentrevision(), el );

View File

@ -104,7 +104,11 @@ CustomPlaylistView::generateTracks()
void
CustomPlaylistView::tracksGenerated( QList< query_ptr > tracks )
{
QList< query_ptr > newTracks = TomahawkUtils::mergePlaylistChanges( m_model->queries(), tracks );
bool changed = false;
QList< query_ptr > newTracks = TomahawkUtils::mergePlaylistChanges( m_model->queries(), tracks, changed);
if ( !changed )
return;
m_model->clear();
m_model->append( newTracks );

View File

@ -533,10 +533,12 @@ newerVersion( const QString& oldVersion, const QString& newVersion )
QList< Tomahawk::query_ptr >
mergePlaylistChanges( const QList< Tomahawk::query_ptr >& orig, const QList< Tomahawk::query_ptr >& newTracks )
mergePlaylistChanges( const QList< Tomahawk::query_ptr >& orig, const QList< Tomahawk::query_ptr >& newTracks, bool& changed )
{
int sameCount = 0;
QList< Tomahawk::query_ptr > tosave = newTracks;
changed = false;
foreach ( const Tomahawk::query_ptr& newquery, newTracks )
{
foreach ( const Tomahawk::query_ptr& oldq, orig )
@ -558,6 +560,7 @@ mergePlaylistChanges( const QList< Tomahawk::query_ptr >& orig, const QList< Tom
if ( orig.size() == newTracks.size() && sameCount == orig.size() )
return orig;
changed = true;
return tosave;
}

View File

@ -110,7 +110,7 @@ namespace TomahawkUtils
*
* \return true if some changes were made, false if the new tracks are the same as the current tracks in \param orig
*/
DLLEXPORT QList< Tomahawk::query_ptr > mergePlaylistChanges( const QList< Tomahawk::query_ptr >& orig, const QList< Tomahawk::query_ptr >& newTracks );
DLLEXPORT QList< Tomahawk::query_ptr > mergePlaylistChanges( const QList< Tomahawk::query_ptr >& orig, const QList< Tomahawk::query_ptr >& newTracks, bool& changed );
DLLEXPORT void crash();
}