mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-12 09:04:33 +02:00
* Added custom UserRoles to access model's data.
This commit is contained in:
committed by
Michael Zanetti
parent
db56757bc8
commit
fc4e42befa
@@ -294,6 +294,26 @@ PlayableModel::data( const QModelIndex& index, int role ) const
|
||||
if ( !entry )
|
||||
return QVariant();
|
||||
|
||||
if ( role == PlayableProxyModel::TypeRole )
|
||||
{
|
||||
if ( entry->result() )
|
||||
{
|
||||
return Tomahawk::TypeResult;
|
||||
}
|
||||
else if ( entry->query() )
|
||||
{
|
||||
return Tomahawk::TypeQuery;
|
||||
}
|
||||
else if ( entry->artist() )
|
||||
{
|
||||
return Tomahawk::TypeArtist;
|
||||
}
|
||||
else if ( entry->album() )
|
||||
{
|
||||
return Tomahawk::TypeAlbum;
|
||||
}
|
||||
}
|
||||
|
||||
int column = index.column();
|
||||
if ( role < CoverIDRole && role >= Qt::UserRole )
|
||||
{
|
||||
@@ -310,33 +330,6 @@ PlayableModel::data( const QModelIndex& index, int role ) const
|
||||
break;
|
||||
}
|
||||
|
||||
case IsPlayingRole:
|
||||
{
|
||||
return entry->isPlaying();
|
||||
break;
|
||||
}
|
||||
|
||||
case PlayableProxyModel::TypeRole:
|
||||
{
|
||||
if ( entry->result() )
|
||||
{
|
||||
return Tomahawk::TypeResult;
|
||||
}
|
||||
else if ( entry->query() )
|
||||
{
|
||||
return Tomahawk::TypeQuery;
|
||||
}
|
||||
else if ( entry->artist() )
|
||||
{
|
||||
return Tomahawk::TypeArtist;
|
||||
}
|
||||
else if ( entry->album() )
|
||||
{
|
||||
return Tomahawk::TypeAlbum;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
if ( !entry->query().isNull() )
|
||||
|
Reference in New Issue
Block a user