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( ) */
this, processItemAppend( int, int ) );
CONNECT( THEMIM, playlistItemRemoved( int ),
this, processItemRemoval( int ) );
+ CONNECT( this, currentChanged( const QModelIndex &) ,
+ this, cacheCurrent( const QModelIndex &) );
}
PLModel::~PLModel()
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
return QModelIndex();
}
+void PLModel::cacheCurrent( const QModelIndex ¤t )
+{
+ 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
PLItem *p_cached_item_bi;
int i_cached_id;
int i_cached_input_id;
+ QModelIndex current_index;
private slots:
void popupPlay();
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