#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
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 * ) );
PopupPlay_Event,
PopupPlayThis_Event,
+ PopupSort_Event,
PopupDel_Event,
PopupEna_Event,
PopupInfo_Event,
/* 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)
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")) );
}
}
+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 =
/* 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 );
{
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 ) )