if( plMimeData )
{
if( copy )
- dropAppendCopy( plMimeData, getItem( parent ) );
+ dropAppendCopy( plMimeData, getItem( parent ), row );
else
dropMove( plMimeData, getItem( parent ), row );
}
return true;
}
-void PLModel::dropAppendCopy( const PlMimeData *plMimeData, PLItem *target )
+void PLModel::dropAppendCopy( const PlMimeData *plMimeData, PLItem *target, int pos )
{
PL_LOCK;
playlist_ItemGetByInput( p_playlist, target->p_input );
if( !p_parent ) return;
- bool b_flat = p_parent == p_playlist->p_playing &&
- !var_InheritBool( p_intf, "playlist-tree" );
+ if( pos == -1 ) pos = PLAYLIST_END;
QList<input_item_t*> inputItems = plMimeData->inputItems();
+
foreach( input_item_t* p_input, inputItems )
{
playlist_item_t *p_item = playlist_ItemGetByInput( p_playlist, p_input );
if( !p_item ) continue;
-
- recursiveAppendCopy( p_playlist, p_item, p_parent, b_flat );
+ pos = playlist_NodeAddCopy( p_playlist, p_item, p_parent, pos );
}
PL_UNLOCK;
}
-/* Must be entered WITH playlist lock! */
-void PLModel::recursiveAppendCopy( playlist_t *p_playlist, playlist_item_t *source,
- playlist_item_t *target, bool b_flat )
-{
- input_item_t *srcInput = source->p_input;
-
- if( !(source->i_children != -1 && b_flat) )
- {
- vlc_mutex_lock( &srcInput->lock );
- input_item_t *newInput =
- input_item_NewWithType( VLC_OBJECT(p_playlist),
- srcInput->psz_uri, srcInput->psz_name,
- srcInput->i_options, srcInput->ppsz_options,
- srcInput->optflagc, srcInput->i_duration,
- srcInput->i_type );
- vlc_mutex_unlock( &srcInput->lock );
-
- if( source->i_children != -1 )
- target = playlist_NodeCreate( p_playlist, newInput->psz_name, target, 0, newInput );
- else
- playlist_NodeAddInput( p_playlist, newInput, target,
- PLAYLIST_APPEND | PLAYLIST_SPREPARSE,
- PLAYLIST_END, pl_Locked );
- }
- for( int i = 0; i < source->i_children; i++ )
- recursiveAppendCopy( p_playlist, source->pp_children[i], target, b_flat );
-}
-
void PLModel::dropMove( const PlMimeData * plMimeData, PLItem *target, int row )
{
QList<input_item_t*> inputItems = plMimeData->inputItems();
/************************* Actions ******************************/
/**
- * Deletion, here we have to do a ugly slow hack as we retrieve the full
- * list of indexes to delete at once: when we delete a node and all of
- * its children, we need to update the list.
- * Todo: investigate whethere we can use ranges to be sure to delete all items?
+ * Lets not worry about nodes children, we do refersh anyway when
+ * core tells that playlist has changed, should give some more speed
*/
void PLModel::doDelete( QModelIndexList selected )
{
if( index.column() != 0 ) continue;
PLItem *item = getItem( index );
- if( item->children.size() )
- recurseDelete( item->children, &selected );
PL_LOCK;
playlist_DeleteFromInput( p_playlist, item->p_input, pl_Locked );
endInsertRows( );
}
PL_UNLOCK;
+ /* if we have popup item, try to make sure that you keep that item visible */
+ if( i_popup_item > -1 )
+ {
+ PLItem *popupitem = findById( rootItem, i_popup_item );
+ if( popupitem ) emit currentChanged( index( popupitem, 0 ) );
+ /* reset i_popup_item as we don't show it as selected anymore anyway */
+ i_popup_item = -1;
+ }
+ else if( currentIndex().isValid() ) emit currentChanged( currentIndex() );
}
void PLModel::search( const QString& search_text, const QModelIndex & idx, bool b_recursive )
i_popup_parent );
if( p_item )
{
- playlist_NodeCreate( p_playlist, qtu( name ), p_item, 0, NULL );
+ playlist_NodeCreate( p_playlist, qtu( name ), p_item, PLAYLIST_END, 0, NULL );
}
PL_UNLOCK;
}