Sfoglia il codice sorgente

core: added sort by date (prepare for playlist fix)

Prepares the core to allow sorting playlists by date.
Further, sorting by artist now decides the order of equal entries via publish date and album.

Signed-off-by: Rémi Denis-Courmont <remi@remlab.net>
Marcel Schnirring 8 anni fa
parent
commit
a5aee64cc8
2 ha cambiato i file con 14 aggiunte e 3 eliminazioni
  1. 2 1
      include/vlc_playlist.h
  2. 12 2
      src/playlist/sort.c

+ 2 - 1
include/vlc_playlist.h

@@ -180,7 +180,8 @@ struct playlist_t
     DEF( SORT_DESCRIPTION )\
     DEF( SORT_RATING )\
     DEF( SORT_URI )\
-    DEF( SORT_DISC_NUMBER )
+    DEF( SORT_DISC_NUMBER )\
+    DEF( SORT_DATE )
 
 #define DEF( s ) s,
 enum

+ 12 - 2
src/playlist/sort.c

@@ -226,12 +226,22 @@ SORTFN( SORT_ALBUM, first, second )
     return i_ret;
 }
 
+SORTFN( SORT_DATE, first, second )
+{
+    int i_ret = meta_sort( first, second, vlc_meta_Date, true );
+    /* Items came from the same date: compare the albums */
+    if( i_ret == 0 )
+        i_ret = proto_SORT_ALBUM( first, second );
+
+    return i_ret;
+}
+
 SORTFN( SORT_ARTIST, first, second )
 {
     int i_ret = meta_sort( first, second, vlc_meta_Artist, false );
-    /* Items came from the same artist: compare the albums */
+    /* Items came from the same artist: compare the dates */
     if( i_ret == 0 )
-        i_ret = proto_SORT_ALBUM( first, second );
+        i_ret = proto_SORT_DATE( first, second );
 
     return i_ret;
 }