sorting.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * sorting.h : commun sorting & column display code
00003  ****************************************************************************
00004  * Copyright © 2008 the VideoLAN team
00005  * $Id$
00006  *
00007  * Authors: Rafaël Carré <funman@videolanorg>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00022  *****************************************************************************/
00023 
00024 /* You can use these numbers with | and & to determine what you want to show */
00025 enum
00026 {
00027     COLUMN_NUMBER       = 0x0001,
00028     COLUMN_TITLE        = 0x0002,
00029     COLUMN_DURATION     = 0x0004,
00030     COLUMN_ARTIST       = 0x0008,
00031     COLUMN_GENRE        = 0x0010,
00032     COLUMN_ALBUM        = 0x0020,
00033     COLUMN_TRACK_NUMBER = 0x0040,
00034     COLUMN_DESCRIPTION  = 0x0080,
00035 
00036     /* Add new entries here and update the COLUMN_END value*/
00037 
00038     COLUMN_END          = 0x0100
00039 };
00040 
00041 /* Return the title of a column */
00042 static const char * psz_column_title( uint32_t i_column )
00043 {
00044     switch( i_column )
00045     {
00046     case COLUMN_NUMBER:          return _("ID");
00047     case COLUMN_TITLE:           return VLC_META_TITLE;
00048     case COLUMN_DURATION:        return _("Duration");
00049     case COLUMN_ARTIST:          return VLC_META_ARTIST;
00050     case COLUMN_GENRE:           return VLC_META_GENRE;
00051     case COLUMN_ALBUM:           return VLC_META_ALBUM;
00052     case COLUMN_TRACK_NUMBER:    return VLC_META_TRACK_NUMBER;
00053     case COLUMN_DESCRIPTION:     return VLC_META_DESCRIPTION;
00054     default: abort();
00055     }
00056 }
00057 
00058 /* Return the meta data associated with an item for a column
00059  * Returned value has to be freed */
00060 static char * psz_column_meta( input_item_t *p_item, uint32_t i_column )
00061 {
00062     char *psz;
00063     int i_duration;
00064     char psz_duration[MSTRTIME_MAX_SIZE];
00065     switch( i_column )
00066     {
00067     case COLUMN_NUMBER:
00068         return NULL;
00069     case COLUMN_TITLE:
00070         psz = input_item_GetTitle( p_item );
00071         if( !psz )
00072             psz = input_item_GetName( p_item );
00073         return psz;
00074     case COLUMN_DURATION:
00075         i_duration = input_item_GetDuration( p_item ) / 1000000;
00076         secstotimestr( psz_duration, i_duration );
00077         return strdup( psz_duration );
00078     case COLUMN_ARTIST:
00079         return input_item_GetArtist( p_item );
00080     case COLUMN_GENRE:
00081         return input_item_GetGenre( p_item );
00082     case COLUMN_ALBUM:
00083         return input_item_GetAlbum( p_item );
00084     case COLUMN_TRACK_NUMBER:
00085         return input_item_GetTrackNum( p_item );
00086     case COLUMN_DESCRIPTION:
00087         return input_item_GetDescription( p_item );
00088     default:
00089         abort();
00090     }
00091 }
00092 
00093 /* Return the playlist sorting mode for a given column */
00094 static inline int i_column_sorting( uint32_t i_column )
00095 {
00096     switch( i_column )
00097     {
00098     case COLUMN_NUMBER:         return SORT_ID;
00099     case COLUMN_TITLE:          return SORT_TITLE_NODES_FIRST;
00100     case COLUMN_DURATION:       return SORT_DURATION;
00101     case COLUMN_ARTIST:         return SORT_ARTIST;
00102     case COLUMN_GENRE:          return SORT_GENRE;
00103     case COLUMN_ALBUM:          return SORT_ALBUM;
00104     case COLUMN_TRACK_NUMBER:   return SORT_TRACK_NUMBER;
00105     case COLUMN_DESCRIPTION:    return SORT_DESCRIPTION;
00106     default: abort();
00107     }
00108 }

Generated on Wed Aug 13 08:02:37 2008 for VLC by  doxygen 1.5.1