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 ...@@ -259,6 +259,9 @@ struct playlist_add_t
#define SORT_DURATION 6 #define SORT_DURATION 6
#define SORT_TITLE_NUMERIC 7 #define SORT_TITLE_NUMERIC 7
#define SORT_ALBUM 8 #define SORT_ALBUM 8
#define SORT_TRACK_NUMBER 9
#define SORT_DESCRIPTION 10
#define SORT_RATING 11
#define ORDER_NORMAL 0 #define ORDER_NORMAL 0
#define ORDER_REVERSE 1 #define ORDER_REVERSE 1
......
...@@ -715,18 +715,48 @@ void PLModel::doDeleteItem( PLItem *item, QModelIndexList *fullList ) ...@@ -715,18 +715,48 @@ void PLModel::doDeleteItem( PLItem *item, QModelIndexList *fullList )
/******* Volume III: Sorting and searching ********/ /******* Volume III: Sorting and searching ********/
void PLModel::sort( int column, Qt::SortOrder order ) 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; PL_LOCK;
{ {
playlist_item_t *p_root = playlist_ItemGetById( p_playlist, playlist_item_t *p_root = playlist_ItemGetById( p_playlist,
rootItem->i_id, rootItem->i_id,
VLC_TRUE ); VLC_TRUE );
int i_mode; int i_mode;
switch( column ) switch( i_flag )
{ {
case 0: i_mode = SORT_TITLE_NODES_FIRST;break; case VLC_META_ENGINE_TITLE: i_mode = SORT_TITLE_NODES_FIRST;break;
case 1: i_mode = SORT_DURATION; break; case VLC_META_ENGINE_DURATION: i_mode = SORT_DURATION; break;
case 2: i_mode = SORT_ARTIST;break; case VLC_META_ENGINE_ARTIST: i_mode = SORT_ARTIST; break;
default: i_mode = SORT_TITLE_NODES_FIRST; 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 ) if( p_root )
{ {
......
...@@ -115,7 +115,7 @@ static int playlist_ItemArraySort( playlist_t *p_playlist, int i_items, ...@@ -115,7 +115,7 @@ static int playlist_ItemArraySort( playlist_t *p_playlist, int i_items,
free( psz_i ); \ free( psz_i ); \
free( psz_ismall ); \ free( psz_ismall ); \
} }
#define DO_META_SORT( node ) { \ #define DO_META_SORT( node ) { \
char *psz_a = input_item_GetMeta( pp_items[i]->p_input, vlc_meta_##node ); \ char *psz_a = input_item_GetMeta( pp_items[i]->p_input, vlc_meta_##node ); \
...@@ -179,10 +179,26 @@ static int playlist_ItemArraySort( playlist_t *p_playlist, int i_items, ...@@ -179,10 +179,26 @@ static int playlist_ItemArraySort( playlist_t *p_playlist, int i_items,
{ {
DO_META_SORT( Artist ); DO_META_SORT( Artist );
} }
else if( i_mode == SORT_GENRE )
{
DO_META_SORT( Genre );
}
else if( i_mode == SORT_ALBUM ) else if( i_mode == SORT_ALBUM )
{ {
DO_META_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 ) else if( i_mode == SORT_TITLE_NODES_FIRST )
{ {
/* Alphabetic sort, all 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