[vlc-commits] commit: skins2: playlist, fix selection issue (Erwan Tulou )

git at videolan.org git at videolan.org
Tue Aug 10 18:57:08 CEST 2010


vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Tue Aug 10 18:45:36 2010 +0200| [0a29e83bbd79ca0a4e2c634808a3e350bd04090a] | committer: Erwan Tulou 

skins2: playlist, fix selection issue

selected items may not be erased (e.g ready-only items). Compute the new
lastSelected only if no more selection exists.

This fixes the extra selection popping up when one tries to
erase the media library for instance.

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

 modules/gui/skins2/controls/ctrl_tree.cpp |   28 +++++++++++++++++++++-------
 1 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/modules/gui/skins2/controls/ctrl_tree.cpp b/modules/gui/skins2/controls/ctrl_tree.cpp
index a0a438e..914dd52 100644
--- a/modules/gui/skins2/controls/ctrl_tree.cpp
+++ b/modules/gui/skins2/controls/ctrl_tree.cpp
@@ -167,7 +167,7 @@ void CtrlTree::onUpdate( Subject<VarTree, tree_update> &rTree,
     }
     else if( arg->i_type == 3 ) // item-del
     {
-        /* Make sure firstPos and lastSelected are still valid */
+        /* Make sure firstPos is valid */
         while( m_firstPos->m_deleted &&
                m_firstPos != (m_flat ? m_rTree.firstLeaf()
                                      : m_rTree.begin()) )
@@ -269,10 +269,10 @@ void CtrlTree::handleEvent( EvtGeneric &rEvent )
             /* Find first non selected item before m_pLastSelected */
             VarTree::Iterator it_sel = m_flat ? m_rTree.firstLeaf()
                                               : m_rTree.begin();
-            for( it = m_flat ? m_rTree.firstLeaf() : m_rTree.begin();
+            for( it = (m_flat ? m_rTree.firstLeaf() : m_rTree.begin());
                  it != m_rTree.end();
-                 it = m_flat ? m_rTree.getNextLeaf( it )
-                             : m_rTree.getNextVisibleItem( it ) )
+                 it = (m_flat ? m_rTree.getNextLeaf( it )
+                              : m_rTree.getNextVisibleItem( it )) )
             {
                 if( &*it == m_pLastSelected ) break;
                 if( !it->m_selected ) it_sel = it;
@@ -281,9 +281,23 @@ void CtrlTree::handleEvent( EvtGeneric &rEvent )
             /* Delete selected stuff */
             m_rTree.delSelected();
 
-            /* Select it_sel */
-            it_sel->m_selected = true;
-            m_pLastSelected = &*it_sel;
+            /* Verify if there is still sthg selected (e.g read-only items) */
+            m_pLastSelected = NULL;
+            for( it = (m_flat ? m_rTree.firstLeaf() : m_rTree.begin());
+                 it != m_rTree.end();
+                 it = (m_flat ? m_rTree.getNextLeaf( it )
+                              : m_rTree.getNextVisibleItem( it )) )
+            {
+                if( it->m_selected )
+                    m_pLastSelected = &*it;
+            }
+
+            /* if everything was deleted, use it_sel as last selection */
+            if( !m_pLastSelected )
+            {
+                it_sel->m_selected = true;
+                m_pLastSelected = &*it_sel;
+            }
 
             // Redraw the control
             makeImage();



More information about the vlc-commits mailing list