Commit e0d08374 authored by zorglub's avatar zorglub
Browse files

Sort a node (alphabetically, all sub-nodes come first)

parent 0b62ce6d
......@@ -208,7 +208,8 @@ struct playlist_add_t
#define SORT_ID 0
#define SORT_TITLE 1
#define SORT_AUTHOR 2
#define SORT_TITLE_NODES_FIRST 2
#define SORT_AUTHOR 3
#define SORT_RANDOM 4
#define SORT_DURATION 5
......@@ -331,6 +332,7 @@ VLC_EXPORT( int, playlist_ItemAddOption, (playlist_item_t *, const char *) );
VLC_EXPORT( int, playlist_Sort, ( playlist_t *, int, int) );
VLC_EXPORT( int, playlist_Move, ( playlist_t *, int, int ) );
VLC_EXPORT( int, playlist_NodeGroup, ( playlist_t *, int,playlist_item_t *,playlist_item_t **,int, int, int ) );
VLC_EXPORT( int, playlist_NodeSort, ( playlist_t *, playlist_item_t *,int, int ) );
/* Load/Save */
VLC_EXPORT( int, playlist_Import, ( playlist_t *, const char * ) );
......
......@@ -93,6 +93,7 @@ enum
PopupPlay_Event,
PopupPlayThis_Event,
PopupSort_Event,
PopupDel_Event,
PopupEna_Event,
PopupInfo_Event,
......@@ -154,6 +155,7 @@ BEGIN_EVENT_TABLE(Playlist, wxFrame)
/* Popup events */
EVT_MENU( PopupPlay_Event, Playlist::OnPopupPlay)
EVT_MENU( PopupPlayThis_Event, Playlist::OnPopupPlay)
EVT_MENU( PopupSort_Event, Playlist::OnPopupSort)
EVT_MENU( PopupDel_Event, Playlist::OnPopupDel)
EVT_MENU( PopupEna_Event, Playlist::OnPopupEna)
EVT_MENU( PopupInfo_Event, Playlist::OnPopupInfo)
......@@ -276,6 +278,7 @@ Playlist::Playlist( intf_thread_t *_p_intf, wxWindow *p_parent ):
popup_menu = new wxMenu;
popup_menu->Append( PopupPlay_Event, wxU(_("Play")) );
popup_menu->Append( PopupPlayThis_Event, wxU(_("Play this branch")) );
popup_menu->Append( PopupSort_Event, wxU(_("Sort this branch")) );
popup_menu->Append( PopupDel_Event, wxU(_("Delete")) );
popup_menu->Append( PopupEna_Event, wxU(_("Enable/Disable")) );
popup_menu->Append( PopupInfo_Event, wxU(_("Info")) );
......@@ -1452,6 +1455,26 @@ void Playlist::OnPopupDel( wxMenuEvent& event )
}
}
void Playlist::OnPopupSort( wxMenuEvent& event )
{
PlaylistItem *p_wxitem;
p_wxitem = (PlaylistItem *)treectrl->GetItemData( i_popup_item );
if( p_wxitem->p_item->i_children >= 0 )
{
playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf,
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( p_playlist )
{
playlist_NodeSort( p_playlist, p_wxitem->p_item,
SORT_TITLE_NODES_FIRST, ORDER_NORMAL );
vlc_object_release( p_playlist );
}
}
}
void Playlist::OnPopupEna( wxMenuEvent& event )
{
playlist_t *p_playlist =
......
......@@ -829,6 +829,7 @@ private:
/* Popup functions */
void OnPopup( wxContextMenuEvent& event );
void OnPopupPlay( wxMenuEvent& event );
void OnPopupSort( wxMenuEvent& event );
void OnPopupDel( wxMenuEvent& event );
void OnPopupEna( wxMenuEvent& event );
void OnPopupInfo( wxMenuEvent& event );
......
......@@ -153,6 +153,26 @@ int playlist_ItemArraySort( playlist_t *p_playlist, int i_items,
{
msg_Err( p_playlist,"META SORT not implemented" );
}
else if( i_mode == SORT_TITLE_NODES_FIRST )
{
/* Alphabetic sort, all nodes first */
if( pp_items[i]->i_children == -1 &&
pp_items[i_small]->i_children >= 0 )
{
i_test = 1;
}
else if( pp_items[i]->i_children >= 0 &&
pp_items[i_small]->i_children == -1 )
{
i_test = -1;
}
else
{
i_test = strcasecmp( pp_items[i]->input.psz_name,
pp_items[i_small]->input.psz_name );
}
}
if( ( i_type == ORDER_NORMAL && i_test < 0 ) ||
( i_type == ORDER_REVERSE && i_test > 0 ) )
......
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