Jellyfin Qt
QML Library for interacting with the Jellyfin multimedia server
Loading...
Searching...
No Matches
userdata.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_USERDATA_H
20#define JELLYFIN_VIEWMODEL_USERDATA_H
21
22#include <QDateTime>
23#include <QObject>
24#include <QSharedPointer>
25
27
28namespace Jellyfin {
29namespace ViewModel{
30
31class UserData : public QObject {
32 Q_OBJECT
33public:
34 explicit UserData(QObject* parent = nullptr);
35 explicit UserData(QSharedPointer<DTO::UserItemDataDto> data, QObject* parent = nullptr);
36
37 void setData(QSharedPointer<DTO::UserItemDataDto> data);
38
39 Q_PROPERTY(double rating READ rating NOTIFY ratingChanged)
43 Q_PROPERTY(int playCount READ playCount NOTIFY playCountChanged)
44 Q_PROPERTY(bool favorite READ favorite NOTIFY favoriteChanged)
45 Q_PROPERTY(bool m_likes READ likes NOTIFY likesChanged)
46 Q_PROPERTY(QDateTime lastPlayedDate READ lastPlayedDate NOTIFY lastPlayedDateChanged)
47 Q_PROPERTY(bool played READ played NOTIFY playedChanged)
48 Q_PROPERTY(QString key READ key NOTIFY keyChanged)
49
50 double rating() const { return m_data->rating().value_or(0); }
51 double playedPercentage() const { return m_data->playedPercentage().value_or(0); }
52 int unplayedItemCount() const { return m_data->unplayedItemCount().value_or(0); }
53 qint64 playbackPositionTicks() const { return m_data->playbackPositionTicks(); }
54 int playCount() const { return m_data->playCount(); }
55 bool favorite() const { return m_data->isFavorite(); }
56 bool likes() const { return m_data->likes().value_or(false); }
57 QDateTime lastPlayedDate() const { return m_data->lastPlayedDate(); }
58 bool played() const { return m_data->played(); }
59 QString key() const { return m_data->key(); }
60
61signals:
62 void ratingChanged(double newRating);
63 void playedPercentageChanged(double newPlayedPercentage);
64 void unplayedItemCountChanged(int newUnplayedItemCount);
65 void playbackPositionTicksChanged(qint64 newPlaybackPositionTicks);
66 void playCountChanged(int newPlayCount);
67 void favoriteChanged(bool newFavorite);
68 void likesChanged(bool newLikes);
69 void lastPlayedDateChanged(QDateTime newLastPlayedDate);
70 void playedChanged(bool newPLayed);
71 void keyChanged(QString newKey);
72
73private:
74 QSharedPointer<DTO::UserItemDataDto> m_data;
75};
76
77
78} // NS ViewModel
79} // NS Jellyfin
80
81#endif // JELLYFIN_VIEWMODEL_USERDATA_H
Definition userdata.h:31
void setData(QSharedPointer< DTO::UserItemDataDto > data)
Definition userdata.cpp:37
qint64 playbackPositionTicks
Definition userdata.h:42
void playedPercentageChanged(double newPlayedPercentage)
double playedPercentage() const
Definition userdata.h:51
void lastPlayedDateChanged(QDateTime newLastPlayedDate)
bool played
Definition userdata.h:47
QString key
Definition userdata.h:48
int playCount() const
Definition userdata.h:54
QString key() const
Definition userdata.h:59
int unplayedItemCount
Definition userdata.h:41
double rating
Definition userdata.h:39
int unplayedItemCount() const
Definition userdata.h:52
void likesChanged(bool newLikes)
void keyChanged(QString newKey)
bool favorite() const
Definition userdata.h:55
void favoriteChanged(bool newFavorite)
void playbackPositionTicksChanged(qint64 newPlaybackPositionTicks)
void unplayedItemCountChanged(int newUnplayedItemCount)
double playedPercentage
Definition userdata.h:40
QDateTime lastPlayedDate
Definition userdata.h:46
bool m_likes
Definition userdata.h:45
void ratingChanged(double newRating)
qint64 playbackPositionTicks() const
Definition userdata.h:53
QDateTime lastPlayedDate() const
Definition userdata.h:57
int playCount
Definition userdata.h:43
bool likes() const
Definition userdata.h:56
bool played() const
Definition userdata.h:58
void playedChanged(bool newPLayed)
bool favorite
Definition userdata.h:44
void playCountChanged(int newPlayCount)
UserItemDataDto UserData
Definition apiclient.h:58