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: c3240548a88a58e5206869b94450b8b01f3b1ad6 $
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_TITLE          = 0x0001,
00028     COLUMN_DURATION       = 0x0002,
00029     COLUMN_ARTIST         = 0x0004,
00030     COLUMN_GENRE          = 0x0008,
00031     COLUMN_ALBUM          = 0x0010,
00032     COLUMN_TRACK_NUMBER   = 0x0020,
00033     COLUMN_DESCRIPTION    = 0x0040,
00034     COLUMN_URI            = 0x0080,
00035     COLUMN_NUMBER         = 0x0100,
00036 
00037     /* Add new entries here and update the COLUMN_END value*/
00038 
00039     COLUMN_END          = 0x0200
00040 };
00041 
00042 #define COLUMN_DEFAULT (COLUMN_TITLE|COLUMN_DURATION|COLUMN_ALBUM)
00043 
00044 /* Return the title of a column */
00045 static inline const char * psz_column_title( uint32_t i_column )
00046 {
00047     switch( i_column )
00048     {
00049     case COLUMN_NUMBER:          return _("ID");
00050     case COLUMN_TITLE:           return VLC_META_TITLE;
00051     case COLUMN_DURATION:        return _("Duration");
00052     case COLUMN_ARTIST:          return VLC_META_ARTIST;
00053     case COLUMN_GENRE:           return VLC_META_GENRE;
00054     case COLUMN_ALBUM:           return VLC_META_ALBUM;
00055     case COLUMN_TRACK_NUMBER:    return VLC_META_TRACK_NUMBER;
00056     case COLUMN_DESCRIPTION:     return VLC_META_DESCRIPTION;
00057     case COLUMN_URI:             return _("URI");
00058     default: abort();
00059     }
00060 }
00061 
00062 /* Return the meta data associated with an item for a column
00063  * Returned value has to be freed */
00064 static inline char * psz_column_meta( input_item_t *p_item, uint32_t i_column )
00065 {
00066     int i_duration;
00067     char psz_duration[MSTRTIME_MAX_SIZE];
00068     switch( i_column )
00069     {
00070     case COLUMN_NUMBER:
00071         return NULL;
00072     case COLUMN_TITLE:
00073         return input_item_GetTitleFbName( p_item );
00074     case COLUMN_DURATION:
00075         i_duration = input_item_GetDuration( p_item ) / 1000000;
00076         if( i_duration == 0 ) return NULL;
00077         secstotimestr( psz_duration, i_duration );
00078         return strdup( psz_duration );
00079     case COLUMN_ARTIST:
00080         return input_item_GetArtist( p_item );
00081     case COLUMN_GENRE:
00082         return input_item_GetGenre( p_item );
00083     case COLUMN_ALBUM:
00084         return input_item_GetAlbum( p_item );
00085     case COLUMN_TRACK_NUMBER:
00086         return input_item_GetTrackNum( p_item );
00087     case COLUMN_DESCRIPTION:
00088         return input_item_GetDescription( p_item );
00089     case COLUMN_URI:
00090         return input_item_GetURI( p_item );
00091     default:
00092         abort();
00093     }
00094 }
00095 
00096 /* Return the playlist sorting mode for a given column */
00097 static inline int i_column_sorting( uint32_t i_column )
00098 {
00099     switch( i_column )
00100     {
00101     case COLUMN_NUMBER:         return SORT_ID;
00102     case COLUMN_TITLE:          return SORT_TITLE_NODES_FIRST;
00103     case COLUMN_DURATION:       return SORT_DURATION;
00104     case COLUMN_ARTIST:         return SORT_ARTIST;
00105     case COLUMN_GENRE:          return SORT_GENRE;
00106     case COLUMN_ALBUM:          return SORT_ALBUM;
00107     case COLUMN_TRACK_NUMBER:   return SORT_TRACK_NUMBER;
00108     case COLUMN_DESCRIPTION:    return SORT_DESCRIPTION;
00109     case COLUMN_URI:            return SORT_URI;
00110     default: abort();
00111     }
00112 }

Generated on Tue May 25 08:04:57 2010 for VLC by  doxygen 1.5.6