]> git.sesse.net Git - vlc/commitdiff
Qt iconView: browse into node when it spawns subitems
authorJakob Leben <jleben@videolan.org>
Thu, 28 Jan 2010 02:12:03 +0000 (03:12 +0100)
committerJakob Leben <jleben@videolan.org>
Thu, 28 Jan 2010 02:13:29 +0000 (03:13 +0100)
modules/gui/qt4/components/playlist/standardpanel.cpp
modules/gui/qt4/components/playlist/standardpanel.hpp

index d1f79935b36e5b1336426223755d81d9e13d8eb2..9f9c20aa6406c69d816e3b09a3dde97c02d4ce6e 100644 (file)
@@ -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 );
+}
index 02efce4a36cd8f4554a37dfec340908075949763..3a841b1988a46647ccdb54dbebca0d81d5ce442f 100644 (file)
@@ -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