Jellyfin Qt
QML Library for interacting with the Jellyfin multimedia server
Toggle main menu visibility
Loading...
Searching...
No Matches
playlist.h
Go to the documentation of this file.
1
/*
2
* Sailfin: a Jellyfin client written using Qt
3
* Copyright (C) 2021 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_VIEWMODEL_PLAYLIST
20
#define JELLYFIN_VIEWMODEL_PLAYLIST
21
22
#include <optional>
23
24
#include <QAbstractListModel>
25
#include <QByteArray>
26
#include <QHash>
27
#include <QObject>
28
#include <QSharedPointer>
29
#include <QVariant>
30
31
#include "
../apiclient.h
"
32
#include "
../model/playlist.h
"
33
#include "
itemmodel.h
"
34
35
namespace
Jellyfin
{
36
namespace
ViewModel
{
37
41
class
NowPlayingSection
{
42
Q_GADGET
43
public
:
44
enum
Value
{
45
Queue
,
46
NowPlaying
,
47
};
48
Q_ENUM
(
Value
);
49
};
50
54
class
Playlist
:
public
QAbstractListModel {
55
Q_OBJECT
56
friend
class
ItemUrlFetcherThread
;
57
public
:
58
enum
RoleNames
{
59
// Item properties
60
name
= Qt::UserRole + 1,
61
artists
,
62
artistItems
,
63
runTimeTicks
,
64
65
// Non-item properties
66
playing
,
67
section
,
68
};
69
explicit
Playlist
(
Model::Playlist
*
data
, QObject *parent =
nullptr
);
70
71
QVariant
data
(
const
QModelIndex &parent,
int
role = Qt::DisplayRole)
const override
;
72
int
rowCount
(
const
QModelIndex &parent)
const override
;
73
QHash<int, QByteArray>
roleNames
()
const override
;
74
void
setPlaylistModel
(
Model::Playlist
*
data
);
75
76
77
private
slots:
78
void
onBeforePlaylistCleared();
79
void
onPlaylistCleared();
80
void
onBeforeItemsAddedToList(
int
startIndex,
int
amount);
81
void
onBeforeItemsAddedToQueue(
int
startIndex,
int
amount);
82
void
onItemsAddedToList();
83
void
onItemsAddedToQueue();
84
void
onBeforeItemsRemovedFromList(
int
startIndex,
int
amount);
85
void
onBeforeItemsRemovedFromQueue(
int
startIndex,
int
amount);
86
void
onItemsRemovedFromList();
87
void
onItemsRemovedFromQueue();
88
void
onReshuffled();
89
void
onPlayingItemChanged();
90
private
:
91
Model::Playlist
*m_data;
92
// The index of the last played item.
93
int
m_lastPlayedRow = -1;
94
99
bool
isPlaying(
int
index)
const
;
100
};
101
102
103
104
}
// NS ViewModel
105
}
// NS Jellyfin
106
107
#endif
//JELLYFIN_VIEWMODEL_PLAYLIST
apiclient.h
Jellyfin::Model::Playlist
Model of a playlist, a list of items that can be played.
Definition
playlist.h:47
Jellyfin::ViewModel::NowPlayingSection
Indicator in which part of the playing queue a given item is positioned.
Definition
playlist.h:41
Jellyfin::ViewModel::NowPlayingSection::Value
Value
Definition
playlist.h:44
Jellyfin::ViewModel::NowPlayingSection::NowPlaying
@ NowPlaying
Definition
playlist.h:46
Jellyfin::ViewModel::NowPlayingSection::Queue
@ Queue
Definition
playlist.h:45
Jellyfin::ViewModel::NowPlayingSection::Q_ENUM
Q_ENUM(Value)
Jellyfin::ViewModel::Playlist::rowCount
int rowCount(const QModelIndex &parent) const override
Definition
playlist.cpp:33
Jellyfin::ViewModel::Playlist::setPlaylistModel
void setPlaylistModel(Model::Playlist *data)
Definition
playlist.cpp:48
Jellyfin::ViewModel::Playlist::roleNames
QHash< int, QByteArray > roleNames() const override
Definition
playlist.cpp:37
Jellyfin::ViewModel::Playlist::ItemUrlFetcherThread
friend class ItemUrlFetcherThread
Definition
playlist.h:56
Jellyfin::ViewModel::Playlist::data
QVariant data(const QModelIndex &parent, int role=Qt::DisplayRole) const override
Definition
playlist.cpp:83
Jellyfin::ViewModel::Playlist::RoleNames
RoleNames
Definition
playlist.h:58
Jellyfin::ViewModel::Playlist::playing
@ playing
Definition
playlist.h:66
Jellyfin::ViewModel::Playlist::artists
@ artists
Definition
playlist.h:61
Jellyfin::ViewModel::Playlist::section
@ section
Definition
playlist.h:67
Jellyfin::ViewModel::Playlist::name
@ name
Definition
playlist.h:60
Jellyfin::ViewModel::Playlist::runTimeTicks
@ runTimeTicks
Definition
playlist.h:63
Jellyfin::ViewModel::Playlist::artistItems
@ artistItems
Definition
playlist.h:62
Jellyfin::ViewModel::Playlist::Playlist
Playlist(Model::Playlist *data, QObject *parent=nullptr)
Definition
playlist.cpp:27
itemmodel.h
playlist.h
Jellyfin::ViewModel
Contains all types exposed to QML.
Jellyfin
core
include
JellyfinQt
viewmodel
playlist.h
Generated by
1.17.0