Jellyfin Qt
QML Library for interacting with the Jellyfin multimedia server
Loading...
Searching...
No Matches
remotedevice.h
Go to the documentation of this file.
1/*
2 * Sailfin: a Jellyfin client written using Qt
3 * Copyright (C) 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_VIEWMODEL_REMOTEDEVICE_H
20#define JELLYFIN_VIEWMODEL_REMOTEDEVICE_H
21
23
24#include <QAbstractItemModel>
25#include <QList>
26#include <QObject>
27#include <QQmlParserStatus>
28#include <QSharedPointer>
29
30#include <utility>
31
32namespace Jellyfin {
33
34class ApiClient;
35
36namespace ViewModel {
37
38class PlaybackManager;
39
46class RemoteDeviceList : public QAbstractListModel, public QQmlParserStatus {
47 Q_OBJECT
48 Q_INTERFACES(QQmlParserStatus)
49
50
57 Q_PROPERTY(bool scanning READ scanning WRITE setScanning NOTIFY scanningChanged);
58public:
67
68 explicit RemoteDeviceList(QObject *parent = nullptr);
69
70 ApiClient *apiClient() const { return m_apiClient; }
72
73 bool scanning() const { return m_scanning; }
74 void setScanning(bool scanning);
75
76 // QAbstractListModel
77 int rowCount(const QModelIndex &parent = QModelIndex()) const override;
78 QVariant data(const QModelIndex &index, int role) const override;
79 QHash<int, QByteArray> roleNames() const override {
80 return {
81 { RoleNames::jellyfinId, "jellyfinId"},
82 { RoleNames::name, "name" },
83 { RoleNames::deviceName, "deviceName" },
84 { RoleNames::deviceType, "deviceType" },
85 { RoleNames::userName, "userName" },
86 { RoleNames::session, "session" }
87 };
88 }
89
95 Q_INVOKABLE void activateSession(Jellyfin::ViewModel::PlaybackManager *manager, int index);
96
97 // QQmlParserStatus
98 void classBegin() override;
99 void componentComplete() override;
100signals:
103private slots:
104 void onSessionFound(Jellyfin::Model::ControllableSession * session);
105 void onSessionLost(QString sessionId);
106 void onSessionsReset();
107private:
108 ApiClient *m_apiClient = nullptr;
109 bool m_scanning = false;
110 bool m_componentComplete = false;
113};
114
115} // NS ViewModel
116} // NS Jellyfin
117
118#endif // JELLYFIN_VIEWMODEL_REMOTEDEVICE_H
An Api client for Jellyfin. Handles requests and authentication.
Definition apiclient.h:90
Abstract class for describing a playback session that can be controlled.
Definition controllablesession.h:56
The PlaybackManager class manages the playback of Jellyfin items.
Definition playbackmanager.h:76
AbstractListModel of remotely controllable devices by JellyfinQt.
Definition remotedevice.h:46
void componentComplete() override
Definition remotedevice.cpp:32
ApiClient * apiClient() const
Definition remotedevice.h:70
RemoteDeviceList(QObject *parent=nullptr)
Definition remotedevice.cpp:28
Jellyfin::ApiClient * apiClient
Definition remotedevice.h:53
void setScanning(bool scanning)
Definition remotedevice.cpp:96
int rowCount(const QModelIndex &parent=QModelIndex()) const override
Definition remotedevice.cpp:66
Q_INVOKABLE void activateSession(Jellyfin::ViewModel::PlaybackManager *manager, int index)
Sets the PlaybackManager to control the session at the given index in this model.
Definition remotedevice.cpp:92
void classBegin() override
Definition remotedevice.cpp:31
QHash< int, QByteArray > roleNames() const override
Definition remotedevice.h:79
QVariant data(const QModelIndex &index, int role) const override
Definition remotedevice.cpp:70
bool scanning
Definition remotedevice.h:57
RoleNames
Definition remotedevice.h:59
@ deviceType
Definition remotedevice.h:63
@ userName
Definition remotedevice.h:64
@ jellyfinId
Definition remotedevice.h:60
@ session
Definition remotedevice.h:65
@ deviceName
Definition remotedevice.h:62
@ name
Definition remotedevice.h:61
void setApiClient(ApiClient *apiClient)
Definition remotedevice.cpp:39
bool scanning() const
Definition remotedevice.h:73
Definition mediaplayer2.h:20