File indexing completed on 2024-05-12 16:21:17
0001 // SPDX-FileCopyrightText: 2021 Jonah Brüchert <jbb@kaidan.im> 0002 // 0003 // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 0005 #pragma once 0006 0007 #include <QAbstractListModel> 0008 #include <ytmusic.h> 0009 0010 #include "abstractytmusicmodel.h" 0011 0012 class PlaylistModel : public AbstractYTMusicModel 0013 { 0014 Q_OBJECT 0015 0016 // input 0017 Q_PROPERTY(QString playlistId READ playlistId WRITE setPlaylistId NOTIFY playlistIdChanged REQUIRED) 0018 0019 // output 0020 Q_PROPERTY(QUrl thumbnailUrl READ thumbnailUrl NOTIFY thumbnailUrlChanged) 0021 Q_PROPERTY(QString title READ title NOTIFY titleChanged) 0022 Q_PROPERTY(QUrl webUrl READ webUrl NOTIFY playlistIdChanged) 0023 0024 0025 public: 0026 explicit PlaylistModel(QObject *parent = nullptr); 0027 0028 enum Role { 0029 Title, 0030 Artists, 0031 VideoId, 0032 ThumbnailUrl, 0033 ArtistsDisplayString 0034 }; 0035 0036 int rowCount(const QModelIndex &parent) const override; 0037 QHash<int, QByteArray> roleNames() const override; 0038 QVariant data(const QModelIndex &index, int role) const override; 0039 0040 QString playlistId() const; 0041 void setPlaylistId(const QString &playlistId); 0042 Q_SIGNAL void playlistIdChanged(); 0043 0044 QUrl thumbnailUrl() const; 0045 Q_SIGNAL void thumbnailUrlChanged(); 0046 0047 QString title() const; 0048 Q_SIGNAL void titleChanged(); 0049 0050 QUrl webUrl() const; 0051 0052 playlist::Playlist playlist() const; 0053 0054 private: 0055 QString m_playlistId; 0056 0057 playlist::Playlist m_playlist {}; 0058 };