diff --git a/src/libtomahawk/playlist/treemodel.cpp b/src/libtomahawk/playlist/treemodel.cpp index 47520ae6c..60d887c90 100644 --- a/src/libtomahawk/playlist/treemodel.cpp +++ b/src/libtomahawk/playlist/treemodel.cpp @@ -49,6 +49,11 @@ TreeModel::TreeModel( QObject* parent ) SLOT( infoSystemInfo( Tomahawk::InfoSystem::InfoRequestData, QVariant ) ) ); connect( Tomahawk::InfoSystem::InfoSystem::instance(), SIGNAL( finished( QString ) ), SLOT( infoSystemFinished( QString ) ) ); + + QHash roles; + roles[NameRole] = "name"; + roles[IsPlayingRole] = "isPlaying"; + setRoleNames(roles); } @@ -277,17 +282,25 @@ TreeModel::data( const QModelIndex& index, int role ) const return QSize( 128, 0 ); } - if ( role != Qt::DisplayRole ) // && role != Qt::ToolTipRole ) + + if ( role != Qt::DisplayRole && !roleNames().contains( role ) ) // && role != Qt::ToolTipRole ) return QVariant(); - if ( !entry->artist().isNull() && index.column() == Name ) + if ( role == IsPlayingRole ) + return entry->isPlaying(); + + if ( !entry->artist().isNull() && ( index.column() == Name || role == NameRole ) ) { return entry->artist()->name(); } - else if ( !entry->album().isNull() && index.column() == Name ) + else if ( !entry->album().isNull() && ( index.column() == Name || role == NameRole ) ) { return entry->album()->name(); } + else if ( role = NameRole ) + { + return entry->result()->track(); + } else { const result_ptr& result = entry->result(); diff --git a/src/libtomahawk/playlist/treemodel.h b/src/libtomahawk/playlist/treemodel.h index 1bc075fe3..274a635d0 100644 --- a/src/libtomahawk/playlist/treemodel.h +++ b/src/libtomahawk/playlist/treemodel.h @@ -50,6 +50,11 @@ public: AlbumPosition }; + enum Roles { + NameRole = Qt::UserRole + 1, + IsPlayingRole + }; + enum ColumnStyle // Default style is AllColumns { AllColumns = 0, TrackOnly };