[vlc-devel] [PATCH] playlist: added column date to detailed view

Marcel Schnirring ms at marcel-schnirring.de
Sun Nov 20 22:24:24 CET 2016


---
 include/vlc_playlist.h                       |  3 ++-
 modules/gui/qt/components/playlist/sorting.h |  9 ++++++++-
 src/playlist/sort.c                          | 14 +++++++++++++-
 3 files changed, 23 insertions(+), 3 deletions(-)

diff --git a/include/vlc_playlist.h b/include/vlc_playlist.h
index 5fef490..742372c 100644
--- a/include/vlc_playlist.h
+++ b/include/vlc_playlist.h
@@ -186,7 +186,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
diff --git a/modules/gui/qt/components/playlist/sorting.h b/modules/gui/qt/components/playlist/sorting.h
index fe0a615..6c1e935 100644
--- a/modules/gui/qt/components/playlist/sorting.h
+++ b/modules/gui/qt/components/playlist/sorting.h
@@ -42,10 +42,11 @@ enum
     COLUMN_RATING         = 0x0200,
     COLUMN_COVER          = 0x0400,
     COLUMN_DISC_NUMBER    = 0x0800,
+    COLUMN_DATE           = 0x1000,
 
     /* Add new entries here and update the COLUMN_END value*/
 
-    COLUMN_END          = 0x1000
+    COLUMN_END            = 0x2000
 };
 
 #define COLUMN_DEFAULT (COLUMN_TITLE|COLUMN_DURATION|COLUMN_ALBUM)
@@ -67,6 +68,7 @@ static inline const char * psz_column_title( uint32_t i_column )
     case COLUMN_RATING:          return VLC_META_RATING;
     case COLUMN_COVER:           return _("Cover");
     case COLUMN_DISC_NUMBER:     return VLC_META_DISCNUMBER;
+    case COLUMN_DATE:            return VLC_META_DATE;
     default: abort();
     }
 }
@@ -106,6 +108,8 @@ static inline char * psz_column_meta( input_item_t *p_item, uint32_t i_column )
         return input_item_GetArtworkURL( p_item );
     case COLUMN_DISC_NUMBER:
         return input_item_GetDiscNumber( p_item );
+    case COLUMN_DATE:
+        return input_item_GetDate( p_item );
     default:
         abort();
     }
@@ -127,10 +131,12 @@ static inline int i_column_sorting( uint32_t i_column )
     case COLUMN_URI:            return SORT_URI;
     case COLUMN_RATING:         return SORT_RATING;
     case COLUMN_DISC_NUMBER:    return SORT_DISC_NUMBER;
+    case COLUMN_DATE:           return SORT_DATE;
     default: abort();
     }
 }
 
+/* Return the media library query select type */
 static inline ml_select_e meta_to_mlmeta( uint32_t i_column )
 {
     switch( i_column )
@@ -147,6 +153,7 @@ static inline ml_select_e meta_to_mlmeta( uint32_t i_column )
     case COLUMN_RATING:         return ML_VOTE;
     case COLUMN_COVER:          return ML_COVER;
     case COLUMN_DISC_NUMBER:    return ML_DISC_NUMBER;
+    case COLUMN_DATE:           return ML_YEAR;
     default: abort();
     }
 }
diff --git a/src/playlist/sort.c b/src/playlist/sort.c
index 588bd35..68c15a5 100644
--- a/src/playlist/sort.c
+++ b/src/playlist/sort.c
@@ -226,6 +226,19 @@ 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 = meta_sort( first, second, vlc_meta_Album, false );
+    /* Items came from the same album: compare the track numbers */
+    if( i_ret == 0 )
+        i_ret = meta_sort( first, second, vlc_meta_TrackNumber, true );
+
+    return i_ret;
+}
+
 SORTFN( SORT_ARTIST, first, second )
 {
     int i_ret = meta_sort( first, second, vlc_meta_Artist, false );
@@ -361,4 +374,3 @@ static const sortfn_t sorting_fns[NUM_SORT_FNS][2] =
 #define DEF( a ) { cmp_a_##a, cmp_d_##a },
 { VLC_DEFINE_SORT_FUNCTIONS };
 #undef  DEF
-
-- 
2.7.4



More information about the vlc-devel mailing list