From: RĂ©mi Duraffort Date: Tue, 4 Mar 2008 00:45:24 +0000 (+0100) Subject: Use the correct meta data to sort the playlist. X-Git-Tag: 0.9.0-test0~2335 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=b0565043b567402b49412c95e7acc8e82c14912b;p=vlc 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. --- diff --git a/include/vlc_playlist.h b/include/vlc_playlist.h index e9033674d7..9e8321139d 100644 --- a/include/vlc_playlist.h +++ b/include/vlc_playlist.h @@ -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 diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp index 46ffe0aa71..53d73d2110 100644 --- a/modules/gui/qt4/components/playlist/playlist_model.cpp +++ b/modules/gui/qt4/components/playlist/playlist_model.cpp @@ -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 ) + switch( i_flag ) { - 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; + 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 ) { diff --git a/src/playlist/sort.c b/src/playlist/sort.c index 7d57921b85..c6ddbd8d62 100644 --- a/src/playlist/sort.c +++ b/src/playlist/sort.c @@ -115,7 +115,7 @@ static int playlist_ItemArraySort( playlist_t *p_playlist, int i_items, free( psz_i ); \ free( psz_ismall ); \ } - + #define DO_META_SORT( 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, { 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 */