Jellyfin Qt
QML Library for interacting with the Jellyfin multimedia server
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
playlist.h
Go to the documentation of this file.
1/*
2 * Sailfin: a Jellyfin client written using Qt
3 * Copyright (C) 2021-2022 Chris Josten and the Sailfin Contributors.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19#ifndef JELLYFIN_MODEL_PLAYLIST_H
20#define JELLYFIN_MODEL_PLAYLIST_H
21
22#include <QObject>
23#include <QSharedPointer>
24#include <QString>
25#include <QUrl>
26#include <QVector>
27
29#include "item.h"
30
31namespace Jellyfin {
32namespace Model {
33
34class Shuffle;
35
47class Playlist : public QObject {
48 Q_OBJECT
49public:
50 explicit Playlist(QObject *parent = nullptr);
51
53 QSharedPointer<Item> currentItem();
54 QSharedPointer<Item> nextItem();
59 int currentItemIndexInList() const;
60
61 bool hasPrevious();
62
66 void previous();
67
68 bool hasNext();
69
73 void next();
74
79
80 int queueSize() { return m_queue.size(); };
81 int listSize() const { return m_list.size(); };
82 int totalSize() const { return m_queue.size() + m_list.size(); }
83
89 QSharedPointer<const Item> listAt(int index) const;
90
96 QSharedPointer<const Item> queueAt(int index) const;
97
101 void clearList();
102
106 void appendToList(const QList<QSharedPointer<Item>> &model);
107
112 void appendToList(QSharedPointer<Model::Item> item);
113
118 void play(int index = 0);
119
124 bool playingFromQueue() const;
125
126signals:
129 void beforeItemsAddedToQueue(int index, int count);
130 void beforeItemsAddedToList(int index, int count);
133 void beforeItemsRemovedFromQueue(int index, int count);
134 void beforeItemsRemovedFromList(int index, int count);
139private:
140 void reshuffle();
141
142 QSharedPointer<Item> m_currentItem;
143 bool m_currentItemFromQueue = false;
144 QSharedPointer<Item> m_nextItem;
145 bool m_nextItemFromQueue = false;
146
148 QVector<QSharedPointer<Item>> m_queue;
150 QVector<QSharedPointer<Item>> m_list;
152 int m_pos = 0;
153
155 Shuffle *m_shuffler;
156};
157
158}
159}
160
161#endif // JELLYFIN_MODEL_PLAYLIST_H
Model of a playlist, a list of items that can be played.
Definition playlist.h:47
int currentItemIndexInList() const
Definition playlist.cpp:131
void previous()
Determine the previous item to be played.
Definition playlist.cpp:42
QSharedPointer< const Item > listAt(int index) const
Returns the item at the given index of the currently selected playlist, excluding the queue.
Definition playlist.cpp:115
void next()
Determine the next item to be played.
Definition playlist.cpp:65
bool hasNext()
Definition playlist.cpp:61
void clearList()
Removes all the items from the playlist, but not from the queue.
Definition playlist.cpp:30
void beforeItemsAddedToList(int index, int count)
QSharedPointer< const Item > queueAt(int index) const
Returns the item at the given index of the currently queue, excluding the playlist.
Definition playlist.cpp:123
void beforeItemsRemovedFromQueue(int index, int count)
bool hasPrevious()
Definition playlist.cpp:38
void beforeItemsRemovedFromList(int index, int count)
QSharedPointer< Item > currentItem()
Returns the current item in the queue.
Definition playlist.cpp:127
Playlist(QObject *parent=nullptr)
Definition playlist.cpp:26
QList< QSharedPointer< Item > > queueAndList() const
Returns all items in the queue.
Definition playlist.cpp:107
QSharedPointer< Item > nextItem()
Definition playlist.cpp:139
int listSize() const
Definition playlist.h:81
void beforeItemsAddedToQueue(int index, int count)
int totalSize() const
Definition playlist.h:82
bool playingFromQueue() const
playingFromQueue
Definition playlist.cpp:207
void play(int index=0)
Start playing this playlist.
Definition playlist.cpp:182
int queueSize()
Definition playlist.h:80
void appendToList(const QList< QSharedPointer< Item > > &model)
Appends all items from the given item list to this list.
Interface for an algorithm shuffling a playlist.
Definition shuffle.h:32
Definition mediaplayer2.h:20