2020-09-27 18:38:33 +00:00
|
|
|
/*
|
|
|
|
Sailfin: a Jellyfin client written using Qt
|
2021-02-17 18:42:10 +00:00
|
|
|
Copyright (C) 2021 Chris Josten
|
2020-09-27 18:38:33 +00:00
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
This library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with this library; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2021-02-17 18:42:10 +00:00
|
|
|
#include "JellyfinQt/apimodel.h"
|
|
|
|
|
2021-02-20 22:20:39 +00:00
|
|
|
#include "JellyfinQt/DTO/item.h"
|
2021-02-17 18:42:10 +00:00
|
|
|
#include "JellyfinQt/DTO/userdata.h"
|
2021-02-20 22:20:39 +00:00
|
|
|
#include "JellyfinQt/DTO/user.h"
|
2020-09-15 14:53:13 +00:00
|
|
|
|
|
|
|
namespace Jellyfin {
|
2021-02-20 22:20:39 +00:00
|
|
|
|
|
|
|
// BaseApiModel
|
|
|
|
|
|
|
|
BaseApiModel::BaseApiModel(QString path, bool hasRecordResponse, bool addUserId, QObject *parent)
|
|
|
|
: QAbstractListModel(parent),
|
2020-09-15 14:53:13 +00:00
|
|
|
m_path(path),
|
2020-09-27 01:14:05 +00:00
|
|
|
m_hasRecordResponse(hasRecordResponse),
|
2021-02-20 22:20:39 +00:00
|
|
|
m_addUserId(addUserId) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void BaseApiModel::setApiClient(ApiClient *apiClient) {
|
|
|
|
m_apiClient = apiClient;
|
|
|
|
emit apiClientChanged(m_apiClient);
|
2020-09-15 14:53:13 +00:00
|
|
|
}
|
|
|
|
|
2021-02-20 22:20:39 +00:00
|
|
|
void BaseApiModel::setLimit(int newLimit) {
|
|
|
|
m_limit = newLimit;
|
|
|
|
emit limitChanged(newLimit);
|
|
|
|
if (m_apiClient != nullptr && !m_isBeingParsed) {
|
|
|
|
load(LOAD_MORE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BaseApiModel::reload() {
|
2020-09-27 14:54:45 +00:00
|
|
|
this->setStatus(Loading);
|
|
|
|
m_startIndex = 0;
|
2020-09-27 01:14:05 +00:00
|
|
|
load(RELOAD);
|
|
|
|
}
|
|
|
|
|
2021-02-20 22:20:39 +00:00
|
|
|
|
|
|
|
void BaseApiModel::load(LoadType type) {
|
2020-09-27 01:14:05 +00:00
|
|
|
qDebug() << (type == RELOAD ? "RELOAD" : "LOAD_MORE");
|
2020-09-15 14:53:13 +00:00
|
|
|
if (m_apiClient == nullptr) {
|
|
|
|
qWarning() << "Please set the apiClient property before (re)loading";
|
|
|
|
return;
|
|
|
|
}
|
2021-02-20 22:20:39 +00:00
|
|
|
|
|
|
|
QString path(m_path);
|
|
|
|
replacePathPlaceholders(path);
|
2020-09-15 14:53:13 +00:00
|
|
|
QUrlQuery query;
|
2020-09-27 01:14:05 +00:00
|
|
|
addQueryParameters(query);
|
2021-02-20 22:20:39 +00:00
|
|
|
|
|
|
|
QNetworkReply *rep = m_apiClient->get(path, query);
|
2020-09-27 01:14:05 +00:00
|
|
|
connect(rep, &QNetworkReply::finished, this, [this, type, rep]() {
|
2021-02-20 22:20:39 +00:00
|
|
|
qDebug() << rep->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() << ": " << rep->request().url();
|
2020-09-15 14:53:13 +00:00
|
|
|
QJsonDocument doc = QJsonDocument::fromJson(rep->readAll());
|
2021-02-20 22:20:39 +00:00
|
|
|
if (doc.isNull()) {
|
|
|
|
qWarning() << "JSON parse error";
|
|
|
|
this->setStatus(Error);
|
|
|
|
}
|
2020-09-27 01:14:05 +00:00
|
|
|
if (!m_hasRecordResponse) {
|
2020-09-15 14:53:13 +00:00
|
|
|
if (!doc.isArray()) {
|
|
|
|
qWarning() << "Object is not an array!";
|
|
|
|
this->setStatus(Error);
|
|
|
|
return;
|
|
|
|
}
|
2021-02-20 22:20:39 +00:00
|
|
|
QJsonArray items = doc.array();
|
|
|
|
setModelData(items);
|
2020-09-15 14:53:13 +00:00
|
|
|
} else {
|
|
|
|
if (!doc.isObject()) {
|
|
|
|
qWarning() << "Object is not an object!";
|
|
|
|
this->setStatus(Error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
QJsonObject obj = doc.object();
|
2020-09-27 01:14:05 +00:00
|
|
|
if (!obj.contains("Items")) {
|
|
|
|
qWarning() << "Object doesn't contain items!";
|
2020-09-15 14:53:13 +00:00
|
|
|
this->setStatus(Error);
|
|
|
|
return;
|
|
|
|
}
|
2020-09-27 01:14:05 +00:00
|
|
|
if (m_limit < 0) {
|
|
|
|
// Javascript is beautiful
|
|
|
|
if (obj.contains("TotalRecordCount") && obj["TotalRecordCount"].isDouble()) {
|
|
|
|
m_totalRecordCount = obj["TotalRecordCount"].toInt();
|
|
|
|
m_startIndex += DEFAULT_LIMIT;
|
|
|
|
} else {
|
|
|
|
qWarning() << "Record-response does not have a total record count";
|
|
|
|
this->setStatus(Error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!obj["Items"].isArray()) {
|
|
|
|
qWarning() << "Items is not an array!";
|
2020-09-15 14:53:13 +00:00
|
|
|
this->setStatus(Error);
|
|
|
|
return;
|
|
|
|
}
|
2020-09-27 01:14:05 +00:00
|
|
|
QJsonArray items = obj["Items"].toArray();
|
|
|
|
switch(type) {
|
|
|
|
case RELOAD:
|
2021-02-20 22:20:39 +00:00
|
|
|
setModelData(items);
|
2020-09-27 01:14:05 +00:00
|
|
|
break;
|
|
|
|
case LOAD_MORE:
|
2021-02-20 22:20:39 +00:00
|
|
|
appendModelData(items);
|
2020-09-27 01:14:05 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2020-09-15 14:53:13 +00:00
|
|
|
this->setStatus(Ready);
|
|
|
|
rep->deleteLater();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-02-20 22:20:39 +00:00
|
|
|
void BaseApiModel::addQueryParameters(QUrlQuery &query) {
|
|
|
|
if (m_limit >= 0) {
|
|
|
|
query.addQueryItem("Limit", QString::number(m_limit));
|
|
|
|
} else {
|
|
|
|
query.addQueryItem("Limit", QString::number(DEFAULT_LIMIT));
|
|
|
|
}
|
|
|
|
if (m_startIndex > 0) {
|
|
|
|
query.addQueryItem("StartIndex", QString::number(m_startIndex));
|
|
|
|
}
|
|
|
|
if (!m_sortBy.empty()) {
|
|
|
|
query.addQueryItem("SortBy", m_sortBy.join(","));
|
|
|
|
}
|
|
|
|
if (m_sortOrder != Unspecified) {
|
|
|
|
query.addQueryItem("SortOrder", m_sortOrder == Ascending ? "Ascending" : "Descending");
|
|
|
|
}
|
|
|
|
if (!m_fields.empty()) {
|
|
|
|
query.addQueryItem("Fields", m_fields.join(","));
|
|
|
|
}
|
|
|
|
if (m_addUserId) {
|
|
|
|
query.addQueryItem("userId", m_apiClient->userId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BaseApiModel::replacePathPlaceholders(QString &path) {
|
|
|
|
if (path.contains("{{user}}")) {
|
|
|
|
path = path.replace("{{user}}", m_apiClient->userId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void BaseApiModel::classBegin() {
|
|
|
|
m_isBeingParsed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void BaseApiModel::componentComplete() {
|
|
|
|
m_isBeingParsed = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ApiModel
|
|
|
|
template <class T>
|
|
|
|
ApiModel<T>::ApiModel(QString path, bool hasRecordResponse, bool addUserId, QObject *parent)
|
|
|
|
: BaseApiModel(path, hasRecordResponse, addUserId, parent) {
|
|
|
|
// If based on QObject, we know our role names before the first request
|
|
|
|
generateFields();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
ApiModel<QJsonValue>::ApiModel(QString path, bool hasRecordResponse, bool addUserId, QObject *parent)
|
|
|
|
: BaseApiModel(path, hasRecordResponse, addUserId, parent) {
|
|
|
|
// But we only know our role names after our first request.
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
T *ApiModel<T>::deserializeResult(QJsonValueRef source) {
|
|
|
|
T *result = new T(static_cast<BaseApiModel *>(this));
|
|
|
|
result->deserialize(source.toObject());
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
QJsonValue *ApiModel<QJsonValue>::deserializeResult(QJsonValueRef source) {
|
|
|
|
QJsonValue *result = new QJsonValue(source);
|
|
|
|
JsonHelper::convertToCamelCase(*result);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
void ApiModel<T>::generateFields() {
|
|
|
|
const QMetaObject *obj = &T::staticMetaObject;
|
|
|
|
m_roles[Qt::UserRole + 1] = "qtObject";
|
|
|
|
for (int i = 0; i < obj->propertyCount(); i++) {
|
|
|
|
QMetaProperty property = obj->property(i);
|
|
|
|
m_roles.insert(Qt::UserRole + 2 + i, property.name());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
void ApiModel<QJsonValue>::generateFields() {
|
|
|
|
// We can only generate field names if there is a first item. Redefining role names later leads to
|
|
|
|
// unexpected results, so prevent it as well.
|
|
|
|
if (m_array.size() == 0 || m_roles.size() > 0) return;
|
2020-09-15 14:53:13 +00:00
|
|
|
int i = Qt::UserRole + 1;
|
2021-02-20 22:20:39 +00:00
|
|
|
if (!m_array[0]->isObject()) {
|
2020-09-15 14:53:13 +00:00
|
|
|
qWarning() << "Iterator is not an object?";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
// Walks over the keys in the first record and adds them to the rolenames.
|
|
|
|
// This assumes the back-end has the same keys for every record. I could technically
|
2021-02-20 22:20:39 +00:00
|
|
|
// go over all records to be really sure, but no-one got time for a O(n) algorithm, so
|
2020-09-15 14:53:13 +00:00
|
|
|
// this heuristic hopefully suffices.
|
2021-02-20 22:20:39 +00:00
|
|
|
QJsonObject ob = m_array[0]->toObject();
|
2020-09-15 14:53:13 +00:00
|
|
|
for (auto jt = ob.begin(); jt != ob.end(); jt++) {
|
|
|
|
QString keyName = jt.key();
|
|
|
|
keyName[0] = keyName[0].toLower();
|
|
|
|
QByteArray keyArr = keyName.toUtf8();
|
|
|
|
if (!m_roles.values().contains(keyArr)) {
|
|
|
|
m_roles.insert(i++, keyArr);
|
|
|
|
}
|
|
|
|
}
|
2021-02-20 22:20:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
void ApiModel<T>::setModelData(QJsonArray &data) {
|
|
|
|
this->beginResetModel();
|
|
|
|
for (T* value : m_array) {
|
|
|
|
value->deleteLater();
|
|
|
|
}
|
|
|
|
m_array.clear();
|
|
|
|
for(QJsonValueRef value : data) {
|
|
|
|
m_array.append(deserializeResult(value));
|
|
|
|
}
|
|
|
|
this->endResetModel();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
void ApiModel<QJsonValue>::setModelData(QJsonArray &data) {
|
|
|
|
generateFields();
|
|
|
|
this->beginResetModel();
|
|
|
|
for (QJsonValue* value : m_array) {
|
|
|
|
delete value;
|
|
|
|
}
|
|
|
|
m_array.clear();
|
|
|
|
for(QJsonValueRef value : data) {
|
|
|
|
m_array.append(deserializeResult(value));
|
2020-10-09 00:33:08 +00:00
|
|
|
}
|
2020-09-15 14:53:13 +00:00
|
|
|
this->endResetModel();
|
|
|
|
}
|
|
|
|
|
2021-02-20 22:20:39 +00:00
|
|
|
template <class T>
|
|
|
|
void ApiModel<T>::appendModelData(QJsonArray &data) {
|
|
|
|
this->beginInsertRows(QModelIndex(), m_array.size(), m_array.size() + data.size() - 1);
|
|
|
|
// QJsonArray apparently doesn't allow concatenating lists like QList or std::vector
|
|
|
|
for (auto it = data.begin(); it != data.end(); it++) {
|
|
|
|
JsonHelper::convertToCamelCase(*it);
|
|
|
|
}
|
|
|
|
for(QJsonValueRef val : data) {
|
|
|
|
m_array.append(deserializeResult(val));
|
|
|
|
}
|
|
|
|
this->endInsertRows();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
QVariant ApiModel<T>::data(const QModelIndex &index, int role) const {
|
|
|
|
// Ignore roles we don't know
|
|
|
|
if (role <= Qt::UserRole || role >= Qt::UserRole + m_roles.size()) return QVariant();
|
|
|
|
// Ignore invalid indices.
|
|
|
|
if (!index.isValid()) return QVariant();
|
|
|
|
|
|
|
|
|
|
|
|
T* obj = m_array.at(index.row());
|
|
|
|
// m_roleNames[role] == "qtObject"
|
|
|
|
if (role == Qt::UserRole + 1) {
|
|
|
|
return QVariant::fromValue(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
const QString &key = m_roles[role];
|
|
|
|
|
|
|
|
if (role - Qt::UserRole - 2 < obj->metaObject()->propertyCount() ) {
|
|
|
|
return obj->property(key.toLocal8Bit());
|
|
|
|
}
|
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
template <>
|
|
|
|
QVariant ApiModel<QJsonValue>::data(const QModelIndex &index, int role) const {
|
2020-09-15 14:53:13 +00:00
|
|
|
// Ignore roles we don't know
|
|
|
|
if (role <= Qt::UserRole || role >= Qt::UserRole + m_roles.size()) return QVariant();
|
|
|
|
// Ignore invalid indices.
|
|
|
|
if (!index.isValid()) return QVariant();
|
|
|
|
|
|
|
|
|
2021-02-20 22:20:39 +00:00
|
|
|
QJsonObject obj = m_array.at(index.row())->toObject();
|
2020-09-15 14:53:13 +00:00
|
|
|
|
2020-10-09 00:33:08 +00:00
|
|
|
const QString &key = m_roles[role];
|
2021-01-14 19:35:24 +00:00
|
|
|
|
2020-09-15 14:53:13 +00:00
|
|
|
if (obj.contains(key)) {
|
|
|
|
return obj[key].toVariant();
|
|
|
|
}
|
|
|
|
return QVariant();
|
|
|
|
}
|
|
|
|
|
2021-02-20 22:20:39 +00:00
|
|
|
|
|
|
|
template <class T>
|
|
|
|
bool ApiModel<T>::canFetchMore(const QModelIndex &parent) const {
|
2020-09-27 01:14:05 +00:00
|
|
|
if (parent.isValid()) return false;
|
|
|
|
switch(m_status) {
|
|
|
|
case Uninitialised:
|
|
|
|
case Loading:
|
2020-10-26 21:29:07 +00:00
|
|
|
case LoadingMore:
|
2020-09-27 01:14:05 +00:00
|
|
|
return false;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (m_limit < 0) {
|
|
|
|
return m_startIndex <= m_totalRecordCount;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-20 22:20:39 +00:00
|
|
|
template <class T>
|
|
|
|
void ApiModel<T>::fetchMore(const QModelIndex &parent) {
|
2020-09-27 01:14:05 +00:00
|
|
|
if (parent.isValid()) return;
|
2020-09-27 14:54:45 +00:00
|
|
|
this->setStatus(LoadingMore);
|
2020-09-27 01:14:05 +00:00
|
|
|
load(LOAD_MORE);
|
|
|
|
}
|
|
|
|
|
2021-02-20 22:20:39 +00:00
|
|
|
template <class T>
|
|
|
|
void ApiModel<T>::addQueryParameters(QUrlQuery &query) {
|
|
|
|
BaseApiModel::addQueryParameters(query);
|
|
|
|
}
|
2020-09-27 01:14:05 +00:00
|
|
|
|
2021-02-20 22:20:39 +00:00
|
|
|
template <class T>
|
|
|
|
void ApiModel<T>::replacePathPlaceholders(QString &path) {
|
|
|
|
BaseApiModel::replacePathPlaceholders(path);
|
|
|
|
}
|
2020-10-09 00:33:08 +00:00
|
|
|
|
2021-02-20 22:20:39 +00:00
|
|
|
template <class T>
|
|
|
|
void ApiModel<T>::insert(int index, T* object) {
|
|
|
|
Q_ASSERT(index >=0 && index <= size());
|
|
|
|
this->beginInsertRows(QModelIndex(), index, index);
|
|
|
|
m_array.insert(index, object);
|
|
|
|
this->endInsertRows();
|
|
|
|
}
|
2020-10-09 00:33:08 +00:00
|
|
|
|
2021-02-20 22:20:39 +00:00
|
|
|
template <class T>
|
|
|
|
void ApiModel<T>::removeAt(int index) {
|
|
|
|
this->beginRemoveRows(QModelIndex(), index, index);
|
|
|
|
m_array.removeAt(index);
|
|
|
|
this->endRemoveRows();
|
|
|
|
}
|
2020-10-09 00:33:08 +00:00
|
|
|
|
2021-02-20 22:20:39 +00:00
|
|
|
template <class T>
|
|
|
|
void ApiModel<T>::removeOne(T* object) {
|
|
|
|
int idx = m_array.indexOf(object);
|
|
|
|
if (idx >= 0) {
|
|
|
|
removeAt(idx);
|
|
|
|
}
|
|
|
|
}
|
2020-10-09 00:33:08 +00:00
|
|
|
|
2021-02-20 22:20:39 +00:00
|
|
|
// Itemmodel
|
2020-10-09 00:33:08 +00:00
|
|
|
ItemModel::ItemModel(QString path, bool hasRecordFields, bool replaceUser, QObject *parent)
|
|
|
|
: ApiModel (path, hasRecordFields, replaceUser, parent){
|
2021-02-20 22:20:39 +00:00
|
|
|
QObject::connect(this, &BaseApiModel::apiClientChanged, static_cast<BaseApiModel *>(this), [this](ApiClient *newApiClient) {
|
|
|
|
QObject::connect(newApiClient, &ApiClient::userDataChanged, this, &ItemModel::onUserDataChanged);
|
2020-10-09 00:33:08 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-02-20 22:20:39 +00:00
|
|
|
void ItemModel::onUserDataChanged(const QString &itemId, DTO::UserData *userData) {
|
2020-10-09 00:33:08 +00:00
|
|
|
int i = 0;
|
2021-02-20 22:20:39 +00:00
|
|
|
for (Item *val: m_array) {
|
|
|
|
if (val->userData() != nullptr && val->jellyfinId() == itemId) {
|
|
|
|
QModelIndex cell = this->index(i);
|
|
|
|
val->userData()->onUpdated(userData);
|
|
|
|
this->dataChanged(cell, cell);
|
2020-10-09 00:33:08 +00:00
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-20 22:20:39 +00:00
|
|
|
void ItemModel::addQueryParameters(QUrlQuery &query) {
|
|
|
|
ApiModel<Item>::addQueryParameters(query);
|
|
|
|
if (!m_parentId.isEmpty()) {
|
|
|
|
query.addQueryItem("ParentId", m_parentId);
|
|
|
|
}
|
|
|
|
if (!m_imageTypes.empty()) {
|
|
|
|
query.addQueryItem("ImageTypes", m_imageTypes.join(","));
|
|
|
|
}
|
|
|
|
if (!m_includeItemTypes.empty()) {
|
|
|
|
query.addQueryItem("IncludeItemTypes", m_includeItemTypes.join(","));
|
|
|
|
}
|
|
|
|
if (!m_seasonId.isEmpty()) {
|
|
|
|
query.addQueryItem("seasonId", m_seasonId);
|
|
|
|
}
|
|
|
|
if (m_recursive) {
|
|
|
|
query.addQueryItem("Recursive", "true");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ItemModel::replacePathPlaceholders(QString &path) {
|
|
|
|
ApiModel::replacePathPlaceholders(path);
|
|
|
|
if (path.contains("{{show}}") && !m_show.isEmpty()) {
|
|
|
|
path = m_path.replace("{{show}}", m_show);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-25 18:58:02 +00:00
|
|
|
PublicUserModel::PublicUserModel(QObject *parent)
|
|
|
|
: ApiModel ("/users/public", false, false, parent) { }
|
|
|
|
|
|
|
|
UserViewModel::UserViewModel(QObject *parent)
|
2021-02-20 22:20:39 +00:00
|
|
|
: ItemModel ("/Users/{{user}}/Views", true, false, parent) {}
|
2020-10-25 18:58:02 +00:00
|
|
|
|
|
|
|
UserItemModel::UserItemModel(QObject *parent)
|
|
|
|
: ItemModel ("/Users/{{user}}/Items", true, false, parent) {}
|
|
|
|
|
|
|
|
UserItemResumeModel::UserItemResumeModel(QObject *parent)
|
|
|
|
: ItemModel ("/Users/{{user}}/Items/Resume", true, false, parent) {}
|
|
|
|
|
|
|
|
UserItemLatestModel::UserItemLatestModel(QObject *parent)
|
|
|
|
: ItemModel ("/Users/{{user}}/Items/Latest", false, false, parent) {}
|
|
|
|
|
|
|
|
ShowNextUpModel::ShowNextUpModel(QObject *parent)
|
|
|
|
: ItemModel("/Shows/NextUp", true, true, parent) {}
|
|
|
|
|
|
|
|
ShowSeasonsModel::ShowSeasonsModel(QObject *parent)
|
|
|
|
: ItemModel ("/Shows/{{show}}/Seasons", true, true, parent) {}
|
|
|
|
|
|
|
|
ShowEpisodesModel::ShowEpisodesModel(QObject *parent)
|
|
|
|
: ItemModel ("/Shows/{{show}}/Episodes", true, true, parent) {}
|
2020-09-27 01:14:05 +00:00
|
|
|
|
2020-09-15 14:53:13 +00:00
|
|
|
void registerModels(const char *URI) {
|
2021-02-20 22:20:39 +00:00
|
|
|
qmlRegisterUncreatableType<BaseApiModel>(URI, 1, 0, "ApiModel", "Is enum and base class");
|
2020-10-01 09:56:02 +00:00
|
|
|
qmlRegisterUncreatableType<SortOptions>(URI, 1, 0, "SortOptions", "Is enum");
|
2020-09-15 14:53:13 +00:00
|
|
|
qmlRegisterType<PublicUserModel>(URI, 1, 0, "PublicUserModel");
|
|
|
|
qmlRegisterType<UserViewModel>(URI, 1, 0, "UserViewModel");
|
|
|
|
qmlRegisterType<UserItemModel>(URI, 1, 0, "UserItemModel");
|
2020-09-25 15:14:44 +00:00
|
|
|
qmlRegisterType<UserItemLatestModel>(URI, 1, 0, "UserItemLatestModel");
|
2020-09-27 14:54:45 +00:00
|
|
|
qmlRegisterType<UserItemResumeModel>(URI, 1, 0, "UserItemResumeModel");
|
2020-10-10 14:26:08 +00:00
|
|
|
qmlRegisterType<ShowNextUpModel>(URI, 1, 0, "ShowNextUpModel");
|
2020-09-26 00:51:37 +00:00
|
|
|
qmlRegisterType<ShowSeasonsModel>(URI, 1, 0, "ShowSeasonsModel");
|
|
|
|
qmlRegisterType<ShowEpisodesModel>(URI, 1, 0, "ShowEpisodesModel");
|
2020-09-15 14:53:13 +00:00
|
|
|
}
|
|
|
|
}
|