]> git.sesse.net Git - vlc/commitdiff
Add URI column to Qt4 playlist. Add sorting by URI in playlist core.
authorAntoine Cellerier <dionoea@videolan.org>
Thu, 18 Sep 2008 17:42:58 +0000 (19:42 +0200)
committerAntoine Cellerier <dionoea@videolan.org>
Thu, 18 Sep 2008 17:42:58 +0000 (19:42 +0200)
include/vlc_playlist.h
modules/gui/qt4/components/playlist/playlist_model.cpp
modules/gui/qt4/components/playlist/sorting.h
modules/gui/qt4/components/playlist/standardpanel.cpp
src/playlist/sort.c

index 95b90cd66e7d92d09d760459190c44d65c88c5e7..430b4a0d7ecfa48e97c75309a6b7c73ec1141090 100644 (file)
@@ -244,6 +244,7 @@ struct playlist_add_t
 #define SORT_TRACK_NUMBER 9
 #define SORT_DESCRIPTION 10
 #define SORT_RATING 11
+#define SORT_URI 12
 
 #define ORDER_NORMAL 0
 #define ORDER_REVERSE 1
index 8edada7dcc01c31b6270883b8264e07fc5dff47e..6d3a7ef77eb50615a08e98a90bfa3e5aea4cbe3d 100644 (file)
@@ -745,27 +745,18 @@ void PLModel::sort( int column, Qt::SortOrder order )
         return;
     }
 
-#define CHECK_COLUMN( meta )                        \
-{                                                   \
-    if( ( shownFlags() & meta ) )                   \
-        i_index++;                                  \
-    if( column == i_index )                         \
-    {                                               \
-        i_flag = meta;                              \
-        goto next;                                  \
-    }                                               \
-}
-
-    CHECK_COLUMN( COLUMN_NUMBER );
-    CHECK_COLUMN( COLUMN_TITLE );
-    CHECK_COLUMN( COLUMN_DURATION );
-    CHECK_COLUMN( COLUMN_ARTIST );
-    CHECK_COLUMN( COLUMN_GENRE );
-    CHECK_COLUMN( COLUMN_ALBUM );
-    CHECK_COLUMN( COLUMN_TRACK_NUMBER );
-    CHECK_COLUMN( COLUMN_DESCRIPTION );
-
-#undef CHECK_COLUMN
+    int i_column = 1;
+    for( i_column = 1; i_column != COLUMN_END; i_column<<=1 )
+    {
+        if( ( shownFlags() & i_column ) )
+            i_index++;
+        if( column == i_index )
+        {
+            i_flag = i_column;
+            goto next;
+        }
+    }
+
 
 next:
     PL_LOCK;
index 78cda9b2ed343f25cb6ed61d9945aeb173036cb5..cf72337009b6126f3ccd674dc842898c086a86d7 100644 (file)
@@ -32,10 +32,11 @@ enum
     COLUMN_ALBUM        = 0x0020,
     COLUMN_TRACK_NUMBER = 0x0040,
     COLUMN_DESCRIPTION  = 0x0080,
+    COLUMN_URI          = 0x0100,
 
     /* Add new entries here and update the COLUMN_END value*/
 
-    COLUMN_END          = 0x0100
+    COLUMN_END          = 0x0200
 };
 
 /* Return the title of a column */
@@ -51,6 +52,7 @@ static const char * psz_column_title( uint32_t i_column )
     case COLUMN_ALBUM:           return VLC_META_ALBUM;
     case COLUMN_TRACK_NUMBER:    return VLC_META_TRACK_NUMBER;
     case COLUMN_DESCRIPTION:     return VLC_META_DESCRIPTION;
+    case COLUMN_URI:             return _("URI");
     default: abort();
     }
 }
@@ -85,6 +87,8 @@ static char * psz_column_meta( input_item_t *p_item, uint32_t i_column )
         return input_item_GetTrackNum( p_item );
     case COLUMN_DESCRIPTION:
         return input_item_GetDescription( p_item );
+    case COLUMN_URI:
+        return input_item_GetURI( p_item );
     default:
         abort();
     }
@@ -103,6 +107,7 @@ static inline int i_column_sorting( uint32_t i_column )
     case COLUMN_ALBUM:          return SORT_ALBUM;
     case COLUMN_TRACK_NUMBER:   return SORT_TRACK_NUMBER;
     case COLUMN_DESCRIPTION:    return SORT_DESCRIPTION;
+    case COLUMN_URI:            return SORT_URI;
     default: abort();
     }
 }
index de809f2e48b63a4541a37abc15fdd67de7b78891..2d1a8b69aa0b103094e459023079a0ecd0723c22 100644 (file)
@@ -274,26 +274,18 @@ void StandardPLPanel::popupSelectColumn( QPoint pos )
 
     QMenu selectColMenu;
 
-#define ADD_META_ACTION( meta ) {                                              \
-    QAction* option = selectColMenu.addAction( qfu( psz_column_title( meta ) ) );     \
-    option->setCheckable( true );                                              \
-    option->setChecked( model->shownFlags() & meta );                          \
-    ContextUpdateMapper->setMapping( option, meta );                           \
-    CONNECT( option, triggered(), ContextUpdateMapper, map() );                \
-}
-
     CONNECT( ContextUpdateMapper, mapped( int ),  model, viewchanged( int ) );
 
-    ADD_META_ACTION( COLUMN_NUMBER );
-    ADD_META_ACTION( COLUMN_TITLE );
-    ADD_META_ACTION( COLUMN_DURATION );
-    ADD_META_ACTION( COLUMN_ARTIST );
-    ADD_META_ACTION( COLUMN_GENRE );
-    ADD_META_ACTION( COLUMN_ALBUM );
-    ADD_META_ACTION( COLUMN_TRACK_NUMBER );
-    ADD_META_ACTION( COLUMN_DESCRIPTION );
-
-#undef ADD_META_ACTION
+    int i_column = 1;
+    for( i_column = 1; i_column != COLUMN_END; i_column<<=1 )
+    {
+        QAction* option = selectColMenu.addAction(
+            qfu( psz_column_title( i_column ) ) );
+        option->setCheckable( true );
+        option->setChecked( model->shownFlags() & i_column );
+        ContextUpdateMapper->setMapping( option, i_column );
+        CONNECT( option, triggered(), ContextUpdateMapper, map() );
+    }
 
     selectColMenu.exec( QCursor::pos() );
 }
index e7c5f6e116b056080cc8d00c0a6486ed24a70d04..e8b6f3c658582189be9eb462257344bef4fd3ef6 100644 (file)
@@ -236,8 +236,17 @@ static int playlist_cmp(const void *first, const void *second)
                                  (*(playlist_item_t **)second)->p_input->psz_name );
         }
     }
+    else if( sort_mode == SORT_URI )
+    {
+        char *psz_i = input_item_GetURI( (*(playlist_item_t **)first)->p_input );
+        char *psz_ismall =
+                input_item_GetURI( (*(playlist_item_t **)second)->p_input );
+        i_test = strcasecmp( psz_i, psz_ismall );
+        free( psz_i );
+        free( psz_ismall );
+    }
 
-    if ( sort_type == ORDER_REVERSE ) 
+    if ( sort_type == ORDER_REVERSE )
         i_test = i_test * -1;
 #undef DO_META_SORT
 #undef DO_META_SORT_ADV