Jellyfin Qt
QML Library for interacting with the Jellyfin multimedia server
Loading...
Searching...
No Matches
Jellyfin::ModelLoader< T > Class Template Referenceabstract

#include <apimodel.h>

Inheritance diagram for Jellyfin::ModelLoader< T >:
Jellyfin::BaseModelLoader Jellyfin::LoaderModelLoader< T, D, R, P > Jellyfin::ViewModel::AbstractUserParameterLoader< T, D, R, P > Jellyfin::ViewModel::PublicUsersLoader Jellyfin::ViewModel::AlbumArtistLoader Jellyfin::ViewModel::LatestMediaLoader Jellyfin::ViewModel::LiveTvChannelsLoader Jellyfin::ViewModel::NextUpLoader Jellyfin::ViewModel::ResumeItemsLoader Jellyfin::ViewModel::ShowEpisodesLoader Jellyfin::ViewModel::ShowSeasonsLoader Jellyfin::ViewModel::UserItemsLoader Jellyfin::ViewModel::UserViewsLoader

Public Member Functions

 ModelLoader (QObject *parent=nullptr)
 
void reload () override
 Clears and reloads the model.
 
void loadMore ()
 
virtual bool canLoadMore () const
 
std::pair< QList< T * >, int > && result ()
 Holds the result. Moves it result to the caller and therefore can be only called once when the itemsLoaded is emitted.
 
- Public Member Functions inherited from Jellyfin::BaseModelLoader
 BaseModelLoader (QObject *parent=nullptr)
 
ApiClientapiClient () const
 
void setApiClient (ApiClient *newApiClient)
 
int limit () const
 
void setLimit (int newLimit)
 
bool autoReload () const
 
void setAutoReload (bool newAutoReload)
 
ViewModel::ModelStatus status () const
 
virtual void classBegin () override
 
virtual void componentComplete () override
 
void autoReloadIfNeeded ()
 

Protected Member Functions

virtual void loadMore (ViewModel::ModelStatus suggestedStatus)=0
 Loads data from the given offset with a maximum count of limit. The itemsLoaded() signal is emitted when new data is ready. Call getLoadedItems to retrieve the loaded items.
 
- Protected Member Functions inherited from Jellyfin::BaseModelLoader
void emitModelShouldClear ()
 
void emitItemsLoaded ()
 
void setStatus (ViewModel::ModelStatus newStatus)
 
virtual bool canReload () const
 Determines if this model is able to reload.
 

Protected Attributes

std::pair< QList< T * >, int > m_result
 
- Protected Attributes inherited from Jellyfin::BaseModelLoader
bool m_isBeingParsed = false
 
ApiClientm_apiClient = nullptr
 
bool m_autoReload = true
 
bool m_needsAuthentication = true
 
bool m_manualLimitSet = false
 
int m_limit = -1
 
int m_startIndex = 0
 
int m_totalRecordCount = 0
 
bool m_explicitLimitSet = false
 
const int DEFAULT_LIMIT = 100
 
ViewModel::ModelStatus m_status = ViewModel::ModelStatus::Uninitialised
 

Additional Inherited Members

- Signals inherited from Jellyfin::BaseModelLoader
void ready ()
 
void apiClientChanged (ApiClient *newApiClient)
 
void statusChanged ()
 
void limitChanged (int newLimit)
 
void autoReloadChanged (bool newAutoReload)
 
void modelShouldClear ()
 Emitted when the model should clear itself.
 
void itemsLoaded ()
 
void reloadWanted ()
 
- Properties inherited from Jellyfin::BaseModelLoader
ApiClientapiClient
 
Jellyfin::ViewModel::ModelStatusClass::Value status
 
int limit
 
bool autoReload
 

Detailed Description

template<class T>
class Jellyfin::ModelLoader< T >

Base model loader that only has one template parameter, so it can be used within the ApiModel.

Constructor & Destructor Documentation

◆ ModelLoader()

template<class T >
Jellyfin::ModelLoader< T >::ModelLoader ( QObject * parent = nullptr)
inline

Member Function Documentation

◆ canLoadMore()

template<class T >
virtual bool Jellyfin::ModelLoader< T >::canLoadMore ( ) const
inlinevirtual

◆ loadMore() [1/2]

template<class T >
void Jellyfin::ModelLoader< T >::loadMore ( )
inline

◆ loadMore() [2/2]

template<class T >
virtual void Jellyfin::ModelLoader< T >::loadMore ( ViewModel::ModelStatus suggestedStatus)
protectedpure virtual

Loads data from the given offset with a maximum count of limit. The itemsLoaded() signal is emitted when new data is ready. Call getLoadedItems to retrieve the loaded items.

Parameters
suggestedStatusThe suggested status this model should take on if it is able to load (more). Either LOADING or LOAD_MORE.

Implemented in Jellyfin::LoaderModelLoader< T, D, R, P >.

◆ reload()

template<class T >
void Jellyfin::ModelLoader< T >::reload ( )
inlineoverridevirtual

Clears and reloads the model.

Reimplemented from Jellyfin::BaseModelLoader.

◆ result()

template<class T >
std::pair< QList< T * >, int > && Jellyfin::ModelLoader< T >::result ( )
inline

Holds the result. Moves it result to the caller and therefore can be only called once when the itemsLoaded is emitted.

Returns
pair containing the items loaded and the integer containing the starting offset. A starting offset of -1 means an error has occurred.

Member Data Documentation

◆ m_result

template<class T >
std::pair<QList<T*>, int> Jellyfin::ModelLoader< T >::m_result
protected

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