Jellyfin Qt
QML Library for interacting with the Jellyfin multimedia server
Loading...
Searching...
No Matches
user.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_USER_H
20#define JELLYFIN_VIEWMODEL_USER_H
21
22#include <QObject>
23#include <QSharedPointer>
24#include <QString>
25
27#include "../model/user.h"
28#include "loader.h"
29
30namespace Jellyfin {
31
32namespace ViewModel {
33
34class User : public QObject {
35 Q_OBJECT
36public:
37 explicit User(QObject *parent = nullptr, QSharedPointer<Model::User> data = QSharedPointer<Model::User>::create());
38
39 Q_PROPERTY(QString name READ name NOTIFY nameChanged)
40 Q_PROPERTY(QString serverId READ serverId NOTIFY serverIdChanged)
41 Q_PROPERTY(QString serverName READ serverName NOTIFY serverNameChanged)
42 Q_PROPERTY(QString userId READ userId NOTIFY userIdChanged)
44 Q_PROPERTY(bool hasPassword READ hasPassword NOTIFY hasPasswordChanged)
47
48 QString name() const { return m_data->name(); }
49 QString serverId() const { return m_data->serverId(); }
50 QString serverName() const { return m_data->serverName(); }
51 QString userId() const { return m_data->jellyfinId(); }
52 QString primaryImageTag() const { return m_data->primaryImageTag(); }
53 bool hasPassword() const { return m_data->hasPassword(); }
54 bool hasConfiguredPassword() const { return m_data->hasConfiguredPassword(); }
55 bool hasConfiguredEasyPassword() const { return m_data->hasConfiguredEasyPassword(); }
56
57 QSharedPointer<Model::User> data() const { return m_data; }
58 void setData(QSharedPointer<Model::User> newData);
59
60signals:
61 void nameChanged(QString newName);
62 void serverIdChanged(QString newServerId);
63 void serverNameChanged(QString newServerName);
64 void userIdChanged(QString newUserId);
65 void primaryImageTagChanged(QString newPrimaryImageTag);
66 void hasPasswordChanged(bool newHasPassword);
67 void hasConfiguredPasswordChanged(bool newHasConfiguredPassword);
68 void hasConfiguredEasyPasswordChanged(bool newHasConfiguredEasyPasswordChanged);
69
70private:
71 QSharedPointer<Model::User> m_data;
72
73};
74
76class UserLoader : public UserLoaderBase {
77 Q_OBJECT
78public:
79 explicit UserLoader(QObject *parent = nullptr);
80 Q_PROPERTY(QString userId READ userId WRITE setUserId NOTIFY userIdChanged)
81
82 QString userId() const { return m_parameters.userId(); }
83 void setUserId(QString newUserId);
84 virtual bool canReload() const override;
85
86signals:
87 void userIdChanged(const QString &newUserId) const;
88};
89
90}
91} // NS Jellyfin
92
93#endif // JELLYFIN_VIEWMODEL_USER_H
Definition loader.h:148
P m_parameters
Definition loader.h:177
QString userId
Definition user.h:80
void userIdChanged(const QString &newUserId) const
UserLoader(QObject *parent=nullptr)
Definition user.cpp:41
virtual bool canReload() const override
Subclasses should implement this to determine if they can load data from the server.
Definition user.cpp:50
void setUserId(QString newUserId)
Definition user.cpp:44
Definition user.h:34
void hasConfiguredEasyPasswordChanged(bool newHasConfiguredEasyPasswordChanged)
QString primaryImageTag() const
Definition user.h:52
void serverNameChanged(QString newServerName)
void primaryImageTagChanged(QString newPrimaryImageTag)
void nameChanged(QString newName)
QString serverId() const
Definition user.h:49
bool hasPassword() const
Definition user.h:53
bool hasConfiguredEasyPassword
Definition user.h:46
QString userId
Definition user.h:42
bool hasConfiguredEasyPassword() const
Definition user.h:55
void hasPasswordChanged(bool newHasPassword)
QString primaryImageTag
Definition user.h:43
void hasConfiguredPasswordChanged(bool newHasConfiguredPassword)
bool hasPassword
Definition user.h:44
bool hasConfiguredPassword() const
Definition user.h:54
QString serverName
Definition user.h:41
void serverIdChanged(QString newServerId)
QString serverId
Definition user.h:40
QString serverName() const
Definition user.h:50
void userIdChanged(QString newUserId)
QString userId() const
Definition user.h:51
QSharedPointer< Model::User > data() const
Definition user.h:57
void setData(QSharedPointer< Model::User > newData)
Definition user.cpp:35
bool hasConfiguredPassword
Definition user.h:45
QString name
Definition user.h:39
DTO::UserDto User
Definition apimodel.cpp:33