2
2
* playlist.m: MacOS X interface module
3
3
*****************************************************************************
4
4
* Copyright (C) 2002-2012 VLC authors and VideoLAN
5
* $Id: 323ad29cab2c6499892a19f155893e92f76a775e $
5
* $Id: bfbcb81a5e9e7a41d43a8c236e92807093514b6f $
7
7
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
8
8
* Derk-Jan Hartman <hartman at videola/n dot org>
1552
1552
/* Drag & Drop inside the playlist */
1553
1553
if( [[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] )
1555
int i_row, i_removed_from_node = 0;
1556
1556
playlist_item_t *p_new_parent, *p_item = NULL;
1557
1557
NSArray *o_all_items = [o_nodes_array arrayByAddingObjectsFromArray: o_items_array];
1558
1558
/* If the item is to be dropped as root item of the outline, make it a
1578
1578
NSUInteger count = [o_all_items count];
1582
playlist_item_t **pp_items = (playlist_item_t **)calloc( count, sizeof( playlist_item_t* ) );
1579
1588
for( NSUInteger i = 0; i < count; i++ )
1581
playlist_item_t *p_old_parent = NULL;
1582
int i_old_index = 0;
1584
1590
p_item = [[o_all_items objectAtIndex:i] pointerValue];
1585
p_old_parent = p_item->p_parent;
1588
/* We may need the old index later */
1589
if( p_new_parent == p_old_parent )
1591
for( NSInteger j = 0; j < p_old_parent->i_children; j++ )
1593
if( p_old_parent->pp_children[j] == p_item )
1592
pp_items[j++] = p_item;
1602
// Actually detach the item from the old position
1603
if( playlist_NodeRemoveItem( p_playlist, p_item, p_old_parent ) ==
1607
/* Calculate the new index */
1610
/* If we move the item in the same node, we need to take into
1611
account that one item will be deleted */
1614
if ((p_new_parent == p_old_parent && i_old_index < index + (int)i) )
1616
i_removed_from_node++;
1618
i_new_index = index + i - i_removed_from_node;
1620
// Reattach the item to the new position
1621
playlist_NodeInsert( p_playlist, p_item, p_new_parent, i_new_index );
1595
if( j == 0 || playlist_TreeMoveMany( p_playlist, j, pp_items, p_new_parent, index ) != VLC_SUCCESS )
1625
1605
[self playlistUpdated];
1626
1606
i_row = [o_outline_view rowForItem:[o_outline_dict objectForKey:[NSString stringWithFormat: @"%p", [[o_all_items objectAtIndex: 0] pointerValue]]]];