Members of the KDE Community are recommended to subscribe to the kde-community mailing list at to allow them to participate in important discussions and receive other important announcements

Commit 894d85d0 authored by Scott Wheeler's avatar Scott Wheeler

Much smarter job of handling updating of search playlists. It now only

adds the new matches and only clears the items which now don't match rather
than the old brute-force, "clear everything, show all matches".  This also
fixes #63908 for me.

svn path=/trunk/kdemultimedia/juk/; revision=249599
parent ae124807
......@@ -25,6 +25,7 @@
#include <qfileinfo.h>
#include <qobject.h>
#include <qptrstack.h>
#include <qptrdict.h>
#include <qvaluevector.h>
#include "musicbrainzquery.h"
......@@ -54,8 +55,10 @@ typedef QValueList<PlaylistItem *> PlaylistItemList;
class PlaylistItem : public QObject, public KListViewItem
friend class Playlist;
friend class SearchPlaylist;
friend class CollectionList;
friend class QPtrList<PlaylistItem>;
friend class QPtrDict<PlaylistItem>;
* Needs access to the destuctor, even though the destructor isn't used by QPtrStack.
......@@ -17,8 +17,11 @@
#include <kdebug.h>
#include <qptrdict.h>
#include "searchplaylist.h"
#include "playlistitem.h"
#include "collectionlist.h"
// public methods
......@@ -40,9 +43,31 @@ void SearchPlaylist::updateItems()
// Here we don't simply use "clear" since that would involve a call to
// items() which would in turn call this method...
PlaylistItemList l = Playlist::items();
QPtrDict<PlaylistItem> oldItems(503);
for(PlaylistItemList::ConstIterator it = l.begin(); it != l.end(); ++it)
oldItems.insert((*it)->collectionItem(), *it);;
PlaylistItemList matched = m_search.matchedItems();
PlaylistItemList newItems;
for(PlaylistItemList::ConstIterator it = matched.begin(); it != matched.end(); ++it) {
// kdDebug(65432) << k_funcinfo << "newItems.size() == " << newItems.size() << endl;
for(QPtrDictIterator<PlaylistItem> it(oldItems); it.current(); ++it)
clearItem(it.current(), false);
if(!oldItems.isEmpty() && newItems.isEmpty())
emit signalCountChanged(this);
......@@ -36,7 +36,7 @@ protected:
* Runs the search to update the current items.
void updateItems();
virtual void updateItems();
PlaylistSearch m_search;
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment