Commit 0455f985 authored by Ilkka Ollakka's avatar Ilkka Ollakka

Qt4: cache currentItem index

Not sure if it's the best way, but this enables
to show the current item even when input is stopped.
parent 15745ba5
......@@ -73,6 +73,7 @@ PLModel::PLModel( playlist_t *_p_playlist, /* THEPL */
i_cached_input_id = -1;
i_popup_item = i_popup_parent = -1;
sortingMenu = NULL;
current_index = QModelIndex();
rootItem = NULL; /* PLItem rootItem, will be set in rebuild( ) */
......@@ -98,6 +99,8 @@ PLModel::PLModel( playlist_t *_p_playlist, /* THEPL */
this, processItemAppend( int, int ) );
CONNECT( THEMIM, playlistItemRemoved( int ),
this, processItemRemoval( int ) );
CONNECT( this, currentChanged( const QModelIndex &) ,
this, cacheCurrent( const QModelIndex &) );
}
PLModel::~PLModel()
......@@ -380,7 +383,7 @@ QVariant PLModel::data( const QModelIndex &index, int role ) const
bool PLModel::isCurrent( const QModelIndex &index ) const
{
return getItem( index )->p_input == THEMIM->currentInputItem();
return index == current_index;
}
int PLModel::itemId( const QModelIndex &index ) const
......@@ -429,12 +432,14 @@ QModelIndex PLModel::index( PLItem *item, int column ) const
return QModelIndex();
}
void PLModel::cacheCurrent( const QModelIndex &current )
{
current_index = current;
}
QModelIndex PLModel::currentIndex()
{
input_thread_t *p_input_thread = THEMIM->getInput();
if( !p_input_thread ) return QModelIndex();
PLItem *item = findByInput( rootItem, input_GetItem( p_input_thread )->i_id );
return index( item, 0 );
return current_index;
}
QModelIndex PLModel::parent( const QModelIndex &index ) const
......
......@@ -161,6 +161,7 @@ private:
PLItem *p_cached_item_bi;
int i_cached_id;
int i_cached_input_id;
QModelIndex current_index;
private slots:
void popupPlay();
......@@ -175,6 +176,7 @@ private slots:
void processInputItemUpdate( input_thread_t* p_input );
void processItemRemoval( int i_id );
void processItemAppend( int item, int parent );
void cacheCurrent( const QModelIndex & );
};
class PlMimeData : public QMimeData
......
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