Fix functionality broken by commit 1c3e0630.

Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
pull/39/head
Michele Calgaro 1 year ago
parent b04099ffab
commit bcd8d83ee7
Signed by: MicheleC
GPG Key ID: 2A75B7CA8ADED5CF

@ -3476,34 +3476,35 @@ Playlist::deleteSelectedFiles() //SLOT
void void
Playlist::removeDuplicates() //SLOT Playlist::removeDuplicates() //SLOT
{ {
// Remove dead entries: // Remove dead entries
for (TQListViewItemIterator it(this); it.current(); )
for( TQListViewItemIterator it( this ); it.current(); ) { {
PlaylistItem* item = static_cast<PlaylistItem*>( *it ); PlaylistItem *item = static_cast<PlaylistItem*>(*it);
const KURL url = item->url(); const KURL url = item->url();
if ( url.isLocalFile() && !TQFile::exists( url.path() ) ) { if (url.isLocalFile() && !TQFile::exists(url.path()))
removeItem( item ); {
removeItem(item);
++it; ++it;
delete item; delete item;
} }
else ++it; else ++it;
} }
// Remove dupes: // Remove duplicates
TQMap<KURL, bool> existingItems;
TQPtrList<PlaylistItem> list; for (TQListViewItemIterator it(this); it.current(); )
for( TQListViewItemIterator it( this ); it.current(); ++it ) {
list.prepend( static_cast<PlaylistItem*>( it.current() ) ); PlaylistItem *item = static_cast<PlaylistItem*>(*it);
const KURL &itemUrl = item->url();
list.sort(); if (!existingItems.contains(itemUrl))
{
TQPtrListIterator<PlaylistItem> it( list ); existingItems[itemUrl] = true;
PlaylistItem *item; ++it;
while( (item = it.current()) ) { }
const KURL &compare = item->url(); else
{
removeItem(item);
++it; ++it;
if ( *it && compare == it.current()->url() ) {
removeItem( item );
delete item; delete item;
} }
} }

Loading…
Cancel
Save