Commit 23235a29 authored by Benjamin Pracht's avatar Benjamin Pracht

* Back to the hack for the isItem: inNode function, since this is several...

* Back to the hack for the isItem: inNode function, since this is several orders  faster than the high level functions provided by Cocoa... Playlist behaves corectly on big lists again...
* Fixes a bug in drag and drop

parent 3d0810e9
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
* $Id$ * $Id$
* *
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net> * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* Derk-Jan Hartman <hartman at videolan dot org> * Derk-Jan Hartman <hartman at videola/n dot org>
* Benjamin Pracht <bigben at videolab dot org> * Benjamin Pracht <bigben at videolab dot org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
...@@ -378,7 +378,13 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/ ...@@ -378,7 +378,13 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
vlc_object_release(p_playlist); vlc_object_release(p_playlist);
} }
- (BOOL)isItem: (playlist_item_t *)p_item inNode: (playlist_item_t *)p_node /* Check if p_item is a child of p_node recursively. We need to check the item existence first since OSX sometimes tries to redraw items that have been
deleted. We don't do it when not required since this verification takes
quite a long time on big playlists (yes, pretty hacky). */
- (BOOL)isItem: (playlist_item_t *)p_item
inNode: (playlist_item_t *)p_node
checkItemExistence:(BOOL)b_check
{ {
playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST, playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE ); FIND_ANYWHERE );
...@@ -403,16 +409,15 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/ ...@@ -403,16 +409,15 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
if ( p_temp_item ) if ( p_temp_item )
{ {
// int i; int i;
vlc_mutex_lock( &p_playlist->object_lock ); vlc_mutex_lock( &p_playlist->object_lock );
// Let's check if we can do without that if( b_check )
#if 0 {
/* Since outlineView: willDisplayCell:... may call this function with /* Since outlineView: willDisplayCell:... may call this function with
p_items that don't exist anymore, first check if the item is still p_items that don't exist anymore, first check if the item is still
in the playlist. Any cleaner solution welcomed. */ in the playlist. Any cleaner solution welcomed. */
for( i = 0; i < p_playlist->i_all_size; i++ )
{ {
if( p_playlist->pp_all_items[i] == p_item ) break; if( p_playlist->pp_all_items[i] == p_item ) break;
else if ( i == p_playlist->i_all_size - 1 ) else if ( i == p_playlist->i_all_size - 1 )
...@@ -422,7 +427,8 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/ ...@@ -422,7 +427,8 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
return NO; return NO;
} }
} }
#endif }
while( p_temp_item->i_parents > 0 ) while( p_temp_item->i_parents > 0 )
{ {
p_temp_item = [self parentOfItem: p_temp_item]; p_temp_item = [self parentOfItem: p_temp_item];
...@@ -472,9 +478,10 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/ ...@@ -472,9 +478,10 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
if( j == i ) continue; if( j == i ) continue;
} }
if( [self isItem: [[o_items objectAtIndex:i] pointerValue] if( [self isItem: [[o_items objectAtIndex:i] pointerValue]
inNode: [[o_nodes objectAtIndex:j] pointerValue]] ) inNode: [[o_nodes objectAtIndex:j] pointerValue]
checkItemExistence: NO] )
{ {
[o_nodes removeObjectAtIndex:i]; [o_items removeObjectAtIndex:i];
/* We need to execute the next iteration with the same index /* We need to execute the next iteration with the same index
since the current item has been deleted */ since the current item has been deleted */
i--; i--;
...@@ -485,29 +492,6 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/ ...@@ -485,29 +492,6 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
} }
- (BOOL)isValueItem: (id)o_item inNode: (id)o_node
{
int i;
int i_total = [[o_outline_view dataSource] outlineView:o_outline_view
numberOfChildrenOfItem: o_node];
for( i = 0 ; i < i_total ; i++ )
{
id o_temp_item = [[o_outline_view dataSource] outlineView:
o_outline_view child:i ofItem: o_node];
if( [[o_outline_view dataSource] outlineView:o_outline_view
numberOfChildrenOfItem: o_temp_item] > 0 )
{
if( [self isValueItem: o_item inNode: o_temp_item] == YES )
return YES;
}
else if( [o_temp_item isEqual: o_item] )
{
return YES;
}
}
return NO;
}
- (IBAction)savePlaylist:(id)sender - (IBAction)savePlaylist:(id)sender
{ {
intf_thread_t * p_intf = VLCIntf; intf_thread_t * p_intf = VLCIntf;
...@@ -634,7 +618,8 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/ ...@@ -634,7 +618,8 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
{ {
if( p_playlist->status.i_status != PLAYLIST_STOPPED && if( p_playlist->status.i_status != PLAYLIST_STOPPED &&
[self isItem: p_playlist->status.p_item inNode: [self isItem: p_playlist->status.p_item inNode:
((playlist_item_t *)[o_item pointerValue])] == YES ) ((playlist_item_t *)[o_item pointerValue])
checkItemExistence: NO] == YES )
{ {
// if current item is in selected node and is playing then stop playlist // if current item is in selected node and is playing then stop playlist
playlist_Stop( p_playlist ); playlist_Stop( p_playlist );
...@@ -1196,8 +1181,9 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/ ...@@ -1196,8 +1181,9 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
o_playing_item = [o_outline_dict objectForKey: o_playing_item = [o_outline_dict objectForKey:
[NSString stringWithFormat:@"%p", p_playlist->status.p_item]]; [NSString stringWithFormat:@"%p", p_playlist->status.p_item]];
if( [self isValueItem: o_playing_item inNode: item] || if( [self isItem: [o_playing_item pointerValue] inNode:
[o_playing_item isEqual: item] ) [item pointerValue] checkItemExistence: YES]
|| [o_playing_item isEqual: item] )
{ {
[cell setFont: [NSFont boldSystemFontOfSize: 0]]; [cell setFont: [NSFont boldSystemFontOfSize: 0]];
} }
...@@ -1441,7 +1427,7 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/ ...@@ -1441,7 +1427,7 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
/* Refuse to move items that are not in the General Node /* Refuse to move items that are not in the General Node
(Service Discovery) */ (Service Discovery) */
if( ![self isItem: [o_item pointerValue] inNode: if( ![self isItem: [o_item pointerValue] inNode:
p_playlist->p_general] ) p_playlist->p_general checkItemExistence: NO])
{ {
vlc_object_release(p_playlist); vlc_object_release(p_playlist);
return NO; return NO;
...@@ -1515,8 +1501,8 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/ ...@@ -1515,8 +1501,8 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
/* We refuse to drop an item in anything else than a child of the General /* We refuse to drop an item in anything else than a child of the General
Node. We still accept items that would be root nodes of the outlineview Node. We still accept items that would be root nodes of the outlineview
however, to allow drop in an empty playlist.*/ however, to allow drop in an empty playlist.*/
if( !([self isItem: [item pointerValue] inNode: p_playlist->p_general] || if( !([self isItem: [item pointerValue] inNode: p_playlist->p_general
item == nil) ) checkItemExistence: NO] || item == nil) )
{ {
vlc_object_release(p_playlist); vlc_object_release(p_playlist);
return NSDragOperationNone; return NSDragOperationNone;
...@@ -1530,7 +1516,8 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/ ...@@ -1530,7 +1516,8 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
{ {
/* We refuse to Drop in a child of an item we are moving */ /* We refuse to Drop in a child of an item we are moving */
if( [self isItem: [item pointerValue] inNode: if( [self isItem: [item pointerValue] inNode:
[[o_nodes_array objectAtIndex: i] pointerValue]] ) [[o_nodes_array objectAtIndex: i] pointerValue]
checkItemExistence: NO] )
{ {
vlc_object_release(p_playlist); vlc_object_release(p_playlist);
return NSDragOperationNone; return NSDragOperationNone;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment