[vlc-devel] [PATCH 1/2] Qt: Allow sorting by disc number

Wieland Hoffmann themineo at gmail.com
Sun Feb 28 21:06:51 CET 2016


---
 include/vlc_input_item.h                             | 1 +
 include/vlc_playlist.h                               | 3 ++-
 modules/gui/qt/components/playlist/sorting.h         | 8 +++++++-
 modules/gui/qt/components/playlist/standardpanel.cpp | 2 +-
 src/playlist/sort.c                                  | 5 +++++
 5 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/include/vlc_input_item.h b/include/vlc_input_item.h
index 4391c72..8d20efa 100644
--- a/include/vlc_input_item.h
+++ b/include/vlc_input_item.h
@@ -259,6 +259,7 @@ INPUT_META(Season)
 INPUT_META(Episode)
 INPUT_META(ShowName)
 INPUT_META(Actors)
+INPUT_META(DiscNumber)
 
 #define input_item_SetTrackNum input_item_SetTrackNumber
 #define input_item_GetTrackNum input_item_GetTrackNumber
diff --git a/include/vlc_playlist.h b/include/vlc_playlist.h
index b116455..177ffa7 100644
--- a/include/vlc_playlist.h
+++ b/include/vlc_playlist.h
@@ -206,7 +206,8 @@ struct playlist_add_t
     DEF( SORT_TRACK_NUMBER )\
     DEF( SORT_DESCRIPTION )\
     DEF( SORT_RATING )\
-    DEF( SORT_URI )
+    DEF( SORT_URI )\
+    DEF( SORT_DISC_NUMBER )
 
 #define DEF( s ) s,
 enum
diff --git a/modules/gui/qt/components/playlist/sorting.h b/modules/gui/qt/components/playlist/sorting.h
index 13a6905..fe0a615 100644
--- a/modules/gui/qt/components/playlist/sorting.h
+++ b/modules/gui/qt/components/playlist/sorting.h
@@ -41,10 +41,11 @@ enum
     COLUMN_NUMBER         = 0x0100,
     COLUMN_RATING         = 0x0200,
     COLUMN_COVER          = 0x0400,
+    COLUMN_DISC_NUMBER    = 0x0800,
 
     /* Add new entries here and update the COLUMN_END value*/
 
-    COLUMN_END          = 0x0800
+    COLUMN_END          = 0x1000
 };
 
 #define COLUMN_DEFAULT (COLUMN_TITLE|COLUMN_DURATION|COLUMN_ALBUM)
@@ -65,6 +66,7 @@ static inline const char * psz_column_title( uint32_t i_column )
     case COLUMN_URI:             return _("URI");
     case COLUMN_RATING:          return VLC_META_RATING;
     case COLUMN_COVER:           return _("Cover");
+    case COLUMN_DISC_NUMBER:     return VLC_META_DISCNUMBER;
     default: abort();
     }
 }
@@ -102,6 +104,8 @@ static inline char * psz_column_meta( input_item_t *p_item, uint32_t i_column )
         return input_item_GetRating( p_item );
     case COLUMN_COVER:
         return input_item_GetArtworkURL( p_item );
+    case COLUMN_DISC_NUMBER:
+        return input_item_GetDiscNumber( p_item );
     default:
         abort();
     }
@@ -122,6 +126,7 @@ static inline int i_column_sorting( uint32_t i_column )
     case COLUMN_DESCRIPTION:    return SORT_DESCRIPTION;
     case COLUMN_URI:            return SORT_URI;
     case COLUMN_RATING:         return SORT_RATING;
+    case COLUMN_DISC_NUMBER:    return SORT_DISC_NUMBER;
     default: abort();
     }
 }
@@ -141,6 +146,7 @@ static inline ml_select_e meta_to_mlmeta( uint32_t i_column )
     case COLUMN_URI:            return ML_URI;
     case COLUMN_RATING:         return ML_VOTE;
     case COLUMN_COVER:          return ML_COVER;
+    case COLUMN_DISC_NUMBER:    return ML_DISC_NUMBER;
     default: abort();
     }
 }
diff --git a/modules/gui/qt/components/playlist/standardpanel.cpp b/modules/gui/qt/components/playlist/standardpanel.cpp
index 2f8a675..26f0657 100644
--- a/modules/gui/qt/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt/components/playlist/standardpanel.cpp
@@ -247,7 +247,7 @@ bool StandardPLPanel::popup( const QPoint &point )
         QMenu *sortingMenu = new QMenu( qtr( "Sort by" ), &menu );
         /* Choose what columns to show in sorting menu, not sure if this should be configurable*/
         QList<int> sortingColumns;
-        sortingColumns << COLUMN_TITLE << COLUMN_ARTIST << COLUMN_ALBUM << COLUMN_TRACK_NUMBER << COLUMN_URI;
+        sortingColumns << COLUMN_TITLE << COLUMN_ARTIST << COLUMN_ALBUM << COLUMN_TRACK_NUMBER << COLUMN_URI << COLUMN_DISC_NUMBER;
         container.action = VLCModelSubInterface::ACTION_SORT;
         foreach( int Column, sortingColumns )
         {
diff --git a/src/playlist/sort.c b/src/playlist/sort.c
index 2b91a90..e0307db 100644
--- a/src/playlist/sort.c
+++ b/src/playlist/sort.c
@@ -306,6 +306,11 @@ SORTFN( SORT_TRACK_NUMBER, first, second )
     return meta_sort( first, second, vlc_meta_TrackNumber, true );
 }
 
+SORTFN( SORT_DISC_NUMBER, first, second )
+{
+  return meta_sort( first, second, vlc_meta_DiscNumber, true );
+}
+
 SORTFN( SORT_URI, first, second )
 {
     int i_ret;
-- 
2.7.1



More information about the vlc-devel mailing list