mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-01 03:40:16 +02:00
* Reset PlayableModel's currentIndex when it gets removed from the model.
This commit is contained in:
@@ -312,7 +312,7 @@ PlayableModel::headerData( int section, Qt::Orientation orientation, int role )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
PlayableModel::setCurrentItem( const QModelIndex& index )
|
PlayableModel::setCurrentIndex( const QModelIndex& index )
|
||||||
{
|
{
|
||||||
PlayableItem* oldEntry = itemFromIndex( m_currentIndex );
|
PlayableItem* oldEntry = itemFromIndex( m_currentIndex );
|
||||||
if ( oldEntry )
|
if ( oldEntry )
|
||||||
@@ -332,6 +332,8 @@ PlayableModel::setCurrentItem( const QModelIndex& index )
|
|||||||
m_currentIndex = QModelIndex();
|
m_currentIndex = QModelIndex();
|
||||||
m_currentUuid = QString();
|
m_currentUuid = QString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit currentIndexChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -596,6 +598,9 @@ PlayableModel::removeIndex( const QModelIndex& index, bool moreToCome )
|
|||||||
PlayableItem* item = itemFromIndex( index );
|
PlayableItem* item = itemFromIndex( index );
|
||||||
if ( item )
|
if ( item )
|
||||||
{
|
{
|
||||||
|
if ( index == m_currentIndex )
|
||||||
|
setCurrentIndex( QModelIndex() );
|
||||||
|
|
||||||
emit beginRemoveRows( index.parent(), index.row(), index.row() );
|
emit beginRemoveRows( index.parent(), index.row(), index.row() );
|
||||||
delete item;
|
delete item;
|
||||||
emit endRemoveRows();
|
emit endRemoveRows();
|
||||||
|
@@ -123,8 +123,10 @@ signals:
|
|||||||
void indexPlayable( const QModelIndex& index );
|
void indexPlayable( const QModelIndex& index );
|
||||||
void changed();
|
void changed();
|
||||||
|
|
||||||
|
void currentIndexChanged();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void setCurrentItem( const QModelIndex& index );
|
virtual void setCurrentIndex( const QModelIndex& index );
|
||||||
|
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user