[vlc-devel] commit: Qt: update playlist dialog on rootChanged signal from model ( Jakob Leben )
git version control
git at videolan.org
Wed Feb 10 11:07:50 CET 2010
vlc | branch: master | Jakob Leben <jleben at videolan.org> | Wed Feb 10 09:08:41 2010 +0100| [a99d1a2c2a3bcfdcc4ec38b68fd9b35bdf78f5c4] | committer: Jakob Leben
Qt: update playlist dialog on rootChanged signal from model
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a99d1a2c2a3bcfdcc4ec38b68fd9b35bdf78f5c4
---
.../gui/qt4/components/playlist/playlist_model.cpp | 3 +-
.../gui/qt4/components/playlist/standardpanel.cpp | 55 +++++++++-----------
.../gui/qt4/components/playlist/standardpanel.hpp | 1 +
3 files changed, 28 insertions(+), 31 deletions(-)
diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp
index 6c6272f..8ef1235 100644
--- a/modules/gui/qt4/components/playlist/playlist_model.cpp
+++ b/modules/gui/qt4/components/playlist/playlist_model.cpp
@@ -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();
}
}
diff --git a/modules/gui/qt4/components/playlist/standardpanel.cpp b/modules/gui/qt4/components/playlist/standardpanel.cpp
index 4d073a4..4ce8617 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.cpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.cpp
@@ -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 )
diff --git a/modules/gui/qt4/components/playlist/standardpanel.hpp b/modules/gui/qt4/components/playlist/standardpanel.hpp
index dd5aebf..d16e46c 100644
--- a/modules/gui/qt4/components/playlist/standardpanel.hpp
+++ b/modules/gui/qt4/components/playlist/standardpanel.hpp
@@ -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();
More information about the vlc-devel
mailing list