Commit 678c0546 authored by Clément Stenac's avatar Clément Stenac

Recursive sort

parent 7f7a8e2b
......@@ -333,6 +333,7 @@ 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 ) );
VLC_EXPORT( int, playlist_RecursiveNodeSort, ( playlist_t *, playlist_item_t *,int, int ) );
/* Load/Save */
VLC_EXPORT( int, playlist_Import, ( playlist_t *, const char * ) );
......
......@@ -1503,8 +1503,11 @@ void Playlist::OnPopupSort( wxMenuEvent& event )
if( p_playlist )
{
playlist_NodeSort( p_playlist, p_wxitem->p_item,
SORT_TITLE_NODES_FIRST, ORDER_NORMAL );
vlc_mutex_lock( &p_playlist->object_lock );
playlist_RecursiveNodeSort( p_playlist, p_wxitem->p_item,
SORT_TITLE_NODES_FIRST, ORDER_NORMAL );
vlc_mutex_unlock( &p_playlist->object_lock );
b_need_update = VLC_TRUE;
vlc_object_release( p_playlist );
}
}
......
......@@ -81,6 +81,9 @@ int playlist_Sort( playlist_t * p_playlist , int i_mode, int i_type )
/**
* Sort a node.
*
* This function must be entered with the playlist lock !
*
* \param p_playlist the playlist
* \param p_node the node to sort
* \param i_mode: SORT_ID, SORT_TITLE, SORT_AUTHOR, SORT_RANDOM
......@@ -90,22 +93,44 @@ int playlist_Sort( playlist_t * p_playlist , int i_mode, int i_type )
int playlist_NodeSort( playlist_t * p_playlist , playlist_item_t *p_node,
int i_mode, int i_type )
{
vlc_value_t val;
val.b_bool = VLC_TRUE;
vlc_mutex_lock( &p_playlist->object_lock );
playlist_ItemArraySort( p_playlist,p_node->i_children,
p_node->pp_children, i_mode, i_type );
p_node->i_serial++;
vlc_mutex_unlock( &p_playlist->object_lock );
return VLC_SUCCESS;
}
/* Notify the interfaces */
var_Set( p_playlist, "intf-change", val );
/**
*
* Sort a node recursively.
*
* This function must be entered with the playlist lock !
*
* \param p_playlist the playlist
* \param p_node the node to sort
* \param i_mode: SORT_ID, SORT_TITLE, SORT_AUTHOR, SORT_RANDOM
* \param i_type: ORDER_NORMAL or ORDER_REVERSE (reversed order)
* \return VLC_SUCCESS on success
*/
int playlist_RecursiveNodeSort( playlist_t *p_playlist, playlist_item_t *p_node,
int i_mode, int i_type )
{
int i;
playlist_NodeSort( p_playlist, p_node, i_mode, i_type );
for( i = 0 ; i< p_node->i_children; i++ )
{
if( p_node->pp_children[i]->i_children != -1 )
{
playlist_RecursiveNodeSort( p_playlist, p_node->pp_children[i],
i_mode,i_type );
}
}
return VLC_SUCCESS;
}
......
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