From e81baf0eb7ea2d495c146d847ff8e364f9512e12 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Tue, 3 Jul 2012 23:42:56 +0200 Subject: [PATCH 1/2] * Added PlayableRoles and mapped them to the according column. --- src/libtomahawk/playlist/PlayableModel.cpp | 13 ++++++++++--- src/libtomahawk/playlist/PlayableModel.h | 21 ++++++++++++++++++++- 2 files changed, 30 insertions(+), 4 deletions(-) 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(); From 692a4043e8b5ff1e7977df4953b58560cbfdf4f5 Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Tue, 3 Jul 2012 23:43:32 +0200 Subject: [PATCH 2/2] * Call startOnDemand() when initializing DynamicQmlWidget. Not sure if we need to wait for a revision to be loaded first, though. --- src/libtomahawk/playlist/dynamic/widgets/DynamicQmlWidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libtomahawk/playlist/dynamic/widgets/DynamicQmlWidget.cpp b/src/libtomahawk/playlist/dynamic/widgets/DynamicQmlWidget.cpp index 59d2c840e..b63d554f2 100644 --- a/src/libtomahawk/playlist/dynamic/widgets/DynamicQmlWidget.cpp +++ b/src/libtomahawk/playlist/dynamic/widgets/DynamicQmlWidget.cpp @@ -26,9 +26,9 @@ DynamicQmlWidget::DynamicQmlWidget( const dynplaylist_ptr& playlist, QWidget* pa rootContext()->setContextProperty( "dynamicModel", m_proxyModel ); m_model->loadPlaylist( m_playlist ); + m_model->startOnDemand(); setSource( QUrl( "qrc" RESPATH "qml/StationScene.qml" ) ); - // TODO: fill m_model with the station stuff }