]> git.sesse.net Git - vlc/commitdiff
Qt: update playlist dialog on rootChanged signal from model
authorJakob Leben <jleben@videolan.org>
Wed, 10 Feb 2010 08:08:41 +0000 (09:08 +0100)
committerJakob Leben <jleben@videolan.org>
Wed, 10 Feb 2010 10:07:39 +0000 (11:07 +0100)
modules/gui/qt4/components/playlist/playlist_model.cpp
modules/gui/qt4/components/playlist/standardpanel.cpp
modules/gui/qt4/components/playlist/standardpanel.hpp

index 6c6272f454edb573d1d15ecac918ec89601b54b8..8ef12357f2ed2e38c17ef360a665d9c5164ef272 100644 (file)
@@ -665,6 +665,8 @@ void PLModel::rebuild( playlist_item_t *p_root, bool b_first )
 
     /* And signal the view */
     reset();
+
+    if( p_root ) emit rootChanged();
 }
 
 void PLModel::takeItem( PLItem *item )
@@ -713,7 +715,6 @@ void PLModel::removeItem( PLItem *item )
     {
         rootItem = NULL;
         rebuild( p_playlist->p_playing );
-        emit rootChanged();
     }
 }
 
index 4d073a439e866bf1c2a3104df37552528ea281bd..4ce86172d0f46d03797c0ec4b72ba620dda55e1c 100644 (file)
@@ -138,6 +138,7 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
 
     CONNECT( model, currentChanged( const QModelIndex& ),
              this, handleExpansion( const QModelIndex& ) );
+    CONNECT( model, rootChanged(), this, handleRootChange() );
 }
 
 StandardPLPanel::~StandardPLPanel()
@@ -161,6 +162,30 @@ void StandardPLPanel::handleExpansion( const QModelIndex& index )
     currentView->scrollTo( index );
 }
 
+void StandardPLPanel::handleRootChange()
+{
+    /* needed for popupAdd() */
+    PLItem *root = model->getItem( QModelIndex() );
+    currentRootId = root->id();
+
+    locationBar->setIndex( QModelIndex() );
+
+    /* enable/disable adding */
+    if( currentRootId == THEPL->p_playing->i_id )
+    {
+        addButton->setEnabled( true );
+        addButton->setToolTip( qtr(I_PL_ADDPL) );
+    }
+    else if( THEPL->p_media_library &&
+             currentRootId == THEPL->p_media_library->i_id )
+    {
+        addButton->setEnabled( true );
+        addButton->setToolTip( qtr(I_PL_ADDML) );
+    }
+    else
+        addButton->setEnabled( false );
+}
+
 /* PopupAdd Menu for the Add Menu */
 void StandardPLPanel::popupAdd()
 {
@@ -233,37 +258,7 @@ void StandardPLPanel::search( const QString& searchText )
 /* This activated by the selector selection */
 void StandardPLPanel::setRoot( playlist_item_t *p_item )
 {
-    QPL_LOCK;
-    assert( 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( qfu(psz_title) );
-    free( psz_title );*/
-
-    QPL_UNLOCK;
-
-    /* do THE job */
     model->rebuild( p_item );
-
-    locationBar->setIndex( QModelIndex() );
-
-    /* enable/disable adding */
-    if( p_item == THEPL->p_playing )
-    {
-        addButton->setEnabled( true );
-        addButton->setToolTip( qtr(I_PL_ADDPL) );
-    }
-    else if( THEPL->p_media_library && p_item == THEPL->p_media_library )
-    {
-        addButton->setEnabled( true );
-        addButton->setToolTip( qtr(I_PL_ADDML) );
-    }
-    else
-        addButton->setEnabled( false );
 }
 
 void StandardPLPanel::removeItem( int i_id )
index dd5aebfe8fb4c6c5ce1b51a25c16fd304065a886..d16e46c161f4f50fb196207b7795c75cdf34be34 100644 (file)
@@ -98,6 +98,7 @@ public slots:
 private slots:
     void deleteSelection();
     void handleExpansion( const QModelIndex& );
+    void handleRootChange();
     void gotoPlayingItem();
     void search( const QString& searchText );
     void popupAdd();