[vlc-devel] commit: Add URI column to Qt4 playlist. Add sorting by URI in playlist core . (Antoine Cellerier )
git version control
git at videolan.org
Thu Sep 18 19:40:38 CEST 2008
vlc | branch: 0.9-bugfix | Antoine Cellerier <dionoea at videolan.org> | Thu Sep 18 19:42:58 2008 +0200| [0060ee409803ddcb79eb1ec0895de850fc608205] | committer: Antoine Cellerier
Add URI column to Qt4 playlist. Add sorting by URI in playlist core.
(cherry picked from commit 2bde17e1579fd13cb0c067baebb1b984e1186cda)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0060ee409803ddcb79eb1ec0895de850fc608205
---
include/vlc_playlist.h | 1 +
.../gui/qt4/components/playlist/playlist_model.cpp | 33 +++++++------------
modules/gui/qt4/components/playlist/sorting.h | 7 +++-
.../gui/qt4/components/playlist/standardpanel.cpp | 28 ++++++-----------
src/playlist/sort.c | 11 ++++++-
5 files changed, 39 insertions(+), 41 deletions(-)
diff --git a/include/vlc_playlist.h b/include/vlc_playlist.h
index 54e457c..c422e79 100644
--- a/include/vlc_playlist.h
+++ b/include/vlc_playlist.h
@@ -246,6 +246,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 f09a4a7..fd72d40 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
@@ -744,27 +744,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 78cda9b..cf72337 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 de809f2..2d1a8b6 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 e7c5f6e..e8b6f3c 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
More information about the vlc-devel
mailing list