From: Antoine Cellerier Date: Thu, 18 Sep 2008 17:42:58 +0000 (+0200) Subject: Add URI column to Qt4 playlist. Add sorting by URI in playlist core. X-Git-Tag: 1.0.0-pre1~3161 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=2bde17e1579fd13cb0c067baebb1b984e1186cda;p=vlc Add URI column to Qt4 playlist. Add sorting by URI in playlist core. --- diff --git a/include/vlc_playlist.h b/include/vlc_playlist.h index 95b90cd66e..430b4a0d7e 100644 --- a/include/vlc_playlist.h +++ b/include/vlc_playlist.h @@ -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 diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp index 8edada7dcc..6d3a7ef77e 100644 --- a/modules/gui/qt4/components/playlist/playlist_model.cpp +++ b/modules/gui/qt4/components/playlist/playlist_model.cpp @@ -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; diff --git a/modules/gui/qt4/components/playlist/sorting.h b/modules/gui/qt4/components/playlist/sorting.h index 78cda9b2ed..cf72337009 100644 --- a/modules/gui/qt4/components/playlist/sorting.h +++ b/modules/gui/qt4/components/playlist/sorting.h @@ -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(); } } diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp index de809f2e48..2d1a8b69aa 100644 --- a/modules/gui/qt4/components/playlist/standardpanel.cpp +++ b/modules/gui/qt4/components/playlist/standardpanel.cpp @@ -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() ); } diff --git a/src/playlist/sort.c b/src/playlist/sort.c index e7c5f6e116..e8b6f3c658 100644 --- a/src/playlist/sort.c +++ b/src/playlist/sort.c @@ -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