mirror of
https://github.com/HenkKalkwater/harbour-sailfin.git
synced 2025-09-05 10:12:46 +00:00
Add navigation to artists from tracks
I'm not to happy about the C++ sides. If anyone from the future finds this commit with "git blame" while debugging this code: I apologise
This commit is contained in:
parent
3f9661ccb5
commit
0fafb19c7d
14 changed files with 185 additions and 5 deletions
|
@ -54,6 +54,7 @@ void JellyfinPlugin::registerTypes(const char *uri) {
|
|||
qmlRegisterUncreatableType<ViewModel::User>(uri, 1, 0, "User", "Acquire one via UserLoader or exposed properties");
|
||||
qmlRegisterUncreatableType<EventBus>(uri, 1, 0, "EventBus", "Obtain one via your ApiClient");
|
||||
qmlRegisterUncreatableType<WebSocket>(uri, 1, 0, "WebSocket", "Obtain one via your ApiClient");
|
||||
qmlRegisterUncreatableType<ViewModel::NameGuidPair>(uri, 1, 0, "NameGuidPair", "Obbtain one via an Item");
|
||||
qmlRegisterUncreatableType<ViewModel::MediaStream>(uri, 1, 0, "MediaStream", "Obtain one via an Item");
|
||||
qmlRegisterUncreatableType<ViewModel::Settings>(uri, 1, 0, "Settings", "Obtain one via your ApiClient");
|
||||
qmlRegisterUncreatableType<ViewModel::UserData>(uri, 1, 0, "UserData", "Obtain one via an Item");
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
namespace Jellyfin {
|
||||
namespace ViewModel {
|
||||
|
||||
NameGuidPair::NameGuidPair(QSharedPointer<DTO::NameGuidPair> data, QObject *parent)
|
||||
: QObject(parent), m_data(data) {}
|
||||
|
||||
Item::Item(QObject *parent, QSharedPointer<Model::Item> data)
|
||||
: QObject(parent),
|
||||
m_data(data),
|
||||
|
@ -44,6 +47,7 @@ void Item::setData(QSharedPointer<Model::Item> newData) {
|
|||
|
||||
if (!m_data.isNull()) {
|
||||
connect(m_data.data(), &Model::Item::userDataChanged, this, &Item::onUserDataChanged);
|
||||
updateMediaStreams();
|
||||
setUserData(m_data->userData());
|
||||
}
|
||||
|
||||
|
@ -77,6 +81,11 @@ void Item::updateMediaStreams() {
|
|||
qDebug() << m_audioStreams.size() << " audio streams, " << m_videoStreams.size() << " video streams, "
|
||||
<< m_subtitleStreams.size() << " subtitle streams, " << m_allMediaStreams.size() << " streams total";
|
||||
|
||||
m_artistItems.clear();
|
||||
const QList<DTO::NameGuidPair> artists = m_data->artistItems();
|
||||
for (auto it = artists.cbegin(); it != artists.cend(); it++) {
|
||||
m_artistItems.append(new NameGuidPair(QSharedPointer<DTO::NameGuidPair>::create(*it), this));
|
||||
}
|
||||
}
|
||||
|
||||
void Item::setUserData(DTO::UserItemDataDto &newData) {
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
*/
|
||||
#include "JellyfinQt/viewmodel/itemmodel.h"
|
||||
|
||||
#include "JellyfinQt/viewmodel/item.h"
|
||||
|
||||
#include "JellyfinQt/loader/http/artists.h"
|
||||
#include "JellyfinQt/loader/http/items.h"
|
||||
#include "JellyfinQt/loader/http/userlibrary.h"
|
||||
|
@ -93,6 +95,14 @@ QVariant ItemModel::data(const QModelIndex &index, int role) const {
|
|||
case RoleNames::runTimeTicks:
|
||||
return QVariant(item->runTimeTicks().value_or(0));
|
||||
JF_CASE(artists)
|
||||
case RoleNames::artistItems: {
|
||||
QVariantList data;
|
||||
auto artists = item->artistItems();
|
||||
for (auto it = artists.cbegin(); it != artists.cend(); it++) {
|
||||
data.append(QVariant::fromValue(new NameGuidPair(QSharedPointer<DTO::NameGuidPair>::create(*it), const_cast<ItemModel *>(this))));
|
||||
}
|
||||
return data;
|
||||
}
|
||||
case RoleNames::isFolder:
|
||||
return QVariant(item->isFolder().value_or(false));
|
||||
JF_CASE(overview)
|
||||
|
|
|
@ -18,6 +18,8 @@
|
|||
*/
|
||||
#include "JellyfinQt/viewmodel/playlist.h"
|
||||
|
||||
#include "JellyfinQt/viewmodel/item.h"
|
||||
|
||||
namespace Jellyfin {
|
||||
namespace ViewModel {
|
||||
|
||||
|
@ -47,6 +49,7 @@ QHash<int, QByteArray> Playlist::roleNames() const {
|
|||
return {
|
||||
{RoleNames::name, "name"},
|
||||
{RoleNames::artists, "artists"},
|
||||
{RoleNames::artistItems, "artistItems"},
|
||||
{RoleNames::runTimeTicks, "runTimeTicks"},
|
||||
{RoleNames::section, "section"},
|
||||
{RoleNames::playing, "playing"},
|
||||
|
@ -83,6 +86,16 @@ QVariant Playlist::data(const QModelIndex &index, int role) const {
|
|||
return QVariant(rowData->name());
|
||||
case RoleNames::artists:
|
||||
return QVariant(rowData->artists());
|
||||
case RoleNames::artistItems: {
|
||||
QVariantList result;
|
||||
|
||||
auto items = rowData->artistItems();
|
||||
for (auto it = items.cbegin(); it != items.cend(); it++) {
|
||||
result.append(QVariant::fromValue(new NameGuidPair(QSharedPointer<DTO::NameGuidPair>::create(*it), const_cast<Playlist *>(this))));
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
case RoleNames::runTimeTicks:
|
||||
return QVariant(rowData->runTimeTicks().value_or(-1));
|
||||
default:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue