[vlc-devel] commit: Qt iconView: browse into node when it spawns subitems (Jakob Leben )

git version control git at videolan.org
Thu Jan 28 03:13:44 CET 2010


vlc | branch: master | Jakob Leben <jleben at videolan.org> | Thu Jan 28 03:12:03 2010 +0100| [e0a92345a179401427f6a896626b6259a5c4709d] | committer: Jakob Leben 

Qt iconView: browse into node when it spawns subitems

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

 .../gui/qt4/components/playlist/standardpanel.cpp  |   34 ++++++++++++++++++--
 .../gui/qt4/components/playlist/standardpanel.hpp  |    3 ++
 2 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index d1f7993..9f9c20a 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -113,6 +113,10 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
     }
 
     getSettings()->endGroup();
+
+    last_activated_id = -1;
+    CONNECT( THEMIM, inputChanged( input_thread_t * ),
+             this, handleInputChange( input_thread_t * ) );
 }
 
 StandardPLPanel::~StandardPLPanel()
@@ -363,13 +367,37 @@ void StandardPLPanel::wheelEvent( QWheelEvent *e )
 
 void StandardPLPanel::activate( const QModelIndex &index )
 {
-    if( model->hasChildren( index ) && currentView == iconView )
+    last_activated_id = model->itemId( index );
+    if( model->hasChildren( index ) )
     {
-        iconView->setRootIndex( index );
-        title->setText( index.data().toString() );
+        if( currentView == iconView ) {
+            iconView->setRootIndex( index );
+            title->setText( index.data().toString() );
+        }
     }
     else
     {
         model->activateItem( index );
     }
 }
+
+void StandardPLPanel::handleInputChange( input_thread_t *p_input_thread )
+{
+    input_item_t *p_input_item = input_GetItem( p_input_thread );
+    if( !p_input_item ) return;
+
+    playlist_Lock( THEPL );
+
+    playlist_item_t *p_item = playlist_ItemGetByInput( THEPL, p_input_item );
+
+    if( p_item  && p_item->p_parent &&
+        p_item->p_parent->i_id == last_activated_id )
+    {
+        QModelIndex index = model->index( p_item->p_parent->i_id, 0 );
+        iconView->setRootIndex( index );
+        title->setText( index.data().toString() );
+        last_activated_id = p_item->i_id;
+    }
+
+    playlist_Unlock( THEPL );
+}
diff --git a/modules/gui/qt4/components/playlist/standardpanel.hpp b/modules/gui/qt4/components/playlist/standardpanel.hpp
index 02efce4..3a841b1 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.hpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.hpp
@@ -76,6 +76,8 @@ private:
     int currentRootId;
     QSignalMapper *selectColumnsSigMapper;
 
+    int last_activated_id;
+
     enum {
       TREE_VIEW = 0,
       ICON_VIEW,
@@ -99,6 +101,7 @@ private slots:
     void toggleColumnShown( int );
     void toggleView();
     void activate( const QModelIndex & );
+    void handleInputChange( input_thread_t * );
 };
 
 #endif




More information about the vlc-devel mailing list