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

Abstract model for displaying collections. More...

#include <apimodel.h>

Inheritance diagram for Jellyfin::ApiModel< T >:
Jellyfin::BaseApiModel

Public Member Functions

 ApiModel (QObject *parent=nullptr)
 Creates a new basemodel.
 
int rowCount (const QModelIndex &index) const override
 
QSharedPointer< T > at (int index) const
 
int size () const
 
void insert (int index, QSharedPointer< T > object)
 
void append (QSharedPointer< T > object)
 
void append (QList< QSharedPointer< T > > &objects)
 
QList< T * > mid (int pos, int length=-1)
 
void removeAt (int index)
 
void removeUntilEnd (int from)
 
void removeOne (QSharedPointer< T > object)
 
void clear () override
 
const QList< QSharedPointer< T > > & toList ()
 
virtual bool canFetchMore (const QModelIndex &parent) const override
 
virtual void fetchMore (const QModelIndex &parent) override
 
BaseModelLoaderloader () const override
 
void setLoader (BaseModelLoader *newLoader)
 
void reload () override
 
- Public Member Functions inherited from Jellyfin::BaseApiModel
 BaseApiModel (QObject *parent=nullptr)
 
void disconnectOldLoader (BaseModelLoader *oldLoader)
 

Protected Member Functions

void loadingFinished () override
 

Protected Attributes

QList< QSharedPointer< T > > m_array
 
ModelLoader< T > * m_loader = nullptr
 

Additional Inherited Members

- Public Slots inherited from Jellyfin::BaseApiModel
- Signals inherited from Jellyfin::BaseApiModel
void loaderChanged ()
 
- Protected Slots inherited from Jellyfin::BaseApiModel
- Properties inherited from Jellyfin::BaseApiModel
BaseModelLoaderloader
 

Detailed Description

template<class T>
class Jellyfin::ApiModel< T >

Abstract model for displaying collections.

Template Parameters
TThe class of the result.
RThe class returned by the loader.
PThe class with the request parameters for the loader.

Constructor & Destructor Documentation

◆ ApiModel()

template<class T >
Jellyfin::ApiModel< T >::ApiModel ( QObject * parent = nullptr)
inlineexplicit

Creates a new basemodel.

Parameters
pathThe path (relative to the baseUrl of JellyfinApiClient) to make the call to.
subfieldLeave empty if the root of the result is the array with results. Otherwise, set to the key name in the root object which contains the data.
parentParent (Standard QObject stuff)

If the response looks something like this:

[{...}, {...}, {...}]

or

{...}

responseHasRecords should be false

If the response looks something like this:

{
"Offset": 0,
"Count": 20,
"Items": [{...}, {...}, {...}, ..., {...}]
}

responseHasRecords should be true

Member Function Documentation

◆ append() [1/2]

template<class T >
void Jellyfin::ApiModel< T >::append ( QList< QSharedPointer< T > > & objects)
inline

◆ append() [2/2]

template<class T >
void Jellyfin::ApiModel< T >::append ( QSharedPointer< T > object)
inline

◆ at()

template<class T >
QSharedPointer< T > Jellyfin::ApiModel< T >::at ( int index) const
inline

◆ canFetchMore()

template<class T >
virtual bool Jellyfin::ApiModel< T >::canFetchMore ( const QModelIndex & parent) const
inlineoverridevirtual

◆ clear()

template<class T >
void Jellyfin::ApiModel< T >::clear ( )
inlineoverridevirtual

◆ fetchMore()

template<class T >
virtual void Jellyfin::ApiModel< T >::fetchMore ( const QModelIndex & parent)
inlineoverridevirtual

◆ insert()

template<class T >
void Jellyfin::ApiModel< T >::insert ( int index,
QSharedPointer< T > object )
inline

◆ loader()

template<class T >
BaseModelLoader * Jellyfin::ApiModel< T >::loader ( ) const
inlineoverridevirtual

◆ loadingFinished()

template<class T >
void Jellyfin::ApiModel< T >::loadingFinished ( )
inlineoverrideprotectedvirtual

◆ mid()

template<class T >
QList< T * > Jellyfin::ApiModel< T >::mid ( int pos,
int length = -1 )
inline

◆ reload()

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

◆ removeAt()

template<class T >
void Jellyfin::ApiModel< T >::removeAt ( int index)
inline

◆ removeOne()

template<class T >
void Jellyfin::ApiModel< T >::removeOne ( QSharedPointer< T > object)
inline

◆ removeUntilEnd()

template<class T >
void Jellyfin::ApiModel< T >::removeUntilEnd ( int from)
inline

◆ rowCount()

template<class T >
int Jellyfin::ApiModel< T >::rowCount ( const QModelIndex & index) const
inlineoverride

◆ setLoader()

template<class T >
void Jellyfin::ApiModel< T >::setLoader ( BaseModelLoader * newLoader)
inlinevirtual

Reimplemented from Jellyfin::BaseApiModel.

◆ size()

template<class T >
int Jellyfin::ApiModel< T >::size ( ) const
inline
Returns
the amount of objects in this model.

◆ toList()

template<class T >
const QList< QSharedPointer< T > > & Jellyfin::ApiModel< T >::toList ( )
inline

Member Data Documentation

◆ m_array

template<class T >
QList<QSharedPointer<T> > Jellyfin::ApiModel< T >::m_array
protected

◆ m_loader

template<class T >
ModelLoader<T>* Jellyfin::ApiModel< T >::m_loader = nullptr
protected

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