19#ifndef JELLYFIN_VIEWMODEL_ITEMMODEL_H
20#define JELLYFIN_VIEWMODEL_ITEMMODEL_H
22#include <QAbstractListModel>
24#include <QScopedPointer>
25#include <QVariantList>
37#define FWDPROP(type, propName, propSetName) \
39 Q_PROPERTY(type propName READ propName WRITE set##propSetName NOTIFY propName##Changed) \
40 type propName() const { return this->m_parameters.propName(); } \
41 void set##propSetName(type newValue) { \
42 this->m_parameters.set##propSetName( newValue ); \
43 emit propName##Changed(); \
44 autoReloadIfNeeded(); \
47 void propName##Changed();
49#define FWDLISTPROP(type, propName, propSetName) \
51 Q_PROPERTY(QVariantList propName READ propName WRITE set##propSetName NOTIFY propName##Changed) \
52 QVariantList propName() const { \
53 QVariantList result; \
55 result.reserve(list.size()); \
56 for (auto it = list.cbegin(); it != list.cend(); it++) { \
57 result.append(QVariant::fromValue<type>(*it)); \
61 void set##propSetName(const QVariantList &newValue) { \
63 list.reserve(newValue.size()); \
64 for(auto it = newValue.cbegin(); it != newValue.cend(); it++) { \
65 list.append(it->value<type>()); \
67 this->m_parameters.set##propSetName(list); \
68 emit propName##Changed(); \
69 autoReloadIfNeeded(); \
72 void propName##Changed();
79#define JFRN(name) {RoleNames::name, #name}
87template <
class T,
class D,
class R,
class P>
99 void apiClientChanged(
ApiClient *newApiClient) {
103 if (newApiClient !=
nullptr) {
104 this->connect(newApiClient, &
ApiClient::userIdChanged,
this, &AbstractUserParameterLoader<T, D, R, P>::userIdChanged);
105 if (!newApiClient->
userId().isNull()) {
111 void userIdChanged(
const QString &newUserId) {
143 FWDPROP(qint32, imageTypeLimit, ImageTypeLimit)
144 FWDPROP(QStringList, includeItemTypes, IncludeItemTypes)
156 FWDPROP(QStringList, albumArtistIds, AlbumArtistIds)
161 FWDPROP(
bool, collapseBoxSetItems, CollapseBoxSetItems)
162 FWDPROP(QStringList, contributingArtistIds, ContributingArtistIds)
165 FWDPROP(
bool, enableTotalRecordCount, EnableTotalRecordCount)
167 FWDPROP(QStringList, excludeArtistIds, ExcludeArtistIds)
168 FWDPROP(QStringList, excludeItemIds, ExcludeItemIds)
169 FWDPROP(QStringList, excludeItemTypes, ExcludeItemTypes)
176 FWDPROP(
bool, hasOfficialRating, HasOfficialRating)
178 FWDPROP(
bool, hasParentalRating, HasParentalRating)
179 FWDPROP(
bool, hasSpecialFeature, HasSpecialFeature)
187 FWDPROP(qint32, imageTypeLimit, ImageTypeLimit)
189 FWDPROP(QStringList, includeItemTypes, IncludeItemTypes)
201 FWDPROP(QString, maxOfficialRating, MaxOfficialRating)
202 FWDPROP(QDateTime, maxPremiereDate, MaxPremiereDate)
206 FWDPROP(QString, minOfficialRating, MinOfficialRating)
207 FWDPROP(QDateTime, minPremiereDate, MinPremiereDate)
228 FWDPROP(
bool, enableTotalRecordCount, EnableTotalRecordCount)
230 FWDPROP(QStringList, excludeItemTypes, ExcludeItemTypes)
232 FWDPROP(qint32, imageTypeLimit, ImageTypeLimit)
233 FWDPROP(QStringList, includeItemTypes, IncludeItemTypes)
251 FWDPROP(qint32, imageTypeLimit, ImageTypeLimit)
253 FWDPROP(
bool, isSpecialSeason, IsSpecialSeason)
268 FWDPROP(qint32, imageTypeLimit, ImageTypeLimit)
282 FWDPROP(
bool, disableFirstEpisode, DisableFirstEpisode)
285 FWDPROP(
bool, enableTotalRecordCount, EnableTotalRecordCount)
288 FWDPROP(qint32, imageTypeLimit, ImageTypeLimit)
301 FWDPROP(
bool, enableTotalRecordCount, EnableTotalRecordCount)
303 FWDPROP(QStringList, excludeItemTypes, ExcludeItemTypes)
308 FWDPROP(qint32, imageTypeLimit, ImageTypeLimit)
309 FWDPROP(QStringList, includeItemTypes, IncludeItemTypes)
313 FWDPROP(
double, minCommunityRating, MinCommunityRating)
315 FWDPROP(QString, nameStartsWith, NameStartsWith)
316 FWDPROP(QString, nameStartsWithOrGreater, NameStartsWithOrGreater)
317 FWDPROP(QStringList, officialRatings, OfficialRatings)
320 FWDPROP(QStringList, personTypes, PersonTypes)
352 FWDPROP(
bool, enableFavoriteSorting, EnableFavoriteSorting)
353 FWDPROP(
bool, addCurrentProgram, AddCurrentProgram)
364 jellyfinId = Qt::UserRole + 1,
403 jellyfinExtendModelAfterHere = Qt::UserRole + 300
406 explicit ItemModel (QObject *parent =
nullptr);
408 virtual QHash<int, QByteArray>
roleNames()
const override {
416 JFRN(playlistItemId),
418 JFRN(dateLastMediaAdded),
422 JFRN(imageBlurHashes),
425 JFRN(collectionType),
432 JFRN(parentIndexNumber),
433 JFRN(userDataRating),
434 JFRN(userDataPlayedPercentage),
435 JFRN(userDataUnplayedItemCount),
436 JFRN(userDataPlaybackPositionTicks),
437 JFRN(userDataPlayCount),
438 JFRN(userDataFavorite),
440 JFRN(userDataLastPlayedDate),
441 JFRN(userDataPlayed),
443 JFRN(currentProgramName),
444 JFRN(currentProgramOverview),
445 JFRN(currentProgramStartDate),
446 JFRN(currentProgramEndDate),
449 QVariant data(
const QModelIndex &index,
int role)
const override;
450 QSharedPointer<Model::Item> itemAt(
int index);
452 void onInsertItems(
const QModelIndex &parent,
int start,
int end);
An Api client for Jellyfin. Handles requests and authentication.
Definition apiclient.h:90
void userIdChanged(QString userId)
QString userId
Definition apiclient.h:103
Abstract model for displaying collections.
Definition apimodel.h:405
int limit
Definition apimodel.h:75
void autoReloadIfNeeded()
Definition apimodel.cpp:49
void apiClientChanged(ApiClient *newApiClient)
virtual bool canReload() const
Determines if this model is able to reload.
Definition apimodel.cpp:83
ApiClient * m_apiClient
Definition apimodel.h:117
Definition baseitemdtoqueryresult.h:50
Definition baseitemdto.h:70
Value
Definition channeltype.h:49
Definition imagetype.h:46
Value
Definition imagetype.h:49
Definition itemfields.h:46
Definition itemfilter.h:46
Definition locationtype.h:46
Definition sortorder.h:46
Value
Definition sortorder.h:49
Definition useritemdatadto.h:49
Definition apimodel.h:282
P m_parameters
Definition apimodel.h:328
Class intended for models which have a mandatory userId property, which can be extracted from the Api...
Definition itemmodel.h:88
AbstractUserParameterLoader(Support::Loader< R, P > *loader, QObject *parent=nullptr)
Definition itemmodel.h:90
virtual bool canReload() const override
Determines if this model is able to reload.
Definition itemmodel.h:95
Definition itemmodel.h:294
Base class for each model that works with items.
Definition itemmodel.h:360
RoleNames
Definition itemmodel.h:363
@ collectionType
Definition itemmodel.h:380
@ userDataPlayCount
Definition itemmodel.h:392
@ userDataPlayedPercentage
Definition itemmodel.h:389
@ currentProgramName
Definition itemmodel.h:398
@ artistItems
Definition itemmodel.h:384
@ parentIndexNumber
Definition itemmodel.h:387
@ userDataLastPlayedDate
Definition itemmodel.h:395
@ serverId
Definition itemmodel.h:367
@ runTimeTicks
Definition itemmodel.h:382
@ userDataKey
Definition itemmodel.h:397
@ currentProgramEndDate
Definition itemmodel.h:401
@ imageTags
Definition itemmodel.h:376
@ mediaType
Definition itemmodel.h:378
@ userDataPlaybackPositionTicks
Definition itemmodel.h:391
@ sourceType
Definition itemmodel.h:369
@ name
Definition itemmodel.h:365
@ imageBlurHashes
Definition itemmodel.h:377
@ currentProgramStartDate
Definition itemmodel.h:400
@ dateLastMediaAdded
Definition itemmodel.h:372
@ overview
Definition itemmodel.h:386
@ userDataRating
Definition itemmodel.h:388
@ etag
Definition itemmodel.h:368
@ indexNumber
Definition itemmodel.h:381
@ extraType
Definition itemmodel.h:373
@ userDataFavorite
Definition itemmodel.h:393
@ originalTitle
Definition itemmodel.h:366
@ dateCreated
Definition itemmodel.h:371
@ userDataUnplayedItemCount
Definition itemmodel.h:390
@ type
Definition itemmodel.h:379
@ artists
Definition itemmodel.h:383
@ userDataLikes
Definition itemmodel.h:394
@ playlistItemId
Definition itemmodel.h:370
@ isFolder
Definition itemmodel.h:385
@ userDataPlayed
Definition itemmodel.h:396
@ currentProgramOverview
Definition itemmodel.h:399
virtual QHash< int, QByteArray > roleNames() const override
Definition itemmodel.h:408
Definition itemmodel.h:331
Definition itemmodel.h:277
Definition itemmodel.h:221
Definition itemmodel.h:258
Definition itemmodel.h:240
Definition itemmodel.h:150
Definition itemmodel.h:121
QStringList presetViews
Definition itemmodel.h:128
bool includeExternalContent
Definition itemmodel.h:126
bool includeHidden
Definition itemmodel.h:127
UserViewsLoader(QObject *parent=nullptr)
Definition itemmodel.cpp:44
Definition mediaplayer2.h:20
#define JFRN(name)
Definition itemmodel.h:79
#define FWDLISTPROP(type, propName, propSetName)
Definition itemmodel.h:49
#define FWDPROP(type, propName, propSetName)
Definition itemmodel.h:37
void writeRequestTypesFile R(File headerFile, File implementationFile, R endpoints) if(is(ElementType!R
Definition openapigenerator.d:278