1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-09-02 10:24:01 +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 void
PlayableModel::setCurrentItem( const QModelIndex& index ) PlayableModel::setCurrentItem( const QModelIndex& index )
{ {
PlayableItem* oldEntry = itemFromIndex( m_currentIndex ); if ( m_currentIndex.isValid() )
if ( oldEntry )
{ {
tDebug() << "ISNT PLAYING ANYMORE:" << oldEntry->name(); PlayableItem* oldEntry = itemFromIndex( m_currentIndex );
oldEntry->setIsPlaying( false ); if ( oldEntry )
{
oldEntry->setIsPlaying( false );
}
} }
PlayableItem* entry = itemFromIndex( index ); PlayableItem* entry = itemFromIndex( index );
@@ -362,7 +364,6 @@ PlayableModel::setCurrentItem( const QModelIndex& index )
{ {
m_currentIndex = index; m_currentIndex = index;
m_currentUuid = entry->query()->id(); m_currentUuid = entry->query()->id();
tDebug() << "IS PLAYING NOW:" << entry->name();
entry->setIsPlaying( true ); entry->setIsPlaying( true );
} }
else 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() ); return itemFromIndex( index( itemIndex, 0, QModelIndex() ) );
if ( modelIndex.isValid() )
{
return static_cast<PlayableItem*>( modelIndex.internalPointer() );
}
else
{
return m_rootItem;
}
} }
void void
PlayableModel::appendArtist( const Tomahawk::artist_ptr& artist ) PlayableModel::appendArtist( const Tomahawk::artist_ptr& artist )
{ {