summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--amarok/src/playlist.cpp43
1 files changed, 22 insertions, 21 deletions
diff --git a/amarok/src/playlist.cpp b/amarok/src/playlist.cpp
index eda08281..bd173b58 100644
--- a/amarok/src/playlist.cpp
+++ b/amarok/src/playlist.cpp
@@ -3476,34 +3476,35 @@ Playlist::deleteSelectedFiles() //SLOT
void
Playlist::removeDuplicates() //SLOT
{
- // Remove dead entries:
-
- for( TQListViewItemIterator it( this ); it.current(); ) {
- PlaylistItem* item = static_cast<PlaylistItem*>( *it );
+ // Remove dead entries
+ for (TQListViewItemIterator it(this); it.current(); )
+ {
+ PlaylistItem *item = static_cast<PlaylistItem*>(*it);
const KURL url = item->url();
- if ( url.isLocalFile() && !TQFile::exists( url.path() ) ) {
- removeItem( item );
+ if (url.isLocalFile() && !TQFile::exists(url.path()))
+ {
+ removeItem(item);
++it;
delete item;
}
else ++it;
}
- // Remove dupes:
-
- TQPtrList<PlaylistItem> list;
- for( TQListViewItemIterator it( this ); it.current(); ++it )
- list.prepend( static_cast<PlaylistItem*>( it.current() ) );
-
- list.sort();
-
- TQPtrListIterator<PlaylistItem> it( list );
- PlaylistItem *item;
- while( (item = it.current()) ) {
- const KURL &compare = item->url();
- ++it;
- if ( *it && compare == it.current()->url() ) {
- removeItem( item );
+ // Remove duplicates
+ TQMap<KURL, bool> existingItems;
+ for (TQListViewItemIterator it(this); it.current(); )
+ {
+ PlaylistItem *item = static_cast<PlaylistItem*>(*it);
+ const KURL &itemUrl = item->url();
+ if (!existingItems.contains(itemUrl))
+ {
+ existingItems[itemUrl] = true;
+ ++it;
+ }
+ else
+ {
+ removeItem(item);
+ ++it;
delete item;
}
}