[vlc-commits] commit: skins2: cosmetic (playlist) (Erwan Tulou )

git at videolan.org git at videolan.org
Sun Jan 16 23:05:51 CET 2011


vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Sun Jan 16 16:37:44 2011 +0100| [fd930cde1c899fe9dfae6f3b4957eb5ad67a1cc1] | committer: Erwan Tulou 

skins2: cosmetic (playlist)

Remove variables that were never used, especially in tree_update structure

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=fd930cde1c899fe9dfae6f3b4957eb5ad67a1cc1
---

 modules/gui/skins2/utils/var_tree.hpp |    3 -
 modules/gui/skins2/vars/playtree.cpp  |   92 +++++++++++++++-----------------
 modules/gui/skins2/vars/playtree.hpp  |    6 --
 3 files changed, 43 insertions(+), 58 deletions(-)

diff --git a/modules/gui/skins2/utils/var_tree.hpp b/modules/gui/skins2/utils/var_tree.hpp
index fa0af1c..bde1ff6 100644
--- a/modules/gui/skins2/utils/var_tree.hpp
+++ b/modules/gui/skins2/utils/var_tree.hpp
@@ -36,10 +36,8 @@
 typedef struct tree_update
 {
      int i_type;
-     int i_parent;
      int i_id;
      bool b_active_item;
-     bool b_visible;
 } tree_update;
 
 /// Tree variable
@@ -189,7 +187,6 @@ public:
         return depth;
     }
 
-
 private:
 
     /// Get root node
diff --git a/modules/gui/skins2/vars/playtree.cpp b/modules/gui/skins2/vars/playtree.cpp
index d0bf1ca..4d3d67b 100644
--- a/modules/gui/skins2/vars/playtree.cpp
+++ b/modules/gui/skins2/vars/playtree.cpp
@@ -32,14 +32,11 @@
 #include <vlc_playlist.h>
 #include "../utils/ustring.hpp"
 
-Playtree::Playtree( intf_thread_t *pIntf ):
-    VarTree( pIntf ), m_currentItem( NULL )
+Playtree::Playtree( intf_thread_t *pIntf ): VarTree( pIntf )
 {
     // Get the VLC playlist object
     m_pPlaylist = pIntf->p_sys->p_playlist;
 
-    i_items_to_append = 0;
-
     buildTree();
 }
 
@@ -124,37 +121,43 @@ void Playtree::onChange()
 void Playtree::onUpdateItem( int id )
 {
     Iterator it = findById( id );
-    tree_update descr;
-    descr.b_active_item = false;
     if( it != end() )
     {
         // Update the item
         playlist_item_t* pNode = (playlist_item_t*)(it->getData());
         UString *pName = new UString( getIntf(), pNode->p_input->psz_name );
         it->setString( UStringPtr( pName ) );
+
+        tree_update descr;
+        descr.i_type = 0;
+        descr.i_id = id;
+        descr.b_active_item = false;
+        notify( &descr );
     }
     else
     {
         msg_Warn(getIntf(), "cannot find node with id %d", id );
     }
-    descr.i_type = 0;
-    notify( &descr );
 }
 
-
 void Playtree::onUpdateCurrent( bool b_active )
 {
-    if( !b_active )
+    for( VarTree::Iterator it = begin(); it != end(); it = getNextItem( it ) )
     {
-        if( !m_currentItem )
-            return;
-
-        Iterator it = findById( m_currentItem->i_id );
-        if( it != end() )
-            it->setPlaying( false );
-        m_currentItem = NULL;
+       if( it->isPlaying() )
+       {
+           it->setPlaying( false );
+
+           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 );
 
@@ -168,20 +171,17 @@ void Playtree::onUpdateCurrent( bool b_active )
         Iterator it = findById( current->i_id );
         if( it != end() )
             it->setPlaying( true );
-        m_currentItem = current;
 
         playlist_Unlock( m_pPlaylist );
-    }
 
-    tree_update descr;
-    descr.b_active_item = true;
-    descr.i_type = 0;
-    notify( &descr );
+        tree_update descr;
+        descr.i_type = 0;
+        descr.i_id = current->i_id;
+        descr.b_active_item = true;
+        notify( &descr );
+    }
 }
 
-
-/// \todo keep a list of "recently removed" to avoid looking up if we
-//  already removed it
 void Playtree::onDelete( int i_id )
 {
     Iterator item = findById( i_id ) ;
@@ -192,45 +192,41 @@ void Playtree::onDelete( int i_id )
         item->setDeleted( true );
 
         tree_update descr;
-        descr.i_id = i_id;
         descr.i_type = 3;
-        descr.b_visible = parent ? parent->isExpanded() : true;
+        descr.i_id = i_id;
         notify( &descr );
 
         if( parent )
             parent->removeChild( item );
     }
-
 }
 
 void Playtree::onAppend( playlist_add_t *p_add )
 {
-    i_items_to_append --;
-
     Iterator node = findById( p_add->i_node );
     if( node != end() )
     {
         playlist_Lock( m_pPlaylist );
-        playlist_item_t *p_item = playlist_ItemGetById(
-                                    m_pPlaylist, p_add->i_item );
+        playlist_item_t *p_item =
+            playlist_ItemGetById( m_pPlaylist, p_add->i_item );
         if( !p_item )
         {
             playlist_Unlock( m_pPlaylist );
             return;
         }
+
         UString *pName = new UString( getIntf(),
                                       p_item->p_input->psz_name );
         node->add( p_add->i_item, UStringPtr( pName ),
-                  false,false, false, p_item->i_flags & PLAYLIST_RO_FLAG,
-                  p_item );
+                   false,false, false, p_item->i_flags & PLAYLIST_RO_FLAG,
+                   p_item );
         playlist_Unlock( m_pPlaylist );
+
+        tree_update descr;
+        descr.i_type = 2;
+        descr.i_id = p_add->i_item;
+        notify( &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;
-    notify( &descr );
 }
 
 void Playtree::buildNode( playlist_item_t *pNode, VarTree &rTree )
@@ -239,11 +235,11 @@ void Playtree::buildNode( playlist_item_t *pNode, VarTree &rTree )
     {
         UString *pName = new UString( getIntf(),
                                    pNode->pp_children[i]->p_input->psz_name );
-        rTree.add( pNode->pp_children[i]->i_id, UStringPtr( pName ),
-                     false,
-                     playlist_CurrentPlayingItem(m_pPlaylist) == pNode->pp_children[i],
-                     false, pNode->pp_children[i]->i_flags & PLAYLIST_RO_FLAG,
-                     pNode->pp_children[i] );
+        rTree.add(
+            pNode->pp_children[i]->i_id, UStringPtr( pName ), false,
+            playlist_CurrentPlayingItem(m_pPlaylist) == pNode->pp_children[i],
+            false, pNode->pp_children[i]->i_flags & PLAYLIST_RO_FLAG,
+            pNode->pp_children[i] );
         if( pNode->pp_children[i]->i_children > 0 )
         {
             buildNode( pNode->pp_children[i], rTree.back() );
@@ -256,8 +252,6 @@ void Playtree::buildTree()
     clear();
     playlist_Lock( m_pPlaylist );
 
-    i_items_to_append = 0;
-
     clear();
 
     /* TODO: Let user choose view - Stick with category ATM */
diff --git a/modules/gui/skins2/vars/playtree.hpp b/modules/gui/skins2/vars/playtree.hpp
index 871cc08..c7bde2b 100644
--- a/modules/gui/skins2/vars/playtree.hpp
+++ b/modules/gui/skins2/vars/playtree.hpp
@@ -56,9 +56,6 @@ public:
     /// Function called to notify playlist item delete
     void onDelete( int );
 
-    /// Items waiting to be appended
-    int i_items_to_append;
-
 private:
     /// VLC playlist object
     playlist_t *m_pPlaylist;
@@ -68,9 +65,6 @@ private:
 
     /// Update Node's children
     void buildNode( playlist_item_t *p_node, VarTree &m_pNode );
-
-    /// keep track of item being played
-    playlist_item_t* m_currentItem;
 };
 
 #endif



More information about the vlc-commits mailing list