1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-09-02 18:33:16 +02:00

* Fixed trying to access root-item's name().

This commit is contained in:
Christian Muehlhaeuser
2012-12-16 12:38:50 +01:00
parent 8894d16c87
commit 4260e3664d

View File

@@ -350,11 +350,13 @@ PlayableModel::headerData( int section, Qt::Orientation orientation, int role )
void
PlayableModel::setCurrentItem( const QModelIndex& index )
{
PlayableItem* oldEntry = itemFromIndex( m_currentIndex );
if ( oldEntry )
if ( m_currentIndex.isValid() )
{
tDebug() << "ISNT PLAYING ANYMORE:" << oldEntry->name();
oldEntry->setIsPlaying( false );
PlayableItem* oldEntry = itemFromIndex( m_currentIndex );
if ( oldEntry )
{
oldEntry->setIsPlaying( false );
}
}
PlayableItem* entry = itemFromIndex( index );
@@ -362,7 +364,6 @@ PlayableModel::setCurrentItem( const QModelIndex& index )
{
m_currentIndex = index;
m_currentUuid = entry->query()->id();
tDebug() << "IS PLAYING NOW:" << entry->name();
entry->setIsPlaying( true );
}
else
@@ -769,19 +770,14 @@ PlayableModel::itemFromIndex( const QModelIndex& index ) const
}
}
PlayableItem *PlayableModel::itemFromIndex(int itemIndex) const
PlayableItem*
PlayableModel::itemFromIndex( int itemIndex ) const
{
QModelIndex modelIndex = index( itemIndex, 0, QModelIndex() );
if ( modelIndex.isValid() )
{
return static_cast<PlayableItem*>( modelIndex.internalPointer() );
}
else
{
return m_rootItem;
}
return itemFromIndex( index( itemIndex, 0, QModelIndex() ) );
}
void
PlayableModel::appendArtist( const Tomahawk::artist_ptr& artist )
{