Commit 5d3edb82 authored by bigben's avatar bigben

Implements sorting of the current node from context menu

parent c5d68965
......@@ -395,6 +395,8 @@
playItem = id;
searchItem = id;
selectAll = id;
sortNodeByAuthor = id;
sortNodeByName = id;
};
CLASS = VLCPlaylist;
LANGUAGE = ObjC;
......@@ -407,6 +409,8 @@
"o_mi_play" = id;
"o_mi_save_playlist" = id;
"o_mi_selectall" = id;
"o_mi_sort_author" = id;
"o_mi_sort_name" = id;
"o_outline_view" = id;
"o_random_ckb" = id;
"o_search_field" = id;
......
......@@ -3,7 +3,7 @@
<plist version="1.0">
<dict>
<key>IBDocumentLocation</key>
<string>94 104 505 517 0 0 1024 746 </string>
<string>230 -84 505 517 0 0 1024 746 </string>
<key>IBEditorPositions</key>
<dict>
<key>1617</key>
......@@ -13,7 +13,7 @@
<key>29</key>
<string>84 667 419 44 0 0 1024 746 </string>
<key>915</key>
<string>620 326 100 130 0 0 1024 746 </string>
<string>731 416 165 180 0 0 1024 746 </string>
</dict>
<key>IBFramework Version</key>
<string>364.0</string>
......
......@@ -52,6 +52,8 @@
IBOutlet id o_mi_delete;
IBOutlet id o_mi_info;
IBOutlet id o_mi_selectall;
IBOutlet id o_mi_sort_name;
IBOutlet id o_mi_sort_author;
NSImage *o_descendingSortingImage;
NSImage *o_ascendingSortingImage;
......@@ -68,10 +70,13 @@
- (NSMenu *)menuForEvent:(NSEvent *)o_event;
- (void)playlistUpdated;
- (void)sortNode:(int)i_mode;
- (IBAction)playItem:(id)sender;
- (IBAction)deleteItem:(id)sender;
- (IBAction)selectAll:(id)sender;
- (IBAction)sortNodeByName:(id)sender;
- (IBAction)sortNodeByAuthor:(id)sender;
- (void)appendArray:(NSArray*)o_array atPos:(int)i_position enqueue:(BOOL)b_enqueue;
......
......@@ -152,6 +152,8 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
[o_mi_delete setTitle: _NS("Delete")];
[o_mi_selectall setTitle: _NS("Select All")];
[o_mi_info setTitle: _NS("Properties")];
[o_mi_sort_name setTitle: _NS("Sort Node by Name")];
[o_mi_sort_author setTitle: _NS("Sort Node by Author")];
[[o_tc_name headerCell] setStringValue:_NS("Name")];
[[o_tc_author headerCell] setStringValue:_NS("Author")];
[[o_tc_duration headerCell] setStringValue:_NS("Duration")];
......@@ -318,6 +320,65 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
}
}
- (IBAction)sortNodeByName:(id)sender
{
[self sortNode: SORT_TITLE];
}
- (IBAction)sortNodeByAuthor:(id)sender
{
[self sortNode: SORT_AUTHOR];
}
- (void)sortNode:(int)i_mode
{
playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
playlist_item_t * p_item;
if (p_playlist == NULL)
{
return;
}
if ([o_outline_view selectedRow] > -1)
{
p_item = [[o_outline_view itemAtRow: [o_outline_view selectedRow]]
pointerValue];
}
else
/*If no item is selected, sort the whole playlist*/
{
playlist_view_t * p_view = playlist_ViewFind( p_playlist, VIEW_SIMPLE );
p_item = p_view->p_root;
}
if (p_item->i_children > -1)
{
vlc_mutex_lock(&p_playlist->object_lock );
playlist_RecursiveNodeSort( p_playlist, p_item, i_mode, ORDER_NORMAL );
vlc_mutex_unlock(&p_playlist->object_lock );
}
else
{
int i;
for (i = 0 ; i < p_item->i_parents ; i++)
{
if (p_item->pp_parents[i]->i_view == VIEW_SIMPLE)
{
vlc_mutex_lock(&p_playlist->object_lock );
playlist_RecursiveNodeSort( p_playlist,
p_item->pp_parents[i]->p_parent, i_mode, ORDER_NORMAL );
vlc_mutex_unlock(&p_playlist->object_lock );
break;
}
}
}
vlc_object_release(p_playlist);
[self playlistUpdated];
}
- (void)appendArray:(NSArray*)o_array atPos:(int)i_position enqueue:(BOOL)b_enqueue
{
int i_item;
......
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