Jellyfin Qt
QML Library for interacting with the Jellyfin multimedia server
Loading...
Searching...
No Matches
Jellyfin::ViewModel::Loader< T, R, P > Class Template Reference

#include <loader.h>

Inheritance diagram for Jellyfin::ViewModel::Loader< T, R, P >:
Jellyfin::ViewModel::LoaderBase

Public Member Functions

 Loader (Support::Loader< R, P > *loaderImpl, QObject *parent=nullptr)
 Loader (ApiClient *apiClient, Support::Loader< R, P > *loaderImpl, QObject *parent=nullptr)
T * dataViewModel () const
QObject * data () const override
void reload () override
 Overload this method to reimplement the fetching mechanism to populate the RemoteData with data from the server.
Public Member Functions inherited from Jellyfin::ViewModel::LoaderBase
 LoaderBase (QObject *parent=nullptr)
 LoaderBase (ApiClient *apiClient, QObject *parent=nullptr)
Status status () const
QString errorString () const
void setApiClient (ApiClient *newApiClient)
void setExtraFields (const QStringList &extraFields)

Protected Attributes

T * m_dataViewModel
m_parameters
QScopedPointer< Support::Loader< R, P > > m_loader = nullptr
 Subclasses should initialize this to a loader that actually loads stuff.
Protected Attributes inherited from Jellyfin::ViewModel::LoaderBase
ApiClientm_apiClient = nullptr

Additional Inherited Members

Public Types inherited from Jellyfin::ViewModel::LoaderBase
enum  Status { Uninitialised , Loading , Ready , Error }
Signals inherited from Jellyfin::ViewModel::LoaderBase
void statusChanged (Jellyfin::ViewModel::LoaderBase::Status newStatus)
void apiClientChanged (ApiClient *newApiClient)
void errorStringChanged (QString newErrorString)
void autoReloadChanged (bool newAutoReload)
void dataChanged ()
void ready ()
 Convenience signal for status == RemoteData.Ready.
Protected Member Functions inherited from Jellyfin::ViewModel::LoaderBase
virtual bool canReload () const
 Subclasses should implement this to determine if they can load data from the server.
void setStatus (Status newStatus)
void setError (QNetworkReply::NetworkError error)
void setErrorString (const QString &newErrorString)
void reloadIfNeeded ()
void classBegin () override
void componentComplete () override
bool isQmlParsing () const
void emitDataChanged ()
Properties inherited from Jellyfin::ViewModel::LoaderBase
ApiClientapiClient
Jellyfin::ViewModel::LoaderBase::Status status
QString errorString
bool autoReload
QObject * data

Detailed Description

template<class T, class R, class P>
class Jellyfin::ViewModel::Loader< T, R, P >

Class representing data from a remote source, meant to be instantiated from QML.

Subclasses should do the following:

  • initialize m_loader with an appropiate loader
  • create properties that map to the parameters.
  • override canReload()

Constructor & Destructor Documentation

◆ Loader() [1/2]

template<class T, class R, class P>
Jellyfin::ViewModel::Loader< T, R, P >::Loader ( Support::Loader< R, P > * loaderImpl,
QObject * parent = nullptr )
inline

◆ Loader() [2/2]

template<class T, class R, class P>
Jellyfin::ViewModel::Loader< T, R, P >::Loader ( ApiClient * apiClient,
Support::Loader< R, P > * loaderImpl,
QObject * parent = nullptr )
inline

Member Function Documentation

◆ data()

template<class T, class R, class P>
QObject * Jellyfin::ViewModel::Loader< T, R, P >::data ( ) const
inlineoverridevirtual

Reimplemented from Jellyfin::ViewModel::LoaderBase.

◆ dataViewModel()

template<class T, class R, class P>
T * Jellyfin::ViewModel::Loader< T, R, P >::dataViewModel ( ) const
inline

◆ reload()

template<class T, class R, class P>
void Jellyfin::ViewModel::Loader< T, R, P >::reload ( )
inlineoverridevirtual

Overload this method to reimplement the fetching mechanism to populate the RemoteData with data from the server.

The default implementation makes a GET request to getDataUrl() and parses the resulting JSON, which should be enough for most cases. Consider overriding getDataUrl() and canRelaod() if possible. Manual overrides need to make sure that they're calling setStatus(Status), setError(QNetworkReply::NetworkError) and setErrorString() to let the QML side know what this thing is up to.

Reimplemented from Jellyfin::ViewModel::LoaderBase.

Member Data Documentation

◆ m_dataViewModel

template<class T, class R, class P>
T* Jellyfin::ViewModel::Loader< T, R, P >::m_dataViewModel
protected

◆ m_loader

template<class T, class R, class P>
QScopedPointer<Support::Loader<R, P> > Jellyfin::ViewModel::Loader< T, R, P >::m_loader = nullptr
protected

Subclasses should initialize this to a loader that actually loads stuff.

◆ m_parameters

template<class T, class R, class P>
P Jellyfin::ViewModel::Loader< T, R, P >::m_parameters
protected

The documentation for this class was generated from the following file:
  • core/include/JellyfinQt/viewmodel/loader.h