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()
}
else if( role == IsCurrentsParentNodeRole )
{
- return QVariant( isParent( index, current_index ) );
+ return QVariant( isParent( index, currentIndex() ) );
}
return QVariant();
}
bool PLModel::isCurrent( const QModelIndex &index ) const
{
- return index == current_index;
+ return getItem( index )->p_input == THEMIM->currentInputItem();
}
int PLModel::itemId( const QModelIndex &index ) const
return QModelIndex();
}
-void PLModel::cacheCurrent( const QModelIndex ¤t )
+QModelIndex PLModel::currentIndex() const
{
- current_index = current;
-}
-
-QModelIndex PLModel::currentIndex()
-{
- return current_index;
+ 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 );
}
QModelIndex PLModel::parent( const QModelIndex &index ) const
/* Invalidate cache */
i_cached_id = i_cached_input_id = -1;
- current_index = QModelIndex();
if( rootItem ) rootItem->removeChildren();
i_cached_id = -1;
i_cached_input_id = -1;
- current_index = QModelIndex();
if( item->parentItem ) {
int i = item->parentItem->children.indexOf( item );
}
i_cached_id = i_cached_input_id = -1;
- current_index = QModelIndex();
if( count )
{