Implement main/sub-text - using Subtitled delegate for the moment
This commit is contained in:
committed by
craig.p.drummond
parent
523a0aa0a8
commit
f49f5f55fd
@@ -29,9 +29,21 @@ QVariant ActionModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
QVariant v;
|
||||
Q_UNUSED(index)
|
||||
#ifndef ENABLE_UBUNTU // Should touch version return a list of action names?
|
||||
if (ItemView::Role_Actions==role) {
|
||||
v.setValue<QList<Action *> >(QList<Action *>() << StdActions::self()->replacePlayQueueAction << StdActions::self()->addToPlayQueueAction);
|
||||
}
|
||||
#endif
|
||||
return v;
|
||||
}
|
||||
|
||||
#ifdef ENABLE_UBUNTU
|
||||
//Expose role names, so that they can be accessed via QML
|
||||
QHash<int, QByteArray> ActionModel::roleNames() const
|
||||
{
|
||||
QHash<int, QByteArray> roles;
|
||||
roles[ItemView::Role_MainText] = "mainText";
|
||||
roles[ItemView::Role_SubText] = "subText";
|
||||
return roles;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <QAbstractItemModel>
|
||||
#include <QMetaType>
|
||||
#include "action.h"
|
||||
#include "config.h"
|
||||
|
||||
class ActionModel : public QAbstractItemModel
|
||||
{
|
||||
@@ -38,6 +39,9 @@ public:
|
||||
|
||||
virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
|
||||
virtual void resetModel() { beginResetModel(); endResetModel(); }
|
||||
#ifdef ENABLE_UBUNTU
|
||||
QHash<int, QByteArray> roleNames() const;
|
||||
#endif
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(QList<Action *>)
|
||||
|
||||
@@ -176,14 +176,6 @@ QModelIndex AlbumsModel::index(int row, int col, const QModelIndex &parent) cons
|
||||
return row<items.count() ? createIndex(row, col, items.at(row)) : QModelIndex();
|
||||
}
|
||||
|
||||
//Expose role names, so that they can be accessed via QML
|
||||
QHash<int, QByteArray> AlbumsModel::roleNames() const {
|
||||
QHash<int, QByteArray> roles;
|
||||
roles[Qt::DisplayRole] = "album";
|
||||
roles[ItemView::Role_SubText] = "artist";
|
||||
return roles;
|
||||
}
|
||||
|
||||
QVariant AlbumsModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (!index.isValid()) {
|
||||
@@ -236,9 +228,7 @@ QVariant AlbumsModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
break;
|
||||
case ItemView::Role_MainText:
|
||||
if (Sort_ArtistYearAlbum==sortAlbums) {
|
||||
return al->albumDisplay();
|
||||
}
|
||||
return al->albumDisplay();
|
||||
case ItemView::Role_BriefMainText:
|
||||
return al->album;
|
||||
case ItemView::Role_ImageSize:
|
||||
|
||||
@@ -112,7 +112,6 @@ public:
|
||||
int columnCount(const QModelIndex&) const { return 1; }
|
||||
QModelIndex parent(const QModelIndex &index) const;
|
||||
QModelIndex index(int row, int column, const QModelIndex &parent) const;
|
||||
QHash<int, QByteArray> roleNames() const;
|
||||
QVariant data(const QModelIndex &, int) const;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
QStringList filenames(const QModelIndexList &indexes, bool allowPlaylists=false) const;
|
||||
|
||||
@@ -42,6 +42,9 @@
|
||||
#include "config.h"
|
||||
#include "action.h"
|
||||
#include "actioncollection.h"
|
||||
#ifdef ENABLE_UBUNTU
|
||||
#include "itemview.h"
|
||||
#endif
|
||||
#ifdef ENABLE_DEVICES_SUPPORT
|
||||
#include "devicesmodel.h"
|
||||
#if defined CDDB_FOUND || defined MUSICBRAINZ5_FOUND
|
||||
@@ -300,14 +303,16 @@ static QString basicPath(const Song &song)
|
||||
return -1==marker ? path : path.left(marker);
|
||||
}
|
||||
|
||||
#ifdef ENABLE_UBUNTU
|
||||
//Expose role names, so that they can be accessed via QML
|
||||
QHash<int, QByteArray> PlayQueueModel::roleNames() const {
|
||||
QHash<int, QByteArray> PlayQueueModel::roleNames() const
|
||||
{
|
||||
QHash<int, QByteArray> roles;
|
||||
roles[QmlRole_Track] = "track";
|
||||
roles[QmlRole_Title] = "title";
|
||||
roles[QmlRole_Artist] = "artist";
|
||||
roles[ItemView::Role_MainText] = "mainText";
|
||||
roles[ItemView::Role_SubText] = "subText";
|
||||
return roles;
|
||||
}
|
||||
#endif
|
||||
|
||||
QVariant PlayQueueModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
@@ -325,6 +330,16 @@ QVariant PlayQueueModel::data(const QModelIndex &index, int role) const
|
||||
// }
|
||||
|
||||
switch (role) {
|
||||
#ifdef ENABLE_UBUNTU
|
||||
case ItemView::Role_MainText: {
|
||||
Song s=songs.at(index.row());
|
||||
return s.title;
|
||||
}
|
||||
case ItemView::Role_SubText: {
|
||||
Song s=songs.at(index.row());
|
||||
return s.artist+QLatin1String(" - ")+s.displayAlbum();
|
||||
}
|
||||
#endif
|
||||
case GroupedView::Role_IsCollection:
|
||||
return false;
|
||||
case GroupedView::Role_CollectionId:
|
||||
@@ -517,19 +532,6 @@ QVariant PlayQueueModel::data(const QModelIndex &index, int role) const
|
||||
}
|
||||
break;
|
||||
}
|
||||
//Seperate roles for QML, as there is no support for different columns
|
||||
case QmlRole_Track: {
|
||||
Song s=songs.at(index.row());
|
||||
return s.track;
|
||||
}
|
||||
case QmlRole_Title: {
|
||||
Song s=songs.at(index.row());
|
||||
return s.title;
|
||||
}
|
||||
case QmlRole_Artist: {
|
||||
Song s=songs.at(index.row());
|
||||
return s.artist;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -61,13 +61,6 @@ public:
|
||||
COL_COUNT
|
||||
};
|
||||
|
||||
//Seperate roles for QML, as there is no support for different columns
|
||||
enum QmlRoles {
|
||||
QmlRole_Track = Qt::UserRole+450,
|
||||
QmlRole_Title,
|
||||
QmlRole_Artist
|
||||
};
|
||||
|
||||
struct UndoItem
|
||||
{
|
||||
bool operator==(const UndoItem &o) const { return priority==o.priority && files==o.files; }
|
||||
@@ -91,7 +84,9 @@ public:
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
int columnCount(const QModelIndex &) const { return COL_COUNT; }
|
||||
#ifdef ENABLE_UBUNTU
|
||||
QHash<int, QByteArray> roleNames() const;
|
||||
#endif
|
||||
QVariant data(const QModelIndex &, int) const;
|
||||
bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
|
||||
void updateCurrentSong(quint32 id);
|
||||
|
||||
@@ -91,12 +91,13 @@ Page {
|
||||
model: albumsProxyModel
|
||||
clip: true
|
||||
|
||||
delegate: ListItem.Standard {
|
||||
text: model.album + " (" + model.artist + ")"
|
||||
delegate: ListItem.Subtitled {
|
||||
text: model.mainText
|
||||
subText: model.subText
|
||||
// progression: true //Removed due to the app showdown, will be implemented later
|
||||
|
||||
control: Row {
|
||||
spacing: units.gu(1)
|
||||
//control: Row {
|
||||
// spacing: units.gu(1)
|
||||
|
||||
Image {
|
||||
width: units.gu(3)
|
||||
@@ -105,6 +106,12 @@ Page {
|
||||
source: "../../icons/toolbar/add.svg"
|
||||
opacity: 0.9
|
||||
|
||||
anchors {
|
||||
right: parent.right
|
||||
rightMargin: units.gu(0)
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
onClicked: {
|
||||
backend.addAlbum(index, false)
|
||||
@@ -121,6 +128,12 @@ Page {
|
||||
source: "../../icons/toolbar/media-playback-start-light.svg"
|
||||
opacity: 0.9
|
||||
|
||||
anchors {
|
||||
right: parent.right
|
||||
rightMargin: units.gu(4)
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
onClicked: {
|
||||
backend.addAlbum(index, true)
|
||||
@@ -130,7 +143,7 @@ Page {
|
||||
preventStealing: true
|
||||
}
|
||||
}
|
||||
}
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -211,8 +211,9 @@ Page {
|
||||
bottomMargin: isPhone?0:(-units.gu(2))
|
||||
}
|
||||
|
||||
delegate: ListItem.Standard {
|
||||
text: (track < 10 ? '0' : '') + track + " " + title + " (" + artist + ")"
|
||||
delegate: ListItem.Subtitled {
|
||||
text: model.mainText
|
||||
subText: model.subText
|
||||
confirmRemoval: true
|
||||
removable: true
|
||||
onItemRemoved: {
|
||||
|
||||
Reference in New Issue
Block a user