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,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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user