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