1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-21 00:09:47 +01:00

* Reset PlayableModel's currentIndex when it gets removed from the model.

This commit is contained in:
Christian Muehlhaeuser 2012-12-23 08:12:49 +01:00
parent 3823774dca
commit 96b9f38b2e
2 changed files with 9 additions and 2 deletions

View File

@ -312,7 +312,7 @@ PlayableModel::headerData( int section, Qt::Orientation orientation, int role )
void
PlayableModel::setCurrentItem( const QModelIndex& index )
PlayableModel::setCurrentIndex( const QModelIndex& index )
{
PlayableItem* oldEntry = itemFromIndex( m_currentIndex );
if ( oldEntry )
@ -332,6 +332,8 @@ PlayableModel::setCurrentItem( const QModelIndex& index )
m_currentIndex = QModelIndex();
m_currentUuid = QString();
}
emit currentIndexChanged();
}
@ -596,6 +598,9 @@ PlayableModel::removeIndex( const QModelIndex& index, bool moreToCome )
PlayableItem* item = itemFromIndex( index );
if ( item )
{
if ( index == m_currentIndex )
setCurrentIndex( QModelIndex() );
emit beginRemoveRows( index.parent(), index.row(), index.row() );
delete item;
emit endRemoveRows();

View File

@ -123,8 +123,10 @@ signals:
void indexPlayable( const QModelIndex& index );
void changed();
void currentIndexChanged();
public slots:
virtual void setCurrentItem( const QModelIndex& index );
virtual void setCurrentIndex( const QModelIndex& index );
virtual void clear();