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,
36
/* Add new entries here and update the COLUMN_END value*/
41
/* Return the title of a column */
42
static const char * psz_column_title( uint32_t i_column )
46
case COLUMN_NUMBER: return _("ID");
47
case COLUMN_TITLE: return VLC_META_TITLE;
48
case COLUMN_DURATION: return _("Duration");
49
case COLUMN_ARTIST: return VLC_META_ARTIST;
50
case COLUMN_GENRE: return VLC_META_GENRE;
51
case COLUMN_ALBUM: return VLC_META_ALBUM;
52
case COLUMN_TRACK_NUMBER: return VLC_META_TRACK_NUMBER;
53
case COLUMN_DESCRIPTION: return VLC_META_DESCRIPTION;
58
/* Return the meta data associated with an item for a column
59
* Returned value has to be freed */
60
static char * psz_column_meta( input_item_t *p_item, uint32_t i_column )
64
char psz_duration[MSTRTIME_MAX_SIZE];
70
psz = input_item_GetTitle( p_item );
72
psz = input_item_GetName( 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 );
93
/* Return the playlist sorting mode for a given column */
94
static inline int i_column_sorting( uint32_t i_column )
98
case COLUMN_NUMBER: return SORT_ID;
99
case COLUMN_TITLE: return SORT_TITLE_NODES_FIRST;
100
case COLUMN_DURATION: return SORT_DURATION;
101
case COLUMN_ARTIST: return SORT_ARTIST;
102
case COLUMN_GENRE: return SORT_GENRE;
103
case COLUMN_ALBUM: return SORT_ALBUM;
104
case COLUMN_TRACK_NUMBER: return SORT_TRACK_NUMBER;
105
case COLUMN_DESCRIPTION: return SORT_DESCRIPTION;