1
0
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:
Christian Muehlhaeuser
2013-06-12 06:05:52 +02:00
committed by Michael Zanetti
parent db56757bc8
commit fc4e42befa

View File

@@ -294,29 +294,7 @@ PlayableModel::data( const QModelIndex& index, int role ) const
if ( !entry )
return QVariant();
int column = index.column();
if ( role < CoverIDRole && role >= Qt::UserRole )
{
// map role to column
column = role - Qt::UserRole;
role = Qt::DisplayRole;
}
switch ( role )
{
case Qt::TextAlignmentRole:
{
return QVariant( columnAlignment( index.column() ) );
break;
}
case IsPlayingRole:
{
return entry->isPlaying();
break;
}
case PlayableProxyModel::TypeRole:
if ( role == PlayableProxyModel::TypeRole )
{
if ( entry->result() )
{
@@ -334,6 +312,21 @@ PlayableModel::data( const QModelIndex& index, int role ) const
{
return Tomahawk::TypeAlbum;
}
}
int column = index.column();
if ( role < CoverIDRole && role >= Qt::UserRole )
{
// map role to column
column = role - Qt::UserRole;
role = Qt::DisplayRole;
}
switch ( role )
{
case Qt::TextAlignmentRole:
{
return QVariant( columnAlignment( index.column() ) );
break;
}