From 25100efbbd8c26cd81c4192daeb117b78cc68d76 Mon Sep 17 00:00:00 2001 From: Jakob Leben Date: Wed, 17 Feb 2010 00:58:49 +0100 Subject: [PATCH] Qt: refactor and (again) emit currentChanged when processing new items --- .../qt4/components/playlist/playlist_model.cpp | 15 +++++++-------- modules/gui/qt4/input_manager.hpp | 4 ++++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/modules/gui/qt4/components/playlist/playlist_model.cpp b/modules/gui/qt4/components/playlist/playlist_model.cpp index 29595620a1..fdb9f288a9 100644 --- a/modules/gui/qt4/components/playlist/playlist_model.cpp +++ b/modules/gui/qt4/components/playlist/playlist_model.cpp @@ -350,9 +350,7 @@ QVariant PLModel::data( const QModelIndex &index, int role ) const bool PLModel::isCurrent( const QModelIndex &index ) const { - input_thread_t *p_input_thread = THEMIM->getInput(); - if( !p_input_thread ) return false; - return getItem( index )->p_input == input_GetItem( p_input_thread ); + return getItem( index )->p_input == THEMIM->currentInputItem(); } int PLModel::itemId( const QModelIndex &index ) const @@ -621,7 +619,10 @@ void PLModel::processItemAppend( int i_item, int i_parent ) PL_LOCK; p_item = playlist_ItemGetById( p_playlist, i_item ); - if( !p_item || p_item->i_flags & PLAYLIST_DBL_FLAG ) goto end; + if( !p_item || p_item->i_flags & PLAYLIST_DBL_FLAG ) + { + PL_UNLOCK; return; + } for( pos = 0; pos < p_item->p_parent->i_children; pos++ ) if( p_item->p_parent->pp_children[pos] == p_item ) break; @@ -633,10 +634,8 @@ void PLModel::processItemAppend( int i_item, int i_parent ) nodeItem->insertChild( newItem, pos ); endInsertRows(); - return; -end: - PL_UNLOCK; - return; + if( newItem->p_input == THEMIM->currentInputItem() ) + emit currentChanged( index( newItem, 0 ) ); } diff --git a/modules/gui/qt4/input_manager.hpp b/modules/gui/qt4/input_manager.hpp index 229f568cb6..726c6bdea0 100644 --- a/modules/gui/qt4/input_manager.hpp +++ b/modules/gui/qt4/input_manager.hpp @@ -253,6 +253,10 @@ public: input_thread_t *getInput() { return p_input; } InputManager *getIM() { return im; } + inline input_item_t *currentInputItem() + { + return ( p_input ? input_GetItem( p_input ) : NULL ); + } vout_thread_t* getVout(); aout_instance_t *getAout(); -- 2.39.5