Commit a99d1a2c authored by Jakob Leben's avatar Jakob Leben

Qt: update playlist dialog on rootChanged signal from model

parent 79081134
...@@ -665,6 +665,8 @@ void PLModel::rebuild( playlist_item_t *p_root, bool b_first ) ...@@ -665,6 +665,8 @@ void PLModel::rebuild( playlist_item_t *p_root, bool b_first )
/* And signal the view */ /* And signal the view */
reset(); reset();
if( p_root ) emit rootChanged();
} }
void PLModel::takeItem( PLItem *item ) void PLModel::takeItem( PLItem *item )
...@@ -713,7 +715,6 @@ void PLModel::removeItem( PLItem *item ) ...@@ -713,7 +715,6 @@ void PLModel::removeItem( PLItem *item )
{ {
rootItem = NULL; rootItem = NULL;
rebuild( p_playlist->p_playing ); rebuild( p_playlist->p_playing );
emit rootChanged();
} }
} }
......
...@@ -138,6 +138,7 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent, ...@@ -138,6 +138,7 @@ StandardPLPanel::StandardPLPanel( PlaylistWidget *_parent,
CONNECT( model, currentChanged( const QModelIndex& ), CONNECT( model, currentChanged( const QModelIndex& ),
this, handleExpansion( const QModelIndex& ) ); this, handleExpansion( const QModelIndex& ) );
CONNECT( model, rootChanged(), this, handleRootChange() );
} }
StandardPLPanel::~StandardPLPanel() StandardPLPanel::~StandardPLPanel()
...@@ -161,6 +162,30 @@ void StandardPLPanel::handleExpansion( const QModelIndex& index ) ...@@ -161,6 +162,30 @@ void StandardPLPanel::handleExpansion( const QModelIndex& index )
currentView->scrollTo( 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 */ /* PopupAdd Menu for the Add Menu */
void StandardPLPanel::popupAdd() void StandardPLPanel::popupAdd()
{ {
...@@ -233,37 +258,7 @@ void StandardPLPanel::search( const QString& searchText ) ...@@ -233,37 +258,7 @@ void StandardPLPanel::search( const QString& searchText )
/* This activated by the selector selection */ /* This activated by the selector selection */
void StandardPLPanel::setRoot( playlist_item_t *p_item ) 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 ); 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 ) void StandardPLPanel::removeItem( int i_id )
......
...@@ -98,6 +98,7 @@ public slots: ...@@ -98,6 +98,7 @@ public slots:
private slots: private slots:
void deleteSelection(); void deleteSelection();
void handleExpansion( const QModelIndex& ); void handleExpansion( const QModelIndex& );
void handleRootChange();
void gotoPlayingItem(); void gotoPlayingItem();
void search( const QString& searchText ); void search( const QString& searchText );
void popupAdd(); void popupAdd();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment