00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <vlc/vlc.h>
00025
00026 #include "playlist.hpp"
00027 #include "../utils/ustring.hpp"
00028
00029 Playlist::Playlist( intf_thread_t *pIntf ): VarList( pIntf )
00030 {
00031
00032 m_pPlaylist = pIntf->p_sys->p_playlist;
00033
00034 buildList();
00035 }
00036
00037
00038 Playlist::~Playlist()
00039 {
00040 }
00041
00042
00043 void Playlist::delSelected()
00044 {
00045
00046 int index = 0;
00047 ConstIterator it;
00048 for( it = begin(); it != end(); it++ )
00049 {
00050 if( (*it).m_selected )
00051 {
00052 playlist_item_t *p_item = playlist_LockItemGetByPos( m_pPlaylist,
00053 index );
00054 playlist_LockDelete( m_pPlaylist, p_item->input.i_id );
00055 }
00056 else
00057 {
00058 index++;
00059 }
00060 }
00061
00062 notify();
00063 }
00064
00065
00066 void Playlist::action( Elem_t *pItem )
00067 {
00068
00069 int index = 0;
00070 ConstIterator it;
00071 for( it = begin(); it != end(); it++ )
00072 {
00073 if( &*it == pItem ) break;
00074 index++;
00075 }
00076
00077 if( index < size() )
00078 {
00079 playlist_Goto( m_pPlaylist, index );
00080 }
00081 }
00082
00083
00084 void Playlist::onChange()
00085 {
00086 buildList();
00087 notify();
00088 }
00089
00090
00091 void Playlist::buildList()
00092 {
00093 clear();
00094
00095 vlc_mutex_lock( &m_pPlaylist->object_lock );
00096 for( int i = 0; i < m_pPlaylist->i_size; i++ )
00097 {
00098
00099 UString *pName =
00100 new UString( getIntf(), m_pPlaylist->pp_items[i]->input.psz_name );
00101
00102 bool playing = (i == m_pPlaylist->i_index );
00103
00104 m_list.push_back( Elem_t( UStringPtr( pName ), false, playing ) );
00105 }
00106 vlc_mutex_unlock( &m_pPlaylist->object_lock );
00107 }
00108