19#ifndef JELLYFIN_DTO_DTO
20#define JELLYFIN_DTO_DTO
25#include <QFutureWatcher>
27#include <QMutexLocker>
28#include <QtConcurrent/QtConcurrent>
42class LoaderBase :
public QObject,
public QQmlParserStatus {
44 Q_INTERFACES(QQmlParserStatus)
58 explicit
LoaderBase(QObject *parent =
nullptr) : QObject(parent) {}
71 virtual QObject *
data()
const {
return nullptr; }
134 QString m_errorString;
135 bool m_autoReload =
true;
136 bool m_isParsing =
false;
147template <
class T,
class R,
class P>
149 using RFutureWatcher = QFutureWatcher<std::optional<R>>;
152 :
Loader(nullptr, loaderImpl, parent) {}
181 QScopedPointer<Support::Loader<R, P>>
m_loader =
nullptr;
187 void onLoaderReady() {
200 }
catch(QException &e) {
206 void onLoaderError(QString message) {
An Api client for Jellyfin. Handles requests and authentication.
Definition apiclient.h:90
void error(QString message=QString())
Emitted when an error has occurred during loading and no result is available.
void ready()
Emitted when data was successfully loaded.
An "interface" for a remote data source.
Definition loader.h:42
void setExtraFields(const QStringList &extraFields)
LoaderBase(ApiClient *apiClient, QObject *parent=nullptr)
Definition loader.h:59
bool isQmlParsing() const
Definition loader.h:130
void classBegin() override
Definition loader.h:119
void ready()
Convenience signal for status == RemoteData.Ready.
QObject * data
Definition loader.h:66
void statusChanged(Jellyfin::ViewModel::LoaderBase::Status newStatus)
void autoReloadChanged(bool newAutoReload)
void setApiClient(ApiClient *newApiClient)
Definition loader.cpp:41
void setStatus(Status newStatus)
Definition loader.cpp:30
Status
Definition loader.h:46
@ Ready
The data is ready, the properties in this object are up to date.
Definition loader.h:52
@ Loading
The data is being loaded over the network.
Definition loader.h:50
@ Error
An error has occurred while loading the data. See error() for more details.
Definition loader.h:54
@ Uninitialised
The data is unitialized and not loading either.
Definition loader.h:48
void reloadIfNeeded()
Definition loader.h:114
void setErrorString(const QString &newErrorString)
Definition loader.cpp:36
bool autoReload
Definition loader.h:65
void componentComplete() override
Definition loader.h:123
virtual void reload()
Overload this method to reimplement the fetching mechanism to populate the RemoteData with data from ...
Definition loader.h:98
void errorStringChanged(QString newErrorString)
void apiClientChanged(ApiClient *newApiClient)
void setError(QNetworkReply::NetworkError error)
QString errorString
Definition loader.h:64
virtual QObject * data() const
Definition loader.h:71
ApiClient * apiClient
Definition loader.h:62
Jellyfin::ViewModel::LoaderBase::Status status
Definition loader.h:63
void emitDataChanged()
Definition loader.cpp:47
virtual bool canReload() const
Subclasses should implement this to determine if they can load data from the server.
Definition loader.cpp:26
QString errorString() const
Definition loader.h:69
ApiClient * m_apiClient
Definition loader.h:127
QObject * data() const override
Definition loader.h:164
Loader(Support::Loader< R, P > *loaderImpl, QObject *parent=nullptr)
Definition loader.h:151
QScopedPointer< Support::Loader< R, P > > m_loader
Subclasses should initialize this to a loader that actually loads stuff.
Definition loader.h:181
P m_parameters
Definition loader.h:177
Loader(ApiClient *apiClient, Support::Loader< R, P > *loaderImpl, QObject *parent=nullptr)
Definition loader.h:154
T * m_dataViewModel
Definition loader.h:176
T * dataViewModel() const
Definition loader.h:163
void reload() override
Overload this method to reimplement the fetching mechanism to populate the RemoteData with data from ...
Definition loader.h:166
void registerRemoteTypes(const char *uri)
Definition loader.cpp:51
void writeRequestTypesFile R(File headerFile, File implementationFile, R endpoints) if(is(ElementType!R
Definition openapigenerator.d:278