[vlc-devel] commit: Use the correct meta data to sort the playlist. ( Rémi Duraffort )

git version control git at videolan.org
Tue Mar 4 01:47:04 CET 2008


vlc | branch: master | Rémi Duraffort <ivoire at via.ecp.fr> | Tue Mar  4 01:45:24 2008 +0100| [b0565043b567402b49412c95e7acc8e82c14912b]

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.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b0565043b567402b49412c95e7acc8e82c14912b
---

 include/vlc_playlist.h                             |    3 +
 .../gui/qt4/components/playlist/playlist_model.cpp |   40 +++++++++++++++++--
 src/playlist/sort.c                                |   18 ++++++++-
 3 files changed, 55 insertions(+), 6 deletions(-)

diff --git a/include/vlc_playlist.h b/include/vlc_playlist.h
index e903367..9e83211 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 46ffe0a..53d73d2 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 7d57921..c6ddbd8 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 */




More information about the vlc-devel mailing list