Jellyfin Qt
QML Library for interacting with the Jellyfin multimedia server
Loading...
Searching...
No Matches
Jellyfin::ViewModel::LoaderBase Class Reference

An "interface" for a remote data source. More...

#include <loader.h>

Inheritance diagram for Jellyfin::ViewModel::LoaderBase:
Jellyfin::ViewModel::Loader< ViewModel::Item, DTO::BaseItemDto, Jellyfin::Loader::GetItemParams > Jellyfin::ViewModel::Loader< T, R, P > Jellyfin::ViewModel::ItemLoader Jellyfin::ViewModel::UserLoader

Public Types

enum  Status { Uninitialised , Loading , Ready , Error }
 

Public Slots

virtual void reload ()
 Overload this method to reimplement the fetching mechanism to populate the RemoteData with data from the server.
 

Signals

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.
 

Public Member Functions

 LoaderBase (QObject *parent=nullptr)
 
 LoaderBase (ApiClient *apiClient, QObject *parent=nullptr)
 
Status status () const
 
QString errorString () const
 
virtual QObject * data () const
 
void setApiClient (ApiClient *newApiClient)
 
void setExtraFields (const QStringList &extraFields)
 

Protected Member Functions

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 ()
 

Protected Attributes

ApiClientm_apiClient = nullptr
 

Properties

ApiClientapiClient
 
Jellyfin::ViewModel::LoaderBase::Status status
 
QString errorString
 
bool autoReload
 
QObject * data
 

Detailed Description

An "interface" for a remote data source.

This class is basically a base class for JSON data that can be fetched from over the network. Subclasses should reimplement reload and call setStatus to update the QML part of the code appropiatly.

Member Enumeration Documentation

◆ Status

Enumerator
Uninitialised 

The data is unitialized and not loading either.

Loading 

The data is being loaded over the network.

Ready 

The data is ready, the properties in this object are up to date.

Error 

An error has occurred while loading the data. See error() for more details.

Constructor & Destructor Documentation

◆ LoaderBase() [1/2]

Jellyfin::ViewModel::LoaderBase::LoaderBase ( QObject * parent = nullptr)
inlineexplicit

◆ LoaderBase() [2/2]

Jellyfin::ViewModel::LoaderBase::LoaderBase ( ApiClient * apiClient,
QObject * parent = nullptr )
inline

Member Function Documentation

◆ apiClientChanged

void Jellyfin::ViewModel::LoaderBase::apiClientChanged ( ApiClient * newApiClient)
signal

◆ autoReloadChanged

void Jellyfin::ViewModel::LoaderBase::autoReloadChanged ( bool newAutoReload)
signal

◆ canReload()

bool Jellyfin::ViewModel::LoaderBase::canReload ( ) const
protectedvirtual

Subclasses should implement this to determine if they can load data from the server.

Usage cases include checking if the required properties, such as the item id are set.

Reimplemented in Jellyfin::ViewModel::ItemLoader, and Jellyfin::ViewModel::UserLoader.

◆ classBegin()

void Jellyfin::ViewModel::LoaderBase::classBegin ( )
inlineoverrideprotected

◆ componentComplete()

void Jellyfin::ViewModel::LoaderBase::componentComplete ( )
inlineoverrideprotected

◆ data()

virtual QObject * Jellyfin::ViewModel::LoaderBase::data ( ) const
inlinevirtual

◆ dataChanged

void Jellyfin::ViewModel::LoaderBase::dataChanged ( )
signal

◆ emitDataChanged()

void Jellyfin::ViewModel::LoaderBase::emitDataChanged ( )
protected

◆ errorString()

QString Jellyfin::ViewModel::LoaderBase::errorString ( ) const
inline

◆ errorStringChanged

void Jellyfin::ViewModel::LoaderBase::errorStringChanged ( QString newErrorString)
signal

◆ isQmlParsing()

bool Jellyfin::ViewModel::LoaderBase::isQmlParsing ( ) const
inlineprotected

◆ ready

void Jellyfin::ViewModel::LoaderBase::ready ( )
signal

Convenience signal for status == RemoteData.Ready.

◆ reload

virtual void Jellyfin::ViewModel::LoaderBase::reload ( )
inlinevirtualslot

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 in Jellyfin::ViewModel::Loader< T, R, P >, and Jellyfin::ViewModel::Loader< ViewModel::Item, DTO::BaseItemDto, Jellyfin::Loader::GetItemParams >.

◆ reloadIfNeeded()

void Jellyfin::ViewModel::LoaderBase::reloadIfNeeded ( )
inlineprotected

◆ setApiClient()

void Jellyfin::ViewModel::LoaderBase::setApiClient ( ApiClient * newApiClient)

◆ setError()

void Jellyfin::ViewModel::LoaderBase::setError ( QNetworkReply::NetworkError error)
protected

◆ setErrorString()

void Jellyfin::ViewModel::LoaderBase::setErrorString ( const QString & newErrorString)
protected

◆ setExtraFields()

void Jellyfin::ViewModel::LoaderBase::setExtraFields ( const QStringList & extraFields)

◆ setStatus()

void Jellyfin::ViewModel::LoaderBase::setStatus ( Status newStatus)
protected

◆ status()

Status Jellyfin::ViewModel::LoaderBase::status ( ) const
inline

◆ statusChanged

void Jellyfin::ViewModel::LoaderBase::statusChanged ( Jellyfin::ViewModel::LoaderBase::Status newStatus)
signal

Member Data Documentation

◆ m_apiClient

ApiClient* Jellyfin::ViewModel::LoaderBase::m_apiClient = nullptr
protected

Property Documentation

◆ apiClient

ApiClient * Jellyfin::ViewModel::LoaderBase::apiClient
write

◆ autoReload

bool Jellyfin::ViewModel::LoaderBase::autoReload

◆ data

QObject * Jellyfin::ViewModel::LoaderBase::data
read

◆ errorString

QString Jellyfin::ViewModel::LoaderBase::errorString
read

◆ status

Jellyfin::ViewModel::LoaderBase::Status Jellyfin::ViewModel::LoaderBase::status
read

The documentation for this class was generated from the following files: