1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 22:26:32 +02:00

* Added PlayableRoles and mapped them to the according column.

This commit is contained in:
Christian Muehlhaeuser
2012-07-03 23:42:56 +02:00
parent 5f61e3b1bd
commit e81baf0eb7
2 changed files with 30 additions and 4 deletions

View File

@@ -259,15 +259,22 @@ PlayableModel::data( const QModelIndex& index, int role ) const
{
return QVariant();
}
if ( role == Qt::TextAlignmentRole )
else if ( role == Qt::TextAlignmentRole )
{
return QVariant( columnAlignment( index.column() ) );
}
int column = index.column();
if ( role >= Qt::UserRole )
{
// Map user-role to column
column = role - Qt::UserRole;
role = Qt::DisplayRole;
}
if ( !entry->query().isNull() )
{
return queryData( entry->query()->displayQuery(), index.column(), role );
return queryData( entry->query()->displayQuery(), column, role );
}
else if ( !entry->artist().isNull() )
{

View File

@@ -38,7 +38,8 @@ class DLLEXPORT PlayableModel : public QAbstractItemModel
Q_OBJECT
public:
enum Columns {
enum Columns
{
Artist = 0,
Track = 1,
Composer = 2,
@@ -54,6 +55,24 @@ public:
Name = 12
};
enum PlayableRoles
{
ArtistRole = Qt::UserRole,
TrackRole,
ComposerRole,
AlbumRole,
AlbumPosRole,
DurationRole,
BitrateRole,
AgeRole,
YearRole,
FilesizeRole,
OriginRole,
ScoreRole,
NameRole
};
explicit PlayableModel( QObject* parent = 0, bool loading = true );
virtual ~PlayableModel();