diff --git a/src/libtomahawk/playlist/PlayableModel.cpp b/src/libtomahawk/playlist/PlayableModel.cpp index 2ac590d5b..02f2c1c5e 100644 --- a/src/libtomahawk/playlist/PlayableModel.cpp +++ b/src/libtomahawk/playlist/PlayableModel.cpp @@ -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() ) { diff --git a/src/libtomahawk/playlist/PlayableModel.h b/src/libtomahawk/playlist/PlayableModel.h index deacf8720..ba0eaf55b 100644 --- a/src/libtomahawk/playlist/PlayableModel.h +++ b/src/libtomahawk/playlist/PlayableModel.h @@ -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();