1 /*****************************************************************************
2 * sorting.h : commun sorting & column display code
3 ****************************************************************************
4 * Copyright © 2008 the VideoLAN team
7 * Authors: Rafaël Carré <funman@videolanorg>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /* You can use these numbers with | and & to determine what you want to show */
27 COLUMN_NUMBER = 0x0001,
28 COLUMN_TITLE = 0x0002,
29 COLUMN_DURATION = 0x0004,
30 COLUMN_ARTIST = 0x0008,
31 COLUMN_GENRE = 0x0010,
32 COLUMN_ALBUM = 0x0020,
33 COLUMN_TRACK_NUMBER = 0x0040,
34 COLUMN_DESCRIPTION = 0x0080,
37 /* Add new entries here and update the COLUMN_END value*/
42 #define COLUMN_DEFAULT (COLUMN_TITLE|COLUMN_DURATION|COLUMN_ALBUM)
44 /* Return the title of a column */
45 static const char * psz_column_title( uint32_t i_column )
49 case COLUMN_NUMBER: return _("ID");
50 case COLUMN_TITLE: return VLC_META_TITLE;
51 case COLUMN_DURATION: return _("Duration");
52 case COLUMN_ARTIST: return VLC_META_ARTIST;
53 case COLUMN_GENRE: return VLC_META_GENRE;
54 case COLUMN_ALBUM: return VLC_META_ALBUM;
55 case COLUMN_TRACK_NUMBER: return VLC_META_TRACK_NUMBER;
56 case COLUMN_DESCRIPTION: return VLC_META_DESCRIPTION;
57 case COLUMN_URI: return _("URI");
62 /* Return the meta data associated with an item for a column
63 * Returned value has to be freed */
64 static char * psz_column_meta( input_item_t *p_item, uint32_t i_column )
67 char psz_duration[MSTRTIME_MAX_SIZE];
73 return input_item_GetTitleFbName( p_item );
75 i_duration = input_item_GetDuration( p_item ) / 1000000;
76 secstotimestr( psz_duration, i_duration );
77 return strdup( psz_duration );
79 return input_item_GetArtist( p_item );
81 return input_item_GetGenre( p_item );
83 return input_item_GetAlbum( p_item );
84 case COLUMN_TRACK_NUMBER:
85 return input_item_GetTrackNum( p_item );
86 case COLUMN_DESCRIPTION:
87 return input_item_GetDescription( p_item );
89 return input_item_GetURI( p_item );
95 /* Return the playlist sorting mode for a given column */
96 static inline int i_column_sorting( uint32_t i_column )
100 case COLUMN_NUMBER: return SORT_ID;
101 case COLUMN_TITLE: return SORT_TITLE_NODES_FIRST;
102 case COLUMN_DURATION: return SORT_DURATION;
103 case COLUMN_ARTIST: return SORT_ARTIST;
104 case COLUMN_GENRE: return SORT_GENRE;
105 case COLUMN_ALBUM: return SORT_ALBUM;
106 case COLUMN_TRACK_NUMBER: return SORT_TRACK_NUMBER;
107 case COLUMN_DESCRIPTION: return SORT_DESCRIPTION;
108 case COLUMN_URI: return SORT_URI;