+ /* Drag & Drop inside the playlist */
+ if( [[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] )
+ {
+ int i_row;
+ unsigned int i;
+ playlist_item_t *p_new_parent, *p_item = NULL;
+ NSArray *o_all_items = [o_nodes_array arrayByAddingObjectsFromArray:
+ o_items_array];
+ /* If the item is to be dropped as root item of the outline, make it a
+ child of the General node.
+ Else, choose the proposed parent as parent. */
+ if( item == nil )
+ p_new_parent = p_playlist->p_general;
+ else
+ p_new_parent = [item pointerValue];
+
+ /* If the proposed parent is not a node, then use the parent node of
+ this item. */
+ if( p_new_parent->i_children <= 0 )
+ {
+ int j;
+ playlist_item_t *p_temp_item = p_new_parent;
+ p_new_parent = [self parentOfItem: p_new_parent];
+ if( !p_new_parent )
+ {
+ vlc_object_release(p_playlist);
+ return NO;
+ }
+ /* Calculate the position of the dropped item in this new parent:
+ following the first proposed parent. */
+ for( j = 0; j < p_new_parent->i_children; j++ )
+ {
+ if( p_new_parent->pp_children[j] == p_temp_item )
+ {
+ index = j;
+ break;
+ }
+ else if( j == p_new_parent->i_children - 1 )
+ index = -1;
+ }
+ }
+
+ for( i = 0; i < [o_all_items count]; i++ )
+ {
+ playlist_item_t *p_old_parent = NULL;
+ int i_old_index = 0;
+
+ p_item = [[o_all_items objectAtIndex:i] pointerValue];
+ p_old_parent = [self parentOfItem: p_item];
+ if( !p_old_parent )
+ continue;
+ /* We may need the old index later */
+ if( p_new_parent == p_old_parent )
+ {
+ int j;
+ for( j = 0; j < p_old_parent->i_children; j++ )
+ {
+ if( p_old_parent->pp_children[j] == p_item )
+ {
+ i_old_index = j;
+ break;
+ }
+ }
+ }
+
+
+ /* If we move the playing item in a different node or we move the
+ node containing the playing item in a different node, then stop
+ playback, or the playlist refuses to detach the item. */
+/* if( p_playlist->status.i_status != PLAYLIST_STOPPED &&
+ (( p_item == p_playlist->status.p_item &&
+ p_new_parent != p_old_parent) ||
+ ( p_item->i_children > 0 &&
+ [self isItem: p_playlist->status.p_item inNode:p_item] == YES))
+ {
+ playlist_Stop( p_playlist );
+ }*/
+ vlc_mutex_lock( &p_playlist->object_lock );
+ // Acually detach the item from the old position
+ if( playlist_NodeRemoveItem( p_playlist, p_item, p_old_parent ) ==
+ VLC_SUCCESS &&
+ playlist_NodeRemoveParent( p_playlist, p_item, p_old_parent ) ==
+ VLC_SUCCESS )
+ {
+ int i_new_index;
+ /* Calculate the new index */
+ if( index == -1 )
+ i_new_index = -1;
+ /* If we move the item in the same node, we need to take into
+ account that one item will be deleted */
+ else if((p_new_parent == p_old_parent &&
+ i_old_index < index + (int)i)
+ || p_new_parent == p_playlist->p_general || index == 0 )
+ i_new_index = index + i;
+ else
+ i_new_index = index + i + 1;
+ // Reattach the item to the new position
+ playlist_NodeInsert( p_playlist, i_current_view, p_item,
+ p_new_parent, i_new_index );
+ }
+ vlc_mutex_unlock( &p_playlist->object_lock );
+ }
+ [self playlistUpdated];
+ i_row = [o_outline_view rowForItem:[o_outline_dict
+ objectForKey:[NSString stringWithFormat: @"%p", p_item]]];
+
+ if( i_row == -1 )
+ {
+ i_row = [o_outline_view rowForItem:[o_outline_dict
+ objectForKey:[NSString stringWithFormat: @"%p", p_new_parent]]];
+ }
+
+ [o_outline_view deselectAll: self];
+ [o_outline_view selectRow: i_row byExtendingSelection: NO];
+ [o_outline_view scrollRowToVisible: i_row];
+
+ vlc_object_release(p_playlist);
+ return YES;
+ }
+
+ else if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )