Commit 6a4273c2 authored by Jakob Leben's avatar Jakob Leben

Qt: playlist: fix updating of currently playing item

- When input changes, update visible item after currentItem has been set.
- Check if item is current when adding it.
parent a1c69e8e
...@@ -577,7 +577,6 @@ bool PLModel::canEdit() const ...@@ -577,7 +577,6 @@ bool PLModel::canEdit() const
void PLModel::processInputItemUpdate( input_thread_t *p_input ) void PLModel::processInputItemUpdate( input_thread_t *p_input )
{ {
if( !p_input ) return; if( !p_input ) return;
processInputItemUpdate( input_GetItem( p_input ) );
if( p_input && !( p_input->b_dead || !vlc_object_alive( p_input ) ) ) if( p_input && !( p_input->b_dead || !vlc_object_alive( p_input ) ) )
{ {
PLItem *item = findByInput( rootItem, input_GetItem( p_input )->i_id ); PLItem *item = findByInput( rootItem, input_GetItem( p_input )->i_id );
...@@ -588,7 +587,9 @@ void PLModel::processInputItemUpdate( input_thread_t *p_input ) ...@@ -588,7 +587,9 @@ void PLModel::processInputItemUpdate( input_thread_t *p_input )
{ {
currentItem = NULL; currentItem = NULL;
} }
processInputItemUpdate( input_GetItem( p_input ) );
} }
void PLModel::processInputItemUpdate( input_item_t *p_item ) void PLModel::processInputItemUpdate( input_item_t *p_item )
{ {
if( !p_item || p_item->i_id <= 0 ) return; if( !p_item || p_item->i_id <= 0 ) return;
...@@ -607,6 +608,7 @@ void PLModel::processItemAppend( int i_item, int i_parent ) ...@@ -607,6 +608,7 @@ void PLModel::processItemAppend( int i_item, int i_parent )
{ {
playlist_item_t *p_item = NULL; playlist_item_t *p_item = NULL;
PLItem *newItem = NULL; PLItem *newItem = NULL;
input_thread_t *currentInputThread;
PLItem *nodeItem = findById( rootItem, i_parent ); PLItem *nodeItem = findById( rootItem, i_parent );
if( !nodeItem ) return; if( !nodeItem ) return;
...@@ -621,10 +623,18 @@ void PLModel::processItemAppend( int i_item, int i_parent ) ...@@ -621,10 +623,18 @@ void PLModel::processItemAppend( int i_item, int i_parent )
newItem = new PLItem( p_item, nodeItem ); newItem = new PLItem( p_item, nodeItem );
PL_UNLOCK; PL_UNLOCK;
currentInputThread = THEMIM->getInput();
if( currentInputThread &&
newItem->p_input == input_GetItem( currentInputThread ) )
currentItem = newItem;
beginInsertRows( index( nodeItem, 0 ), nodeItem->childCount(), nodeItem->childCount() ); beginInsertRows( index( nodeItem, 0 ), nodeItem->childCount(), nodeItem->childCount() );
nodeItem->appendChild( newItem ); nodeItem->appendChild( newItem );
endInsertRows(); endInsertRows();
updateTreeItem( newItem );
if( currentItem == newItem )
emit currentChanged( index( newItem, 0 ) );
return; return;
end: end:
PL_UNLOCK; PL_UNLOCK;
......
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