- if( !p_target || !p_src )
- {
- PL_UNLOCK;
- return false;
- }
- if( p_target->i_children == -1 ) /* A leaf */
- {
- PLItem *parentItem = targetItem->parent();
- assert( parentItem );
- playlist_item_t *p_parent =
- playlist_ItemGetById( p_playlist, parentItem->i_id,
- VLC_TRUE );
- if( !p_parent )
- {
- PL_UNLOCK;
- return false;
- }
- for( i = 0 ; i< p_parent->i_children ; i++ )
- if( p_parent->pp_children[i] == p_target ) break;
- playlist_TreeMove( p_playlist, p_src, p_parent, i );
- newParentItem = parentItem;
- }
- else
- {
- /* \todo: if we drop on a top-level node, use copy instead ? */
- playlist_TreeMove( p_playlist, p_src, p_target, 0 );
- i = 0;
- newParentItem = targetItem;
- }
- /* Remove from source */
- PLItem *srcItem = FindById( rootItem, p_src->i_id );
- // We dropped on the source selector. Ask the dialog to forward
- // to the main view
- if( !srcItem )
+ 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;
+ pos = playlist_NodeAddCopy( p_playlist, p_item, p_parent, pos );
+ }
+
+ PL_UNLOCK;
+}
+
+void PLModel::dropMove( const PlMimeData * plMimeData, PLItem *target, int row )
+{
+ QList<input_item_t*> inputItems = plMimeData->inputItems();
+ QList<PLItem*> model_items;
+ playlist_item_t *pp_items[inputItems.size()];
+
+ PL_LOCK;
+
+ playlist_item_t *p_parent =
+ playlist_ItemGetByInput( p_playlist, target->p_input );
+
+ if( !p_parent || row > p_parent->i_children )
+ {
+ PL_UNLOCK; return;
+ }
+
+ int new_pos = row == -1 ? p_parent->i_children : row;
+ int model_pos = new_pos;
+ int i = 0;
+
+ foreach( input_item_t *p_input, inputItems )
+ {
+ playlist_item_t *p_item = playlist_ItemGetByInput( p_playlist, p_input );
+ if( !p_item ) continue;
+
+ PLItem *item = findByInput( rootItem, p_input->i_id );
+ if( !item ) continue;
+
+ /* Better not try to move a node into itself.
+ Abort the whole operation in that case,
+ because it is ambiguous. */
+ PLItem *climber = target;
+ while( climber )
+ {
+ if( climber == item )