summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichele Calgaro <[email protected]>2023-06-21 14:18:10 +0900
committerMichele Calgaro <[email protected]>2023-06-21 14:19:21 +0900
commitbcd8d83ee713bd3aa685c10dc260e2f8bb0522be (patch)
tree2034389c35af1812b463db069f45ffa513db6c1a
parentb04099ffabde61c7537289148f6a629ef1bed264 (diff)
downloadamarok-bcd8d83ee713bd3aa685c10dc260e2f8bb0522be.tar.gz
amarok-bcd8d83ee713bd3aa685c10dc260e2f8bb0522be.zip
Fix functionality broken by commit 1c3e0630.
Signed-off-by: Michele Calgaro <[email protected]>
-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;
}
}