[vlc-devel] commit: qt4: refactor, remove nonsense & re-enable popup-adding items to playlist (Jakob Leben )

git version control git at videolan.org
Sat Sep 12 07:25:26 CEST 2009


vlc | branch: master | Jakob Leben <jleben at videolan.org> | Sat Sep 12 07:15:00 2009 +0200| [346b6cdff934d35a77d5c80e3c9ea29df106cc37] | committer: Jakob Leben 

qt4: refactor, remove nonsense & re-enable popup-adding items to playlist

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

 modules/gui/qt4/components/playlist/panels.hpp     |    1 -
 modules/gui/qt4/components/playlist/playlist.cpp   |    8 +---
 modules/gui/qt4/components/playlist/playlist.hpp   |    3 -
 .../gui/qt4/components/playlist/standardpanel.cpp  |   56 ++++++++++----------
 4 files changed, 29 insertions(+), 39 deletions(-)

diff --git a/modules/gui/qt4/components/playlist/panels.hpp b/modules/gui/qt4/components/playlist/panels.hpp
index c30db22..8949179 100644
--- a/modules/gui/qt4/components/playlist/panels.hpp
+++ b/modules/gui/qt4/components/playlist/panels.hpp
@@ -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 );
diff --git a/modules/gui/qt4/components/playlist/playlist.cpp b/modules/gui/qt4/components/playlist/playlist.cpp
index 4d70cc5..96d5012 100644
--- a/modules/gui/qt4/components/playlist/playlist.cpp
+++ b/modules/gui/qt4/components/playlist/playlist.cpp
@@ -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 );
diff --git a/modules/gui/qt4/components/playlist/playlist.hpp b/modules/gui/qt4/components/playlist/playlist.hpp
index 38270e6..8ac7a53 100644
--- a/modules/gui/qt4/components/playlist/playlist.hpp
+++ b/modules/gui/qt4/components/playlist/playlist.hpp
@@ -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
diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index e39f5f2..e572cc2 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -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 )




More information about the vlc-devel mailing list