Commit 09aae32b authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: implemented drag & drop from playlist to media library and vice verca....

macosx: implemented drag & drop from playlist to media library and vice verca. additionally, drag from SD to ML or PL is supported. (close #6044)
parent b378ac85
...@@ -22,15 +22,15 @@ ...@@ -22,15 +22,15 @@
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs"> <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<integer value="4850"/> <integer value="4850"/>
<integer value="29"/> <integer value="2770"/>
<integer value="4596"/> <integer value="4596"/>
<integer value="4722"/>
<integer value="21"/>
<integer value="1617"/> <integer value="1617"/>
<integer value="2730"/> <integer value="29"/>
<integer value="4722"/>
<integer value="4948"/> <integer value="4948"/>
<integer value="2770"/>
<integer value="915"/> <integer value="915"/>
<integer value="2730"/>
<integer value="21"/>
</object> </object>
<object class="NSArray" key="IBDocument.PluginDependencies"> <object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
<bool key="EncodedWithXMLCoder">YES</bool> <bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSOutlineView" id="1064884668"> <object class="NSOutlineView" id="1064884668">
<reference key="NSNextResponder" ref="18556274"/> <reference key="NSNextResponder" ref="18556274"/>
<int key="NSvFlags">4354</int> <int key="NSvFlags">258</int>
<string key="NSFrameSize">{199, 272}</string> <string key="NSFrameSize">{199, 272}</string>
<reference key="NSSuperview" ref="18556274"/> <reference key="NSSuperview" ref="18556274"/>
<int key="NSViewLayerContentsRedrawPolicy">2</int> <int key="NSViewLayerContentsRedrawPolicy">2</int>
......
...@@ -446,6 +446,8 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -446,6 +446,8 @@ static VLCMainWindow *_o_sharedInstance = nil;
for (NSUInteger x = 0; x < i_sidebaritem_count; x++) for (NSUInteger x = 0; x < i_sidebaritem_count; x++)
[o_sidebar_view expandItem: [o_sidebaritems objectAtIndex: x] expandChildren: YES]; [o_sidebar_view expandItem: [o_sidebaritems objectAtIndex: x] expandChildren: YES];
[o_sidebar_view selectRowIndexes:[NSIndexSet indexSetWithIndex:1] byExtendingSelection:NO]; [o_sidebar_view selectRowIndexes:[NSIndexSet indexSetWithIndex:1] byExtendingSelection:NO];
[o_sidebar_view setDropItem:playlistItem dropChildIndex:NSOutlineViewDropOnItemIndex];
[o_sidebar_view registerForDraggedTypes:[NSArray arrayWithObjects: NSFilenamesPboardType, @"VLCPlaylistItemPboardType", nil]];
if( b_dark_interface ) if( b_dark_interface )
{ {
...@@ -2239,6 +2241,72 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -2239,6 +2241,72 @@ static VLCMainWindow *_o_sharedInstance = nil;
PL_UNLOCK; PL_UNLOCK;
} }
- (NSDragOperation)sourceList:(PXSourceList *)aSourceList validateDrop:(id <NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(NSInteger)index
{
if ([[item identifier] isEqualToString:@"playlist"] || [[item identifier] isEqualToString:@"medialibrary"] )
{
NSPasteboard *o_pasteboard = [info draggingPasteboard];
if ([[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] || [[o_pasteboard types] containsObject: NSFilenamesPboardType])
return NSDragOperationGeneric;
}
return NSDragOperationNone;
}
- (BOOL)sourceList:(PXSourceList *)aSourceList acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(NSInteger)index
{
NSPasteboard *o_pasteboard = [info draggingPasteboard];
playlist_t * p_playlist = pl_Get( VLCIntf );
playlist_item_t *p_node;
if ([[item identifier] isEqualToString:@"playlist"])
p_node = p_playlist->p_local_category;
else
p_node = p_playlist->p_ml_category;
if( [[o_pasteboard types] containsObject: NSFilenamesPboardType] )
{
NSArray *o_values = [[o_pasteboard propertyListForType: NSFilenamesPboardType] sortedArrayUsingSelector: @selector(caseInsensitiveCompare:)];
NSUInteger count = [o_values count];
NSMutableArray *o_array = [NSMutableArray arrayWithCapacity:count];
for( NSUInteger i = 0; i < count; i++)
{
NSDictionary *o_dic;
char *psz_uri = make_URI([[o_values objectAtIndex:i] UTF8String], NULL);
if( !psz_uri )
continue;
o_dic = [NSDictionary dictionaryWithObject:[NSString stringWithCString:psz_uri encoding:NSUTF8StringEncoding] forKey:@"ITEM_URL"];
free( psz_uri );
[o_array addObject: o_dic];
}
[[[VLCMain sharedInstance] playlist] appendNodeArray:o_array inNode: p_node atPos:-1 enqueue:YES];
return YES;
}
else if( [[o_pasteboard types] containsObject: @"VLCPlaylistItemPboardType"] )
{
NSArray * array = [[[VLCMain sharedInstance] playlist] draggedItems];
NSUInteger count = [array count];
playlist_item_t * p_item = NULL;
PL_LOCK;
for( NSUInteger i = 0; i < count; i++ )
{
p_item = [[array objectAtIndex:i] pointerValue];
if( !p_item ) continue;
playlist_NodeAddCopy( p_playlist, p_item, p_node, PLAYLIST_END );
}
PL_UNLOCK;
return YES;
}
return NO;
}
@end @end
@implementation VLCDetachedVideoWindow @implementation VLCDetachedVideoWindow
......
...@@ -148,6 +148,7 @@ ...@@ -148,6 +148,7 @@
- (IBAction)recursiveExpandNode:(id)sender; - (IBAction)recursiveExpandNode:(id)sender;
- (id)playingItem; - (id)playingItem;
- (NSArray *)draggedItems;
- (void)appendArray:(NSArray*)o_array atPos:(int)i_position enqueue:(BOOL)b_enqueue; - (void)appendArray:(NSArray*)o_array atPos:(int)i_position enqueue:(BOOL)b_enqueue;
- (void)appendNodeArray:(NSArray*)o_array inNode:(playlist_item_t *)p_node atPos:(int)i_position enqueue:(BOOL)b_enqueue; - (void)appendNodeArray:(NSArray*)o_array inNode:(playlist_item_t *)p_node atPos:(int)i_position enqueue:(BOOL)b_enqueue;
......
...@@ -1443,6 +1443,11 @@ ...@@ -1443,6 +1443,11 @@
return o_playing_item; return o_playing_item;
} }
- (NSArray *)draggedItems
{
return [[o_nodes_array arrayByAddingObjectsFromArray: o_items_array] retain];
}
@end @end
@implementation VLCPlaylist (NSOutlineViewDataSource) @implementation VLCPlaylist (NSOutlineViewDataSource)
...@@ -1471,15 +1476,6 @@ ...@@ -1471,15 +1476,6 @@
{ {
id o_item = [items objectAtIndex: i]; id o_item = [items objectAtIndex: i];
/* Refuse to move items that are not in the General Node
(Service Discovery) */
if( (![self isItem: [o_item pointerValue] inNode: p_playlist->p_local_category checkItemExistence: NO] &&
var_CreateGetBool( p_playlist, "media-library" ) && ![self isItem: [o_item pointerValue] inNode: p_playlist->p_ml_category checkItemExistence: NO]) ||
[o_item pointerValue] == p_playlist->p_local_category ||
[o_item pointerValue] == p_playlist->p_ml_category )
{
return NO;
}
/* Fill the items and nodes to move in 2 different arrays */ /* Fill the items and nodes to move in 2 different arrays */
if( ((playlist_item_t *)[o_item pointerValue])->i_children > 0 ) if( ((playlist_item_t *)[o_item pointerValue])->i_children > 0 )
[o_nodes_array addObject: o_item]; [o_nodes_array addObject: o_item];
...@@ -1563,8 +1559,7 @@ ...@@ -1563,8 +1559,7 @@
{ {
int i_row, i_removed_from_node = 0; int i_row, i_removed_from_node = 0;
playlist_item_t *p_new_parent, *p_item = NULL; playlist_item_t *p_new_parent, *p_item = NULL;
NSArray *o_all_items = [o_nodes_array arrayByAddingObjectsFromArray: NSArray *o_all_items = [o_nodes_array arrayByAddingObjectsFromArray: o_items_array];
o_items_array];
/* If the item is to be dropped as root item of the outline, make it a /* If the item is to be dropped as root item of the outline, make it a
child of the respective general node, if is either the pl or the ml child of the respective general node, if is either the pl or the ml
Else, choose the proposed parent as parent. */ Else, choose the proposed parent as parent. */
......
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