Commit b0565043 authored by Rémi Duraffort's avatar Rémi Duraffort

Use the correct meta data to sort the playlist.

The sorting is still strange (wrong ?) but the sort is done on the right meta data.
parent 0a520894
......@@ -259,6 +259,9 @@ struct playlist_add_t
#define SORT_DURATION 6
#define SORT_TITLE_NUMERIC 7
#define SORT_ALBUM 8
#define SORT_TRACK_NUMBER 9
#define SORT_DESCRIPTION 10
#define SORT_RATING 11
#define ORDER_NORMAL 0
#define ORDER_REVERSE 1
......
......@@ -715,18 +715,48 @@ void PLModel::doDeleteItem( PLItem *item, QModelIndexList *fullList )
/******* Volume III: Sorting and searching ********/
void PLModel::sort( int column, Qt::SortOrder order )
{
int i_index = -1;
int i_flag = 0;
#define CHECK_COLUMN( meta ) \
{ \
if( ( shownFlags() & VLC_META_ENGINE_##meta ) ) \
i_index++; \
if( column == i_index ) \
{ \
i_flag = VLC_META_ENGINE_##meta; \
goto next; \
} \
}
CHECK_COLUMN( TITLE );
CHECK_COLUMN( DURATION );
CHECK_COLUMN( ARTIST );
CHECK_COLUMN( GENRE );
CHECK_COLUMN( COLLECTION );
CHECK_COLUMN( SEQ_NUM );
CHECK_COLUMN( DESCRIPTION );
CHECK_COLUMN( RATING );
#undef CHECK_COLUMN;
next:
PL_LOCK;
{
playlist_item_t *p_root = playlist_ItemGetById( p_playlist,
rootItem->i_id,
VLC_TRUE );
int i_mode;
switch( column )
{
case 0: i_mode = SORT_TITLE_NODES_FIRST;break;
case 1: i_mode = SORT_DURATION; break;
case 2: i_mode = SORT_ARTIST;break;
default: i_mode = SORT_TITLE_NODES_FIRST; break;
switch( i_flag )
{
case VLC_META_ENGINE_TITLE: i_mode = SORT_TITLE_NODES_FIRST;break;
case VLC_META_ENGINE_DURATION: i_mode = SORT_DURATION; break;
case VLC_META_ENGINE_ARTIST: i_mode = SORT_ARTIST; break;
case VLC_META_ENGINE_GENRE: i_mode = SORT_GENRE; break;
case VLC_META_ENGINE_COLLECTION: i_mode = SORT_ALBUM; break;
case VLC_META_ENGINE_SEQ_NUM: i_mode = SORT_TRACK_NUMBER; break;
case VLC_META_ENGINE_DESCRIPTION:i_mode = SORT_DESCRIPTION; break;
case VLC_META_ENGINE_RATING: i_mode = SORT_RATING; break;
default: i_mode = SORT_TITLE_NODES_FIRST;break;
}
if( p_root )
{
......
......@@ -179,10 +179,26 @@ static int playlist_ItemArraySort( playlist_t *p_playlist, int i_items,
{
DO_META_SORT( Artist );
}
else if( i_mode == SORT_GENRE )
{
DO_META_SORT( Genre );
}
else if( i_mode == SORT_ALBUM )
{
DO_META_SORT( Album );
}
else if( i_mode == SORT_TRACK_NUMBER )
{
DO_META_SORT( TrackNumber );
}
else if( i_mode == SORT_DESCRIPTION )
{
DO_META_SORT( Description );
}
else if( i_mode == SORT_RATING )
{
DO_META_SORT( Rating );
}
else if( i_mode == SORT_TITLE_NODES_FIRST )
{
/* Alphabetic sort, all nodes first */
......
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