Commit 7bc28eeb authored by Rafaël Carré's avatar Rafaël Carré

meta-data handling cleanup

Remove VLC_META_ENGINE_*
Don't use VLC_META_INFO_CAT
Avoid using input_Item{Add,Get}Info
Remove disabled code in cdda
Remove "meta fetcher":
    There was only 1 module (not) implementing it (musicbrainz)
    Reduces complexity in playlist core
Use a more consistent naming
Factorize QT4 sorting and column display code
Remove unused members
parent f864df7f
......@@ -258,12 +258,6 @@ static inline bool input_item_IsPreparsed( input_item_t *p_i )
return p_i->p_meta ? p_i->p_meta->i_status & ITEM_PREPARSED : false ;
}
static inline bool input_item_IsMetaFetched( input_item_t *p_i )
{
return p_i->p_meta ? p_i->p_meta->i_status & ITEM_META_FETCHED : false ;
}
static inline bool input_item_IsArtFetched( input_item_t *p_i )
{
return p_i->p_meta ? p_i->p_meta->i_status & ITEM_ART_FETCHED : false ;
......
......@@ -30,11 +30,9 @@
#include <vlc_arrays.h>
#define VLC_META_TYPE_COUNT 17
typedef enum vlc_meta_type_t
{
vlc_meta_Title = 0,
vlc_meta_Title,
vlc_meta_Artist,
vlc_meta_Genre,
vlc_meta_Copyright,
......@@ -53,14 +51,15 @@ typedef enum vlc_meta_type_t
vlc_meta_TrackID
} vlc_meta_type_t;
#define VLC_META_TYPE_COUNT 17
/* Returns a localizes string describing the meta */
VLC_EXPORT(const char *, input_MetaTypeToLocalizedString, ( vlc_meta_type_t meta_type ) );
#define ITEM_PREPARSED 0x01
#define ITEM_META_FETCHED 0x02
#define ITEM_ARTURL_FETCHED 0x04
#define ITEM_ART_FETCHED 0x08
#define ITEM_ART_NOTFOUND 0x10
#define ITEM_ARTURL_FETCHED 0x02
#define ITEM_ART_FETCHED 0x04
#define ITEM_ART_NOTFOUND 0x08
struct vlc_meta_t
{
......@@ -69,7 +68,6 @@ struct vlc_meta_t
vlc_dictionary_t extra_tags;
int i_status;
};
/* Setters for meta.
......@@ -163,15 +161,12 @@ static inline void vlc_meta_Merge( vlc_meta_t *dst, const vlc_meta_t *src )
free( ppsz_all_keys );
}
/* Shortcuts for the AddInfo */
#define VLC_META_INFO_CAT N_("Meta-information")
#define VLC_META_TITLE input_MetaTypeToLocalizedString( vlc_meta_Title )
#define VLC_META_DURATION N_( "Duration" )
#define VLC_META_ARTIST input_MetaTypeToLocalizedString( vlc_meta_Artist )
#define VLC_META_GENRE input_MetaTypeToLocalizedString( vlc_meta_Genre )
#define VLC_META_COPYRIGHT input_MetaTypeToLocalizedString( vlc_meta_Copyright )
#define VLC_META_COLLECTION input_MetaTypeToLocalizedString( vlc_meta_Album )
#define VLC_META_SEQ_NUM input_MetaTypeToLocalizedString( vlc_meta_TrackNumber )
#define VLC_META_ALBUM input_MetaTypeToLocalizedString( vlc_meta_Album )
#define VLC_META_TRACK_NUMBER input_MetaTypeToLocalizedString( vlc_meta_TrackNumber )
#define VLC_META_DESCRIPTION input_MetaTypeToLocalizedString( vlc_meta_Description )
#define VLC_META_RATING input_MetaTypeToLocalizedString( vlc_meta_Rating )
#define VLC_META_DATE input_MetaTypeToLocalizedString( vlc_meta_Date )
......@@ -196,43 +191,4 @@ struct meta_export_t
const char *psz_file;
};
#define VLC_META_ENGINE_TRACKID 0x00000001
#define VLC_META_ENGINE_TITLE 0x00000002
#define VLC_META_ENGINE_DURATION 0x00000004
#define VLC_META_ENGINE_ARTIST 0x00000008
#define VLC_META_ENGINE_GENRE 0x00000010
#define VLC_META_ENGINE_COPYRIGHT 0x00000020
#define VLC_META_ENGINE_COLLECTION 0x00000040
#define VLC_META_ENGINE_SEQ_NUM 0x00000080
#define VLC_META_ENGINE_DESCRIPTION 0x00000100
#define VLC_META_ENGINE_RATING 0x00000200
#define VLC_META_ENGINE_DATE 0x00000400
#define VLC_META_ENGINE_URL 0x00000800
#define VLC_META_ENGINE_LANGUAGE 0x00001000
#define VLC_META_ENGINE_ART_URL 0x00002000
#if 0 /* unused (yet?) */
#define VLC_META_ENGINE_MB_ARTIST_ID 0x00002000
#define VLC_META_ENGINE_MB_RELEASE_ID 0x00004000
#define VLC_META_ENGINE_MB_TRACK_ID 0x00008000
#define VLC_META_ENGINE_MB_TRM_ID 0x00010000
#endif
typedef struct meta_engine_sys_t meta_engine_sys_t;
struct meta_engine_t
{
VLC_COMMON_MEMBERS
module_t *p_module;
uint32_t i_mandatory; /**< Stuff which we really need to get */
uint32_t i_optional; /**< Stuff which we'd like to have */
input_item_t *p_item;
};
VLC_EXPORT(uint32_t, input_CurrentMetaFlags,( const vlc_meta_t *p_meta ) );
#endif
......@@ -807,16 +807,6 @@ CDDAFormatTitle( const access_t *p_access, track_t i_track )
return(NULL);
}
/* Adds a string-valued entry to the playlist information under "Track"
if the string is not null or the null string.
*/
#define add_playlist_track_info_str(TITLE, FIELD) \
if (FIELD && strlen(FIELD)) \
{ \
input_ItemAddInfo( &p_item->input, _("Track"), _(TITLE), \
"%s", FIELD); \
}
static playlist_item_t *
CDDACreatePlaylistItem( const access_t *p_access, cdda_data_t *p_cdda,
playlist_t *p_playlist, playlist_item_t *p_item,
......@@ -849,58 +839,6 @@ CDDACreatePlaylistItem( const access_t *p_access, cdda_data_t *p_cdda,
return p_child;
}
int CDDAAddMetaToItem( access_t *p_access, cdda_data_t *p_cdda,
playlist_item_t *p_item, int i_track,
bool b_single )
{
#if 0
add_playlist_track_info_str("Source", p_cdda->psz_source);
input_ItemAddInfo( &p_item->input, _("Track"), _("Track Number"),
"%d", i_track );
if (p_cdda->p_cdtext[i_track])
{
const cdtext_t *p = p_cdda->p_cdtext[i_track];
add_playlist_track_info_str("Arranger (CD-Text)",
p->field[CDTEXT_ARRANGER]);
add_playlist_track_info_str("Composer (CD-Text)",
p->field[CDTEXT_COMPOSER]);
add_playlist_track_info_str("Genre (CD-Text)",
p->field[CDTEXT_GENRE]);
add_playlist_track_info_str("Message (CD-Text)",
p->field[CDTEXT_MESSAGE]);
add_playlist_track_info_str("Performer (CD-Text)",
p->field[CDTEXT_PERFORMER]);
add_playlist_track_info_str("Songwriter (CD-Text)",
p->field[CDTEXT_SONGWRITER]);
add_playlist_track_info_str("Title (CD-Text)",
p->field[CDTEXT_TITLE]);
}
#ifdef HAVE_LIBCDDB
if (p_cdda->b_cddb_enabled)
{
cddb_track_t *t=cddb_disc_get_track(p_cdda->cddb.disc,
i_track-p_cdda->i_first_track);
if (t)
{
if (cddb_track_get_artist(t))
add_playlist_track_info_str("Artist (CDDB)",
cddb_track_get_artist(t));
if (cddb_track_get_title(t))
add_playlist_track_info_str("Title (CDDB)",
cddb_track_get_title(t));
if (cddb_track_get_ext_data(t))
add_playlist_track_info_str("Extended information (CDDB)",
cddb_track_get_ext_data(t));
}
}
#endif /*HAVE_LIBCDDB*/
#endif
return VLC_SUCCESS;
}
/*
Fixes up playlist.
*/
......@@ -973,7 +911,6 @@ CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda,
if( p_item )
{
CDDAAddMetaToItem( p_access, p_cdda, p_item, i_track, false );
input_item_SetDuration( p_item->p_input, (mtime_t) i_track_frames
* (CLOCK_FREQ / CDIO_CD_FRAMES_PER_SEC) );
input_item_SetURI( p_item->p_input,
......@@ -1009,8 +946,6 @@ CDDAFixupPlaylist( access_t *p_access, cdda_data_t *p_cdda,
p_child = CDDACreatePlaylistItem( p_access, p_cdda, p_playlist,
p_item,
i_track );
CDDAAddMetaToItem( p_access, p_cdda, p_child, i_track,
true );
}
}
......
......@@ -653,10 +653,6 @@ static void ParseVorbisComments( decoder_t *p_dec )
if( psz_value && ( *psz_value != '\0' ) )
{
input_item_SetArtist( p_item, psz_value );
input_ItemAddInfo( p_item,
_(VLC_META_INFO_CAT),
_(VLC_META_ARTIST),
"%s", psz_value );
}
}
else if( !strcasecmp( psz_name, "title" ) )
......
......@@ -983,30 +983,21 @@ void E_(EvaluateRPN)( intf_thread_t *p_intf, mvar_t *vars,
#define p_item input_GetItem( p_sys->p_input )
if( !strcmp( psz_meta, "ARTIST" ) )
{
psz_val = input_ItemGetInfo( p_item,
_(VLC_META_INFO_CAT), _(VLC_META_ARTIST) );
psz_val = input_item_GetArtist( p_item );
}
else if( !strcmp( psz_meta, "TITLE" ) )
{
psz_val = input_ItemGetInfo( p_item,
_(VLC_META_INFO_CAT), _(VLC_META_TITLE) );
if( psz_val == NULL )
psz_val = strdup( p_item->psz_name );
psz_val = input_item_GetTitle( p_item );
if( !psz_val )
psz_val = input_item_GetName( p_item );
}
else if( !strcmp( psz_meta, "ALBUM" ) )
{
psz_val = input_ItemGetInfo( p_item,
_(VLC_META_INFO_CAT), _(VLC_META_COLLECTION) );
psz_val = input_item_GetAlbum( p_item );
}
else if( !strcmp( psz_meta, "GENRE" ) )
{
psz_val = input_ItemGetInfo( p_item,
_(VLC_META_INFO_CAT), _(VLC_META_GENRE) );
}
else
{
psz_val = input_ItemGetInfo( p_item,
_(VLC_META_INFO_CAT), psz_meta );
psz_val = input_item_GetGenre( p_item );
}
#undef p_item
}
......
......@@ -184,9 +184,11 @@ static int Demux( demux_t *p_demux )
p_input = input_ItemNewExt( p_playlist, psz_mrl, psz_name,
0, NULL, i_duration );
if ( psz_artist && *psz_artist )
input_ItemAddInfo( p_input, _(VLC_META_INFO_CAT),
_(VLC_META_ARTIST), "%s", psz_artist );
input_item_SetArtist( p_input, psz_artist );
free( psz_artist );
input_ItemAddSubItem( p_current_input, p_input );
for( unsigned i = 0; i < i_options; i++ )
input_ItemAddOpt( p_input, ppsz_options[i], 0 );
......
......@@ -78,8 +78,8 @@ static VLCInfo *_o_sharedInstance = nil;
/* constants defined in vlc_meta.h */
[o_genre_lbl setStringValue: _NS(VLC_META_GENRE)];
[o_copyright_lbl setStringValue: _NS(VLC_META_COPYRIGHT)];
[o_collection_lbl setStringValue: _NS(VLC_META_COLLECTION)];
[o_seqNum_lbl setStringValue: _NS(VLC_META_SEQ_NUM)];
[o_collection_lbl setStringValue: _NS(VLC_META_ALBUM)];
[o_seqNum_lbl setStringValue: _NS(VLC_META_TRACK_NUMBER)];
[o_description_lbl setStringValue: _NS(VLC_META_DESCRIPTION)];
[o_date_lbl setStringValue: _NS(VLC_META_DATE)];
[o_language_lbl setStringValue: _NS(VLC_META_LANGUAGE)];
......
......@@ -1787,14 +1787,8 @@ static void Redraw( intf_thread_t *p_intf, time_t *t_last_refresh )
/* Meta data box */
int l = 0;
int i_len = strlen( VLC_META_INFO_CAT );
char psz_title[i_len + 3];
psz_title[0] = ' ';
psz_title[1] = '\0';
strcat( &psz_title[1], VLC_META_INFO_CAT );
psz_title[i_len + 1] = ' ';
psz_title[i_len + 2] = '\0';
DrawBox( p_sys->w, y++, 0, h, COLS, psz_title, p_sys->b_color );
DrawBox( p_sys->w, y++, 0, h, COLS, _("Meta-information"),
p_sys->b_color );
if( p_input )
{
......@@ -1819,9 +1813,9 @@ static void Redraw( intf_thread_t *p_intf, time_t *t_last_refresh )
case 3:
psz_meta_title = VLC_META_COPYRIGHT; break;
case 4:
psz_meta_title = VLC_META_COLLECTION; break;
psz_meta_title = VLC_META_ALBUM; break;
case 5:
psz_meta_title = VLC_META_SEQ_NUM; break;
psz_meta_title = VLC_META_TRACK_NUMBER; break;
case 6:
psz_meta_title = VLC_META_DESCRIPTION; break;
case 7:
......
......@@ -149,6 +149,7 @@ noinst_HEADERS = \
components/playlist/panels.hpp \
components/playlist/playlist.hpp \
components/playlist/selector.hpp \
components/playlist/sorting.h \
util/input_slider.hpp \
util/customwidgets.hpp \
util/qvlcframe.hpp \
......
......@@ -67,7 +67,7 @@ MetaPanel::MetaPanel( QWidget *parent,
/* Title, artist and album*/
ADD_META( VLC_META_TITLE, title_text ); /* OK */
ADD_META( VLC_META_ARTIST, artist_text ); /* OK */
ADD_META( VLC_META_COLLECTION, collection_text ); /* OK */
ADD_META( VLC_META_ALBUM, collection_text ); /* OK */
/* Genre Name */
/* TODO List id3genres.h is not includable yet ? */
......@@ -76,7 +76,7 @@ MetaPanel::MetaPanel( QWidget *parent,
metaLayout->addWidget( genre_text, line, 1, 1, 3 );
/* Number - on the same line */
metaLayout->addWidget( new QLabel( qtr( "Track Number" ) + " :" ),
metaLayout->addWidget( new QLabel( qtr( VLC_META_TRACK_NUMBER ) + " :" ),
line, 5, 1, 2 );
seqnum_text = new QLineEdit;
seqnum_text->setInputMask("0000");
......
......@@ -36,6 +36,8 @@
#include <QSettings>
#include "sorting.h"
/*************************************************************************
* Playlist item implementation
*************************************************************************/
......@@ -109,40 +111,12 @@ void PLItem::updateColumnHeaders()
{
item_col_strings.clear();
for( int i_index=1; i_index <= VLC_META_ENGINE_ART_URL; i_index *= 2 )
assert( i_showflags < COLUMN_END );
for( uint32_t i_index=1; i_index < COLUMN_END; i_index <<= 1 )
{
if( i_showflags & i_index )
{
switch( i_index )
{
case VLC_META_ENGINE_TRACKID:
item_col_strings.append( qtr( VLC_META_TRACKID ) );
break;
case VLC_META_ENGINE_ARTIST:
item_col_strings.append( qtr( VLC_META_ARTIST ) );
break;
case VLC_META_ENGINE_TITLE:
item_col_strings.append( qtr( VLC_META_TITLE ) );
break;
case VLC_META_ENGINE_DESCRIPTION:
item_col_strings.append( qtr( VLC_META_DESCRIPTION ) );
break;
case VLC_META_ENGINE_DURATION:
item_col_strings.append( qtr( VLC_META_DURATION ) );
break;
case VLC_META_ENGINE_GENRE:
item_col_strings.append( qtr( VLC_META_GENRE ) );
break;
case VLC_META_ENGINE_COLLECTION:
item_col_strings.append( qtr( VLC_META_COLLECTION ) );
break;
case VLC_META_ENGINE_SEQ_NUM:
item_col_strings.append( qtr( VLC_META_SEQ_NUM ) );
break;
default:
break;
}
}
item_col_strings.append( psz_column_title( i_index ) );
}
}
......@@ -206,63 +180,15 @@ void PLItem::update( playlist_item_t *p_item, bool iscurrent )
return;
}
#define ADD_META( item, meta ) \
psz_meta = input_item_Get ## meta ( item->p_input ); \
item_col_strings.append( qfu( psz_meta ) ); \
free( psz_meta );
assert( parentItem->i_showflags < COLUMN_END );
for( int i_index=1; i_index <= VLC_META_ENGINE_ART_URL; i_index *= 2 )
for( uint32_t i_index=1; i_index < COLUMN_END; i_index <<= 1 )
{
if( parentItem->i_showflags & i_index )
{
switch( i_index )
{
case VLC_META_ENGINE_ARTIST:
ADD_META( p_item, Artist );
break;
case VLC_META_ENGINE_TITLE:
char *psz_title;
psz_title = input_item_GetTitle( p_item->p_input );
if( psz_title )
{
ADD_META( p_item, Title );
free( psz_title );
char *psz = psz_column_meta( p_item->p_input, i_index );
item_col_strings.append( psz );
free( psz );
}
else
{
psz_title = input_item_GetName( p_item->p_input );
if( psz_title )
{
item_col_strings.append( qfu( psz_title ) );
}
free( psz_title );
}
break;
case VLC_META_ENGINE_DESCRIPTION:
ADD_META( p_item, Description );
break;
case VLC_META_ENGINE_DURATION:
secstotimestr( psz_duration,
input_item_GetDuration( p_item->p_input ) / 1000000 );
item_col_strings.append( QString( psz_duration ) );
break;
case VLC_META_ENGINE_GENRE:
ADD_META( p_item, Genre );
break;
case VLC_META_ENGINE_COLLECTION:
ADD_META( p_item, Album );
break;
case VLC_META_ENGINE_SEQ_NUM:
ADD_META( p_item, TrackNum );
break;
case VLC_META_ENGINE_TRACKID:
item_col_strings.append( QString::number( p_item->i_id ) );
break;
default:
break;
}
}
}
#undef ADD_META
}
......@@ -39,6 +39,8 @@
#include <QApplication>
#include <QSettings>
#include "sorting.h"
QIcon PLModel::icons[ITEM_TYPE_NUMBER];
static int PlaylistChanged( vlc_object_t *, const char *,
......@@ -72,8 +74,6 @@ PLModel::PLModel( playlist_t *_p_playlist, /* THEPL */
assert( i_depth == DEPTH_SEL || i_depth == DEPTH_PL );
p_intf = _p_intf;
p_playlist = _p_playlist;
i_items_to_append = 0;
b_need_update = false;
i_cached_id = -1;
i_cached_input_id = -1;
i_popup_item = i_popup_parent = -1;
......@@ -539,8 +539,6 @@ void PLModel::ProcessItemAppend( playlist_add_t *p_add )
{
playlist_item_t *p_item = NULL;
PLItem *newItem = NULL;
i_items_to_append--;
if( b_need_update ) return;
PLItem *nodeItem = FindById( rootItem, p_add->i_node );
PL_LOCK;
......@@ -719,23 +717,23 @@ void PLModel::sort( int column, Qt::SortOrder order )
#define CHECK_COLUMN( meta ) \
{ \
if( ( shownFlags() & VLC_META_ENGINE_##meta ) ) \
if( ( shownFlags() & meta ) ) \
i_index++; \
if( column == i_index ) \
{ \
i_flag = VLC_META_ENGINE_##meta; \
i_flag = meta; \
goto next; \
} \
}
CHECK_COLUMN( TRACKID );
CHECK_COLUMN( TITLE );
CHECK_COLUMN( DURATION );
CHECK_COLUMN( ARTIST );
CHECK_COLUMN( GENRE );
CHECK_COLUMN( COLLECTION );
CHECK_COLUMN( SEQ_NUM );
CHECK_COLUMN( DESCRIPTION );
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
......@@ -745,22 +743,10 @@ next:
playlist_item_t *p_root = playlist_ItemGetById( p_playlist,
rootItem->i_id,
true );
int i_mode;
switch( i_flag )
{
case VLC_META_ENGINE_TRACKID: i_mode = SORT_ID; break;
case VLC_META_ENGINE_TITLE: i_mode = SORT_TITLE_NODES_FIRST;break;
case VLC_META_ENGINE_DURATION: i_mode = SORT_DURATION; break;
case VLC_META_ENGINE_ARTIST: i_mode = SORT_ARTIST; break;
case VLC_META_ENGINE_GENRE: i_mode = SORT_GENRE; break;
case VLC_META_ENGINE_COLLECTION: i_mode = SORT_ALBUM; break;
case VLC_META_ENGINE_SEQ_NUM: i_mode = SORT_TRACK_NUMBER; break;
case VLC_META_ENGINE_DESCRIPTION:i_mode = SORT_DESCRIPTION; break;
default: i_mode = SORT_TITLE_NODES_FIRST;break;
}
if( p_root )
{
playlist_RecursiveNodeSort( p_playlist, p_root, i_mode,
playlist_RecursiveNodeSort( p_playlist, p_root,
i_column_sorting( i_flag ),
order == Qt::AscendingOrder ?
ORDER_NORMAL : ORDER_REVERSE );
p_playlist->b_reset_currently_playing = true;
......@@ -826,32 +812,16 @@ void PLModel::popup( QModelIndex & index, QPoint &point, QModelIndexList list )
void PLModel::viewchanged( int meta )
{
assert( meta );
if( rootItem )
{
int index=0;
switch( meta )
{
case VLC_META_ENGINE_TRACKID:
index=0; break;
case VLC_META_ENGINE_TITLE:
index=1; break;
case VLC_META_ENGINE_DURATION:
index=2; break;
case VLC_META_ENGINE_ARTIST:
index=3; break;
case VLC_META_ENGINE_GENRE:
index=4; break;
case VLC_META_ENGINE_COPYRIGHT:
index=5; break;
case VLC_META_ENGINE_COLLECTION:
index=6; break;
case VLC_META_ENGINE_SEQ_NUM:
index=7; break;
case VLC_META_ENGINE_DESCRIPTION:
index=8; break;
default:
break;
int index=-1;
while( meta )
{
index++;
meta >>= 1;
}
/* UNUSED emit layoutAboutToBeChanged(); */
index = __MIN( index, rootItem->item_col_strings.count() );
QModelIndex parent = createIndex( 0, 0, rootItem );
......@@ -969,11 +939,6 @@ static int ItemAppended( vlc_object_t *p_this, const char *psz_variable,
playlist_add_t *p_add = (playlist_add_t *)malloc( sizeof( playlist_add_t));
memcpy( p_add, nval.p_address, sizeof( playlist_add_t ) );
if( ++p_model->i_items_to_append >= 50 )
{
// p_model->b_need_update = true;
// return VLC_SUCCESS;
}
PLEvent *event = new PLEvent( p_add );
QApplication::postEvent( p_model, static_cast<QEvent*>(event) );
return VLC_SUCCESS;
......
......@@ -96,9 +96,6 @@ public:
int rowCount( const QModelIndex &parent = QModelIndex() ) const;
int columnCount( const QModelIndex &parent = QModelIndex() ) const;
bool b_need_update;
int i_items_to_append;
void rebuild(); void rebuild( playlist_item_t * );
bool hasRandom(); bool hasLoop(); bool hasRepeat();
......
/*****************************************************************************
* sorting.h : commun sorting & column display code
****************************************************************************
* Copyright © 2008 the VideoLAN team
* $Id$
*
* Authors: Rafaël Carré <funman@videolanorg>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/* You can use these numbers with | and & to determine what you want to show */
enum
{
COLUMN_NUMBER = 0x0001,
COLUMN_TITLE = 0x0002,
COLUMN_DURATION = 0x0004,
COLUMN_ARTIST = 0x0008,
COLUMN_GENRE = 0x0010,
COLUMN_ALBUM = 0x0020,
COLUMN_TRACK_NUMBER = 0x0040,
COLUMN_DESCRIPTION = 0x0080,
/* Add new entries here */
COLUMN_END
};
/* Return the title of a column */
static const char * psz_column_title( uint32_t i_column )
{
switch( i_column )
{
case COLUMN_NUMBER: return "";
case COLUMN_TITLE: return VLC_META_TITLE;
case COLUMN_DURATION: return _("Duration");
case COLUMN_ARTIST: return VLC_META_ARTIST;
case COLUMN_GENRE: return VLC_META_GENRE;
case COLUMN_ALBUM: return VLC_META_ALBUM;
case COLUMN_TRACK_NUMBER: return VLC_META_TRACK_NUMBER;
case COLUMN_DESCRIPTION: return VLC_META_DESCRIPTION;
default: abort();
}
}
/* Return the meta data associated with an item for a column
* Returned value has to be freed */
static char * psz_column_meta( input_item_t *p_item, uint32_t i_column )
{
char *psz;
int i_duration;
char psz_duration[MSTRTIME_MAX_SIZE];
switch( i_column )
{
case COLUMN_NUMBER:
return NULL;
case COLUMN_TITLE:
psz = input_item_GetTitle( p_item );
if( !psz )
psz = input_item_GetName( p_item );
return psz;
case COLUMN_DURATION:
i_duration = input_item_GetDuration( p_item ) / 1000000;
secstotimestr( psz_duration, i_duration );
return strdup( psz_duration );
case COLUMN_ARTIST:
return input_item_GetArtist( p_item );
case COLUMN_GENRE:
return input_item_GetGenre( p_item );
case COLUMN_ALBUM:
return input_item_GetAlbum( p_item );
case COLUMN_TRACK_NUMBER:
return input_item_GetTrackNum( p_item );
case COLUMN_DESCRIPTION:
return input_item_GetDescription( p_item );
default:
abort();
}
}
/* Return the playlist sorting mode for a given column */
static inline int i_column_sorting( uint32_t i_column )
{
switch( i_column )
{
case COLUMN_NUMBER: return SORT_ID;
case COLUMN_TITLE: return SORT_TITLE_NODES_FIRST;
case COLUMN_DURATION: return SORT_DURATION;
case COLUMN_ARTIST: return SORT_ARTIST;
case COLUMN_GENRE: return SORT_GENRE;
case COLUMN_ALBUM: return SORT_ALBUM;
case COLUMN_TRACK_NUMBER: return SORT_TRACK_NUMBER;
case COLUMN_DESCRIPTION: return SORT_DESCRIPTION;
default: abort();
}
}