Commit fd930cde authored by Erwan Tulou's avatar Erwan Tulou

skins2: cosmetic (playlist)

Remove variables that were never used, especially in tree_update structure
parent a714732f
...@@ -36,10 +36,8 @@ ...@@ -36,10 +36,8 @@
typedef struct tree_update typedef struct tree_update
{ {
int i_type; int i_type;
int i_parent;
int i_id; int i_id;
bool b_active_item; bool b_active_item;
bool b_visible;
} tree_update; } tree_update;
/// Tree variable /// Tree variable
...@@ -189,7 +187,6 @@ public: ...@@ -189,7 +187,6 @@ public:
return depth; return depth;
} }
private: private:
/// Get root node /// Get root node
......
...@@ -32,14 +32,11 @@ ...@@ -32,14 +32,11 @@
#include <vlc_playlist.h> #include <vlc_playlist.h>
#include "../utils/ustring.hpp" #include "../utils/ustring.hpp"
Playtree::Playtree( intf_thread_t *pIntf ): Playtree::Playtree( intf_thread_t *pIntf ): VarTree( pIntf )
VarTree( pIntf ), m_currentItem( NULL )
{ {
// Get the VLC playlist object // Get the VLC playlist object
m_pPlaylist = pIntf->p_sys->p_playlist; m_pPlaylist = pIntf->p_sys->p_playlist;
i_items_to_append = 0;
buildTree(); buildTree();
} }
...@@ -124,37 +121,43 @@ void Playtree::onChange() ...@@ -124,37 +121,43 @@ void Playtree::onChange()
void Playtree::onUpdateItem( int id ) void Playtree::onUpdateItem( int id )
{ {
Iterator it = findById( id ); Iterator it = findById( id );
tree_update descr;
descr.b_active_item = false;
if( it != end() ) if( it != end() )
{ {
// Update the item // Update the item
playlist_item_t* pNode = (playlist_item_t*)(it->getData()); playlist_item_t* pNode = (playlist_item_t*)(it->getData());
UString *pName = new UString( getIntf(), pNode->p_input->psz_name ); UString *pName = new UString( getIntf(), pNode->p_input->psz_name );
it->setString( UStringPtr( pName ) ); it->setString( UStringPtr( pName ) );
tree_update descr;
descr.i_type = 0;
descr.i_id = id;
descr.b_active_item = false;
notify( &descr );
} }
else else
{ {
msg_Warn(getIntf(), "cannot find node with id %d", id ); msg_Warn(getIntf(), "cannot find node with id %d", id );
} }
descr.i_type = 0;
notify( &descr );
} }
void Playtree::onUpdateCurrent( bool b_active ) void Playtree::onUpdateCurrent( bool b_active )
{ {
if( !b_active ) for( VarTree::Iterator it = begin(); it != end(); it = getNextItem( it ) )
{
if( it->isPlaying() )
{ {
if( !m_currentItem )
return;
Iterator it = findById( m_currentItem->i_id );
if( it != end() )
it->setPlaying( false ); it->setPlaying( false );
m_currentItem = NULL;
tree_update descr;
descr.i_type = 0;
descr.i_id = it->getId();
descr.b_active_item = false;
notify( &descr );
break;
} }
else }
if( b_active )
{ {
playlist_Lock( m_pPlaylist ); playlist_Lock( m_pPlaylist );
...@@ -168,20 +171,17 @@ void Playtree::onUpdateCurrent( bool b_active ) ...@@ -168,20 +171,17 @@ void Playtree::onUpdateCurrent( bool b_active )
Iterator it = findById( current->i_id ); Iterator it = findById( current->i_id );
if( it != end() ) if( it != end() )
it->setPlaying( true ); it->setPlaying( true );
m_currentItem = current;
playlist_Unlock( m_pPlaylist ); playlist_Unlock( m_pPlaylist );
}
tree_update descr; tree_update descr;
descr.b_active_item = true;
descr.i_type = 0; descr.i_type = 0;
descr.i_id = current->i_id;
descr.b_active_item = true;
notify( &descr ); notify( &descr );
}
} }
/// \todo keep a list of "recently removed" to avoid looking up if we
// already removed it
void Playtree::onDelete( int i_id ) void Playtree::onDelete( int i_id )
{ {
Iterator item = findById( i_id ) ; Iterator item = findById( i_id ) ;
...@@ -192,45 +192,41 @@ void Playtree::onDelete( int i_id ) ...@@ -192,45 +192,41 @@ void Playtree::onDelete( int i_id )
item->setDeleted( true ); item->setDeleted( true );
tree_update descr; tree_update descr;
descr.i_id = i_id;
descr.i_type = 3; descr.i_type = 3;
descr.b_visible = parent ? parent->isExpanded() : true; descr.i_id = i_id;
notify( &descr ); notify( &descr );
if( parent ) if( parent )
parent->removeChild( item ); parent->removeChild( item );
} }
} }
void Playtree::onAppend( playlist_add_t *p_add ) void Playtree::onAppend( playlist_add_t *p_add )
{ {
i_items_to_append --;
Iterator node = findById( p_add->i_node ); Iterator node = findById( p_add->i_node );
if( node != end() ) if( node != end() )
{ {
playlist_Lock( m_pPlaylist ); playlist_Lock( m_pPlaylist );
playlist_item_t *p_item = playlist_ItemGetById( playlist_item_t *p_item =
m_pPlaylist, p_add->i_item ); playlist_ItemGetById( m_pPlaylist, p_add->i_item );
if( !p_item ) if( !p_item )
{ {
playlist_Unlock( m_pPlaylist ); playlist_Unlock( m_pPlaylist );
return; return;
} }
UString *pName = new UString( getIntf(), UString *pName = new UString( getIntf(),
p_item->p_input->psz_name ); p_item->p_input->psz_name );
node->add( p_add->i_item, UStringPtr( pName ), node->add( p_add->i_item, UStringPtr( pName ),
false,false, false, p_item->i_flags & PLAYLIST_RO_FLAG, false,false, false, p_item->i_flags & PLAYLIST_RO_FLAG,
p_item ); p_item );
playlist_Unlock( m_pPlaylist ); playlist_Unlock( m_pPlaylist );
}
tree_update descr; tree_update descr;
descr.i_id = p_add->i_item;
descr.i_parent = p_add->i_node;
descr.b_visible = node->isExpanded();
descr.i_type = 2; descr.i_type = 2;
descr.i_id = p_add->i_item;
notify( &descr ); notify( &descr );
}
} }
void Playtree::buildNode( playlist_item_t *pNode, VarTree &rTree ) void Playtree::buildNode( playlist_item_t *pNode, VarTree &rTree )
...@@ -239,8 +235,8 @@ void Playtree::buildNode( playlist_item_t *pNode, VarTree &rTree ) ...@@ -239,8 +235,8 @@ void Playtree::buildNode( playlist_item_t *pNode, VarTree &rTree )
{ {
UString *pName = new UString( getIntf(), UString *pName = new UString( getIntf(),
pNode->pp_children[i]->p_input->psz_name ); pNode->pp_children[i]->p_input->psz_name );
rTree.add( pNode->pp_children[i]->i_id, UStringPtr( pName ), rTree.add(
false, pNode->pp_children[i]->i_id, UStringPtr( pName ), false,
playlist_CurrentPlayingItem(m_pPlaylist) == pNode->pp_children[i], playlist_CurrentPlayingItem(m_pPlaylist) == pNode->pp_children[i],
false, pNode->pp_children[i]->i_flags & PLAYLIST_RO_FLAG, false, pNode->pp_children[i]->i_flags & PLAYLIST_RO_FLAG,
pNode->pp_children[i] ); pNode->pp_children[i] );
...@@ -256,8 +252,6 @@ void Playtree::buildTree() ...@@ -256,8 +252,6 @@ void Playtree::buildTree()
clear(); clear();
playlist_Lock( m_pPlaylist ); playlist_Lock( m_pPlaylist );
i_items_to_append = 0;
clear(); clear();
/* TODO: Let user choose view - Stick with category ATM */ /* TODO: Let user choose view - Stick with category ATM */
......
...@@ -56,9 +56,6 @@ public: ...@@ -56,9 +56,6 @@ public:
/// Function called to notify playlist item delete /// Function called to notify playlist item delete
void onDelete( int ); void onDelete( int );
/// Items waiting to be appended
int i_items_to_append;
private: private:
/// VLC playlist object /// VLC playlist object
playlist_t *m_pPlaylist; playlist_t *m_pPlaylist;
...@@ -68,9 +65,6 @@ private: ...@@ -68,9 +65,6 @@ private:
/// Update Node's children /// Update Node's children
void buildNode( playlist_item_t *p_node, VarTree &m_pNode ); void buildNode( playlist_item_t *p_node, VarTree &m_pNode );
/// keep track of item being played
playlist_item_t* m_currentItem;
}; };
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment