Commit 2bde17e1 authored by Antoine Cellerier's avatar Antoine Cellerier

Add URI column to Qt4 playlist. Add sorting by URI in playlist core.

parent db6404e5
......@@ -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
......
......@@ -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;
......
......@@ -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();
}
}
......@@ -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() );
}
......
......@@ -236,6 +236,15 @@ 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 )
i_test = i_test * -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment