Fix functionality broken by commit 1c3e0630.

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

@ -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;
}
}

Loading…
Cancel
Save