]> git.sesse.net Git - vlc/commitdiff
qt4: refactor, remove nonsense & re-enable popup-adding items to playlist
authorJakob Leben <jleben@videolan.org>
Sat, 12 Sep 2009 05:15:00 +0000 (07:15 +0200)
committerJakob Leben <jleben@videolan.org>
Sat, 12 Sep 2009 05:17:37 +0000 (07:17 +0200)
modules/gui/qt4/components/playlist/panels.hpp
modules/gui/qt4/components/playlist/playlist.cpp
modules/gui/qt4/components/playlist/playlist.hpp
modules/gui/qt4/components/playlist/standardpanel.cpp

index c30db2213cf02640e9e479952f22b800d9132478..89491796c403038339b0f626a3bf8870afa5be6e 100644 (file)
@@ -90,7 +90,6 @@ private slots:
     void gotoPlayingItem();
     void doPopup( QModelIndex index, QPoint point );
     void search( const QString& searchText );
-    void setCurrentRootId( playlist_item_t * );
     void popupAdd();
     void popupSelectColumn( QPoint );
     void toggleColumnShown( int );
index 4d70cc510db70a7ae00082acd922a036f6ec1d44..96d50122aafd10d5d15fe6e59849ce808b049d22 100644 (file)
@@ -80,13 +80,7 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_i ) : p_intf ( _p_i )
     CONNECT( selector, activated( playlist_item_t * ),
              rightPanel, setRoot( playlist_item_t * ) );
 
-    /* Connect the activated() to the rootChanged() signal
-       This will be used by StandardPLPanel to setCurrentRootId, that will
-       change the label of the addButton  */
-    connect( selector, SIGNAL( activated( playlist_item_t * ) ),
-             this, SIGNAL( rootChanged( playlist_item_t * ) ) );
-
-    emit rootChanged( p_root );
+    rightPanel->setRoot( p_root );
 
     /* Add the two sides of the QSplitter */
     addWidget( leftW );
index 38270e6749f6da026cc9e64762c81b9c2c57e90e..8ac7a539d649ccca6f2fada2930bf3ae3f974347 100644 (file)
@@ -60,9 +60,6 @@ protected:
     virtual void dropEvent( QDropEvent *);
     virtual void dragEnterEvent( QDragEnterEvent * );
     virtual void closeEvent( QCloseEvent * );
-
-signals:
-    void rootChanged( playlist_item_t *);
 };
 
 class ArtLabel : public CoverArtLabel
index e39f5f2081aa82fce05336a8de249f3fd509990c..e572cc284c8d01802eddcc9a064a6504152b4bac 100644 (file)
@@ -107,8 +107,6 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
              this, handleExpansion( const QModelIndex& ) );
 
     currentRootId = -1;
-    CONNECT( parent, rootChanged( playlist_item_t * ),
-             this, setCurrentRootId( playlist_item_t * ) );
 
     /* Buttons configuration */
     QHBoxLayout *buttons = new QHBoxLayout;
@@ -228,31 +226,6 @@ void StandardPLPanel::handleExpansion( const QModelIndex& index )
     view->scrollTo( index );
 }
 
-void StandardPLPanel::setCurrentRootId( playlist_item_t *p_item )
-{
-    if( p_item == THEPL->p_local_category ||
-        p_item == THEPL->p_local_onelevel )
-    {
-        addButton->setEnabled( true );
-        addButton->setToolTip( qtr(I_PL_ADDPL) );
-    }
-    else if( ( THEPL->p_ml_category && p_item == THEPL->p_ml_category) ||
-             ( THEPL->p_ml_onelevel && p_item == THEPL->p_ml_onelevel ) )
-    {
-        addButton->setEnabled( true );
-        addButton->setToolTip( qtr(I_PL_ADDML) );
-    }
-    else
-        addButton->setEnabled( false );
-
-    /* <jleben> do we need to lock here? */
-    playlist_Lock( THEPL );
-    char *psz_title = input_item_GetName( p_item->p_input );
-    title->setText( psz_title );
-    free( psz_title );
-    playlist_Unlock( THEPL );
-}
-
 /* PopupAdd Menu for the Add Menu */
 void StandardPLPanel::popupAdd()
 {
@@ -320,11 +293,38 @@ void StandardPLPanel::doPopup( QModelIndex index, QPoint point )
 void StandardPLPanel::setRoot( playlist_item_t *p_item )
 {
     QPL_LOCK;
-    p_item = playlist_GetPreferredNode( THEPL, p_item );
     assert( p_item );
+
+    p_item = playlist_GetPreferredNode( THEPL, p_item );
+
+    /* needed for popupAdd() */
+    currentRootId = p_item->i_id;
+
+    /* cosmetics, ..still need playlist locking.. */
+    char *psz_title = input_item_GetName( p_item->p_input );
+    title->setText( psz_title );
+    free( psz_title );
+
     QPL_UNLOCK;
 
+    /* do THE job */
     model->rebuild( p_item );
+
+    /* enable/disable adding */
+    if( p_item == THEPL->p_local_category ||
+        p_item == THEPL->p_local_onelevel )
+    {
+        addButton->setEnabled( true );
+        addButton->setToolTip( qtr(I_PL_ADDPL) );
+    }
+    else if( ( THEPL->p_ml_category && p_item == THEPL->p_ml_category) ||
+              ( THEPL->p_ml_onelevel && p_item == THEPL->p_ml_onelevel ) )
+    {
+        addButton->setEnabled( true );
+        addButton->setToolTip( qtr(I_PL_ADDML) );
+    }
+    else
+        addButton->setEnabled( false );
 }
 
 void StandardPLPanel::removeItem( int i_id )