From 4392e348824986409fae70c1552fb81a6be663ab Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Sat, 24 Mar 2012 16:22:27 -0400 Subject: [PATCH] Notify of tracks inserted also when dropped on sidebar item --- src/libtomahawk/playlist.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/libtomahawk/playlist.cpp b/src/libtomahawk/playlist.cpp index c94c4f4b0..8ba8e5670 100644 --- a/src/libtomahawk/playlist.cpp +++ b/src/libtomahawk/playlist.cpp @@ -515,8 +515,18 @@ Playlist::addEntries( const QList& queries, const QString& oldrev ) { QList el = entriesFromQueries( queries ); + const int prevSize = m_entries.size(); + QString newrev = uuid(); createNewRevision( newrev, oldrev, el ); + + + // We are appending at end, so notify listeners. + // PlaylistModel also emits during appends, but since we call + // createNewRevision, it reloads instead of appends. + const QList added = el.mid( prevSize ); + qDebug() << "Playlist got" << queries.size() << "tracks added, emitting tracksInserted with:" << added.size() << "at pos:" << prevSize - 1; + emit tracksInserted( added, prevSize ); } void @@ -536,8 +546,15 @@ Playlist::insertEntries( const QList< query_ptr >& queries, const int position, for ( QList< plentry_ptr >::iterator iter = toInsert.end(); iter != toInsert.begin(); iter-- ) entries.insert( position, *iter ); + const int prevSize = m_entries.size(); qDebug() << "Done inserting playlist entries in the middle of the playlist! Committing..."; createNewRevision( uuid(), oldrev, entries ); + + // We are appending at end, so notify listeners. + // PlaylistModel also emits during appends, but since we call + // createNewRevision, it reloads instead of appends. + qDebug() << "Playlist got" << toInsert.size() << "tracks added, emitting tracksInserted at pos:" << position; + emit tracksInserted( toInsert, position ); }