QtRestClient  3.0.0
A library for generic JSON-based REST-APIs, with a mechanism to map JSON to Qt objects
Signals | Public Member Functions | Static Public Attributes | Properties | List of all members
QtRestClient::PagingModel Class Reference

A Qt item model that fills itself from a Paging object obtained via the network. More...

#include <pagingmodel.h>

+ Inheritance diagram for QtRestClient::PagingModel:

Signals

void fetchError (QPrivateSignal)
 Gets emitted if the model fails to obtain data via the network.
 
void typeIdChanged (int typeId, QPrivateSignal)
 NOTIFY accessor for PagingModel::typeId.
 

Public Member Functions

 PagingModel (QObject *parent=nullptr)
 Default constructor.
 
Q_INVOKABLE void initialize (const QUrl &initialUrl, QtRestClient::IPagingModelFetcher *fetcher, int typeId=QMetaType::UnknownType)
 Initialize the model using a type, a initial URL and a fetcher to use to send requests. More...
 
Q_INVOKABLE void initialize (const QUrl &initialUrl, QtRestClient::RestClass *restClass, int typeId=QMetaType::UnknownType)
 Initialize the model using a type, a initial URL and a fetcher to use to send requests. More...
 
Q_INVOKABLE void initialize (QtRestClient::RestReply *reply, QtRestClient::IPagingModelFetcher *fetcher, int typeId=QMetaType::UnknownType)
 Initialize the model from a paging object and a fetcher to use to send requests. More...
 
Q_INVOKABLE void initialize (QtRestClient::RestReply *reply, QtRestClient::RestClass *restClass, int typeId=QMetaType::UnknownType)
 Initialize the model from a paging object and a fetcher to use to send requests. More...
 
Q_INVOKABLE void initialize (QtRestClient::IPaging *paging, QtRestClient::IPagingModelFetcher *fetcher, int typeId=QMetaType::UnknownType)
 Initialize the model from a rest reply and a fetcher to use to send requests. More...
 
Q_INVOKABLE void initialize (QtRestClient::IPaging *paging, QtRestClient::RestClass *restClass, int typeId=QMetaType::UnknownType)
 Initialize the model from a rest reply and a fetcher to use to send requests. More...
 
template<typename T >
void initialize (const QUrl &initialUrl, IPagingModelFetcher *fetcher)
 Initialize the model using a type, a initial URL and a fetcher to use to send requests. More...
 
template<typename T >
void initialize (const QUrl &initialUrl, RestClass *restClass)
 Initialize the model using a type, a initial URL and a fetcher to use to send requests. More...
 
template<typename T >
void initialize (const Paging< T > &paging, IPagingModelFetcher *fetcher)
 Initialize the model from a paging object and a fetcher to use to send requests. More...
 
template<typename T >
void initialize (const Paging< T > &paging, RestClass *restClass)
 Initialize the model from a paging object and a fetcher to use to send requests. More...
 
template<typename DataClassType , typename ErrorClassType = QObject*>
void initialize (GenericRestReply< Paging< DataClassType >, ErrorClassType > *reply, IPagingModelFetcher *fetcher)
 Initialize the model from a rest reply and a fetcher to use to send requests. More...
 
template<typename DataClassType , typename ErrorClassType = QObject*>
void initialize (GenericRestReply< Paging< DataClassType >, ErrorClassType > *reply, RestClass *restClass)
 Initialize the model from a rest reply and a fetcher to use to send requests. More...
 
int typeId () const
 READ accessor for PagingModel::typeId.
 
QVariant headerData (int section, Qt::Orientation orientation=Qt::Horizontal, int role=Qt::DisplayRole) const override
 Inherits QAbstractTableModel::headerData.
 
int rowCount (const QModelIndex &parent=QModelIndex()) const override
 Inherits QAbstractTableModel::rowCount.
 
int columnCount (const QModelIndex &parent=QModelIndex()) const override
 Inherits QAbstractTableModel::columnCount.
 
bool canFetchMore (const QModelIndex &parent) const override
 Inherits QAbstractTableModel::canFetchMore.
 
void fetchMore (const QModelIndex &parent) override
 Inherits QAbstractTableModel::fetchMore.
 
QVariant data (const QModelIndex &index, int role=Qt::DisplayRole) const override
 Inherits QAbstractTableModel::data.
 
Q_INVOKABLE QVariant object (const QModelIndex &index) const
 Returns the object at the given index.
 
template<typename T >
object (const QModelIndex &index) const
 Returns the object at the given index. More...
 
Qt::ItemFlags flags (const QModelIndex &index) const override
 Inherits QAbstractTableModel::flags.
 
QHash< int, QByteArrayroleNames () const override
 Inherits QAbstractTableModel::roleNames.
 
int addColumn (const QString &text)
 Add a new column with the given title. More...
 
int addColumn (const QString &text, const char *propertyName)
 Add a new column and set the given property as its Qt::DisplayRole. More...
 
void addRole (int column, int role, const char *propertyName)
 Adds the given property as a new role to the given column. More...
 
void clearColumns ()
 Removes all customly added columns and roles.
 
- Public Member Functions inherited from QAbstractTableModel
 QAbstractTableModel (QObject *parent)
 
virtual QModelIndex index (int row, int column, const QModelIndex &parent) const const override
 
virtual QModelIndex sibling (int row, int column, const QModelIndex &idx) const const override
 
virtual bool dropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) override
 
- Public Member Functions inherited from QAbstractItemModel
 QAbstractItemModel (QObject *parent)
 
bool hasIndex (int row, int column, const QModelIndex &parent) const const
 
virtual QModelIndex parent (const QModelIndex &index) const const=0
 
virtual bool hasChildren (const QModelIndex &parent) const const
 
virtual bool setData (const QModelIndex &index, const QVariant &value, int role)
 
virtual bool setHeaderData (int section, Qt::Orientation orientation, const QVariant &value, int role)
 
virtual QMap< int, QVariantitemData (const QModelIndex &index) const const
 
virtual bool setItemData (const QModelIndex &index, const QMap< int, QVariant > &roles)
 
virtual QStringList mimeTypes () const const
 
virtual QMimeDatamimeData (const QModelIndexList &indexes) const const
 
virtual bool canDropMimeData (const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) const const
 
virtual Qt::DropActions supportedDropActions () const const
 
virtual Qt::DropActions supportedDragActions () const const
 
void setSupportedDragActions (Qt::DropActions actions)
 
virtual bool insertRows (int row, int count, const QModelIndex &parent)
 
virtual bool insertColumns (int column, int count, const QModelIndex &parent)
 
virtual bool removeRows (int row, int count, const QModelIndex &parent)
 
virtual bool removeColumns (int column, int count, const QModelIndex &parent)
 
virtual bool moveRows (const QModelIndex &sourceParent, int sourceRow, int count, const QModelIndex &destinationParent, int destinationChild)
 
virtual bool moveColumns (const QModelIndex &sourceParent, int sourceColumn, int count, const QModelIndex &destinationParent, int destinationChild)
 
bool insertRow (int row, const QModelIndex &parent)
 
bool insertColumn (int column, const QModelIndex &parent)
 
bool removeRow (int row, const QModelIndex &parent)
 
bool removeColumn (int column, const QModelIndex &parent)
 
bool moveRow (const QModelIndex &sourceParent, int sourceRow, const QModelIndex &destinationParent, int destinationChild)
 
bool moveColumn (const QModelIndex &sourceParent, int sourceColumn, const QModelIndex &destinationParent, int destinationChild)
 
virtual void sort (int column, Qt::SortOrder order)
 
virtual QModelIndex buddy (const QModelIndex &index) const const
 
virtual QModelIndexList match (const QModelIndex &start, int role, const QVariant &value, int hits, Qt::MatchFlags flags) const const
 
virtual QSize span (const QModelIndex &index) const const
 
bool checkIndex (const QModelIndex &index, QAbstractItemModel::CheckIndexOptions options) const const
 
void dataChanged (const QModelIndex &topLeft, const QModelIndex &bottomRight, const QVector< int > &roles)
 
void headerDataChanged (Qt::Orientation orientation, int first, int last)
 
void layoutChanged (const QList< QPersistentModelIndex > &parents, QAbstractItemModel::LayoutChangeHint hint)
 
void layoutAboutToBeChanged (const QList< QPersistentModelIndex > &parents, QAbstractItemModel::LayoutChangeHint hint)
 
void rowsAboutToBeInserted (const QModelIndex &parent, int start, int end)
 
void rowsInserted (const QModelIndex &parent, int first, int last)
 
void rowsAboutToBeRemoved (const QModelIndex &parent, int first, int last)
 
void rowsRemoved (const QModelIndex &parent, int first, int last)
 
void columnsAboutToBeInserted (const QModelIndex &parent, int first, int last)
 
void columnsInserted (const QModelIndex &parent, int first, int last)
 
void columnsAboutToBeRemoved (const QModelIndex &parent, int first, int last)
 
void columnsRemoved (const QModelIndex &parent, int first, int last)
 
void modelAboutToBeReset ()
 
void modelReset ()
 
void rowsAboutToBeMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationRow)
 
void rowsMoved (const QModelIndex &parent, int start, int end, const QModelIndex &destination, int row)
 
void columnsAboutToBeMoved (const QModelIndex &sourceParent, int sourceStart, int sourceEnd, const QModelIndex &destinationParent, int destinationColumn)
 
void columnsMoved (const QModelIndex &parent, int start, int end, const QModelIndex &destination, int column)
 
virtual bool submit ()
 
virtual void revert ()
 
- Public Member Functions inherited from QObject
virtual const QMetaObjectmetaObject () const const
 
 QObject (QObject *parent)
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
QString objectName () const const
 
void setObjectName (const QString &name)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
bool signalsBlocked () const const
 
bool blockSignals (bool block)
 
QThreadthread () const const
 
void moveToThread (QThread *targetThread)
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
void killTimer (int id)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
const QObjectListchildren () const const
 
void setParent (QObject *parent)
 
void installEventFilter (QObject *filterObj)
 
void removeEventFilter (QObject *obj)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectTree ()
 
void dumpObjectInfo ()
 
void dumpObjectTree () const const
 
void dumpObjectInfo () const const
 
bool setProperty (const char *name, const QVariant &value)
 
QVariant property (const char *name) const const
 
QList< QByteArraydynamicPropertyNames () const const
 
void destroyed (QObject *obj)
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
bool inherits (const char *className) const const
 
void deleteLater ()
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
qobject_cast (QObject *object)
 
qobject_cast (const QObject *object)
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
 Q_CLASSINFO (Name, Value)
 
 Q_INTERFACES (...)
 
 Q_PROPERTY (...)
 
 Q_ENUMS (...)
 
 Q_FLAGS (...)
 
 Q_ENUM (...)
 
 Q_FLAG (...)
 
 Q_ENUM_NS (...)
 
 Q_FLAG_NS (...)
 
 Q_OBJECT Q_OBJECT
 
 Q_GADGET Q_GADGET
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SLOTS Q_SLOTS
 
 Q_SLOT Q_SLOT
 
 Q_EMIT Q_EMIT
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 

Static Public Attributes

static constexpr int ModelDataRole = Qt::UserRole
 The Qt item role of the full REST-Object as was used to populate the model.
 

Properties

int typeId
 Holds the type the model fetches data for. More...
 
- Properties inherited from QObject
 objectName
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
- Public Attributes inherited from QAbstractItemModel
typedef CheckIndexOptions
 
- Public Attributes inherited from QObject
typedef QObjectList
 
- Protected Member Functions inherited from QAbstractItemModel
void resetInternalData ()
 
QModelIndex createIndex (int row, int column, void *ptr) const const
 
QModelIndex createIndex (int row, int column, quintptr id) const const
 
void beginInsertRows (const QModelIndex &parent, int first, int last)
 
void endInsertRows ()
 
void beginRemoveRows (const QModelIndex &parent, int first, int last)
 
void endRemoveRows ()
 
bool beginMoveRows (const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationChild)
 
void endMoveRows ()
 
void beginInsertColumns (const QModelIndex &parent, int first, int last)
 
void endInsertColumns ()
 
void beginRemoveColumns (const QModelIndex &parent, int first, int last)
 
void endRemoveColumns ()
 
bool beginMoveColumns (const QModelIndex &sourceParent, int sourceFirst, int sourceLast, const QModelIndex &destinationParent, int destinationChild)
 
void endMoveColumns ()
 
void reset ()
 
void beginResetModel ()
 
void endResetModel ()
 
void changePersistentIndex (const QModelIndex &from, const QModelIndex &to)
 
void changePersistentIndexList (const QModelIndexList &from, const QModelIndexList &to)
 
QModelIndexList persistentIndexList () const const
 
void setRoleNames (const QHash< int, QByteArray > &roleNames)
 
- Protected Member Functions inherited from QObject
QObjectsender () const const
 
int senderSignalIndex () const const
 
int receivers (const char *signal) const const
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
virtual void timerEvent (QTimerEvent *event)
 
virtual void childEvent (QChildEvent *event)
 
virtual void customEvent (QEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 

Detailed Description

A Qt item model that fills itself from a Paging object obtained via the network.

This class can be used to provide a generic item model that uses a paging REST-API to fetch the data to be displayed to the user.

To use the model, you have to initialize() it once with a URL, a Paging object or a rest reply that returns a paging object. This works for both, the generic and non generic (CBOR/JSON) replies. The model uses the prpperties of the object that is managed by the paging object to generate roles that can be used in the UI.

The be able to acually fetch the data from a remote HTTP-server, the model needs a so called "fetcher", i.e. an instance of a QtRestClient::IPagingModelFetcher. Internally, this interface is used to create HTTP-requests and fetch more data for the model.

A default implementation for such a fetcher is available as the QtRestClient::RestClassFetcher. It uses a QtRestClient::RestClass to send GET-requests.

Example

Assuming your data class looks like this:

class Person
{
Q_PROPERTY(QString name MEMBER name)
Q_PROPERTY(int age MEMBER age)
//...
};

You can instanciate a model for this data as follows:

auto model = new QtRestClient::PagingModel(this);
model->initialize<Person>("https://api.example.org/pagings?offset=0&limit=10", rClass);

Alternatively, you can pass a Paging<Person> or a GenericRestReply<Paging<Person>> as first parameter and initialize the model from that data. In this example, the standard RestClassFetcher was used, which can be created automatically by passing the RestClass directly as second parameter.

One additional feature of the model is, that it can also serve as model for table/tree views by delegating properties to multiple columns. This way you can use the model from QML by using the property names, and from widgets by delegating the properties to extra columns. For the above sample, the following code will result in a model with 2 columns, presenting the name and age properties as the Qt::DisplayRole of each column:

// setup first
auto model = new QtRestClient::PagingModel(this);
model->initialize<Person>(...);
// add the column config:
auto col0 = model->addColumn("Name");
model->addRole(col0, Qt::DisplayRole, "name");
// or as shortcut for the above:
model->addColumn("Age", "age");
See also
QtRestClient::IPagingModelFetcher, QtRestClient::RestClassFetcher, QtRestClient::RestClass, QtRestClient::IPaging, QtRestClient::Paging, QtRestClient::RestReply, QtRestClient::GenericRestReply, PagingModel::initialize

Definition at line 35 of file pagingmodel.h.

Member Function Documentation

◆ addColumn() [1/2]

QVariant QtRestClient::PagingModel::addColumn ( const QString text)

Add a new column with the given title.

Parameters
textThe display name of the column header
Returns
The index of the newly created column

The method add a column to the model that can be used to present propeties from the underlying data as specific roles.

Attention
If no custom columns have been added yet, the model with have a single column with the typeId class name as title. By calling this method the first time, this default column will be replaced by whatever column you specify. All subsequent columns are simply added as new columns.
See also
PagingModel::typeId, PagingModel::addRole, PagingModel::clearColumns

◆ addColumn() [2/2]

QVariant QtRestClient::PagingModel::addColumn ( const QString text,
const char *  propertyName 
)

Add a new column and set the given property as its Qt::DisplayRole.

Parameters
textThe display name of the column header
propertyNameThe name of the property to presented as the display role of that column
Returns
The index of the newly created column

This method is basically a shortcut for:

auto column = model->addColumn(text);
model->addRole(column, Qt::DisplayRole, propertyName);
See also
PagingModel::typeId, PagingModel::addRole, PagingModel::clearColumns

◆ addRole()

QVariant QtRestClient::PagingModel::addRole ( int  column,
int  role,
const char *  propertyName 
)

Adds the given property as a new role to the given column.

Parameters
columnThe existing column to add the role to
roleThe role that should be added to the column
propertyNameThe name of the property to presented as the give role of that column

This method adds a new role to an existing column. The new role will simply the the value of the given property of the object in each row. It's basically a delegate to the properties role.

See also
PagingModel::typeId, PagingModel::addColumn, PagingModel::clearColumns

◆ initialize() [1/12]

template<typename T >
QtRestClient::PagingModel::initialize ( const Paging< T > &  paging,
IPagingModelFetcher fetcher 
)
inline

Initialize the model from a paging object and a fetcher to use to send requests.

Template Parameters
TThe type of data to be presented by the model
Parameters
pagingThe paging object to initialize the model from
fetcherThe IPagingModelFetcher to use to fetch the paging data from the remote server

The model will first clear itself and then fill itself from the data that the paging provides. After that, the information returned by the paging of the reply is used to continue to fill the model.

See also
PagingModel::typeId, QtRestClient::Paging

Definition at line 166 of file pagingmodel.h.

◆ initialize() [2/12]

template<typename T >
QtRestClient::PagingModel::initialize ( const Paging< T > &  paging,
RestClass restClass 
)
inline

Initialize the model from a paging object and a fetcher to use to send requests.

Template Parameters
TThe type of data to be presented by the model
Parameters
pagingThe paging object to initialize the model from
restClassThe RestClass to use to fetch the paging data from the remote server

The model will first clear itself and then fill itself from the data that the paging provides. After that, the information returned by the paging of the reply is used to continue to fill the model.

See also
PagingModel::typeId, QtRestClient::Paging

Definition at line 172 of file pagingmodel.h.

◆ initialize() [3/12]

template<typename T >
QtRestClient::PagingModel::initialize ( const QUrl initialUrl,
IPagingModelFetcher fetcher 
)
inline

Initialize the model using a type, a initial URL and a fetcher to use to send requests.

Template Parameters
TThe type of data to be presented by the model
Parameters
initialUrlThe URL to use to fetch the first paging object of the model
fetcherThe IPagingModelFetcher to use to fetch the paging data from the remote server

The model will first clear itself and then send the initialUrl as request using the fetcher to populate the model. After that, the information returned by the paging of the reply is used to continue to fill the model.

See also
PagingModel::typeId

Definition at line 154 of file pagingmodel.h.

◆ initialize() [4/12]

QtRestClient::PagingModel::initialize ( const QUrl initialUrl,
QtRestClient::IPagingModelFetcher fetcher,
int  typeId = QMetaType::UnknownType 
)

Initialize the model using a type, a initial URL and a fetcher to use to send requests.

Parameters
initialUrlThe URL to use to fetch the first paging object of the model
fetcherThe IPagingModelFetcher to use to fetch the paging data from the remote server
typeIdThe type of data to be presented by the model

The model will first clear itself and then send the initialUrl as request using the fetcher to populate the model. After that, the information returned by the paging of the reply is used to continue to fill the model.

See also
PagingModel::typeId

◆ initialize() [5/12]

QtRestClient::PagingModel::initialize ( const QUrl initialUrl,
QtRestClient::RestClass restClass,
int  typeId = QMetaType::UnknownType 
)

Initialize the model using a type, a initial URL and a fetcher to use to send requests.

Parameters
initialUrlThe URL to use to fetch the first paging object of the model
restClassThe RestClass to use to fetch the paging data from the remote server
typeIdThe type of data to be presented by the model

The model will first clear itself and then send the initialUrl as request using the fetcher to populate the model. After that, the information returned by the paging of the reply is used to continue to fill the model.

See also
PagingModel::typeId

◆ initialize() [6/12]

template<typename T >
QtRestClient::PagingModel::initialize ( const QUrl initialUrl,
RestClass restClass 
)
inline

Initialize the model using a type, a initial URL and a fetcher to use to send requests.

Template Parameters
TThe type of data to be presented by the model
Parameters
initialUrlThe URL to use to fetch the first paging object of the model
restClassThe RestClass to use to fetch the paging data from the remote server

The model will first clear itself and then send the initialUrl as request using the fetcher to populate the model. After that, the information returned by the paging of the reply is used to continue to fill the model.

See also
PagingModel::typeId

Definition at line 160 of file pagingmodel.h.

◆ initialize() [7/12]

template<typename DataClassType , typename ErrorClassType >
QtRestClient::PagingModel::initialize ( GenericRestReply< Paging< DataClassType >, ErrorClassType > *  reply,
IPagingModelFetcher fetcher 
)
inline

Initialize the model from a rest reply and a fetcher to use to send requests.

Template Parameters
DataClassTypeThe type of data to be presented by the model
ErrorClassTypeThe ErrorClassType as needed by the GenericRestReply
Parameters
replyA rest reply returning a paging object to intialize the model from
fetcherThe IPagingModelFetcher to use to fetch the paging data from the remote server

The model will first clear itself and then wait (asynchronously) for the reply to finish. Once that happend, it will fill itself with the data from that reply. After that, the information returned by the paging of the reply is used to continue to fill the model.

See also
PagingModel::typeId, QtRestClient::GenericRestReply

Definition at line 178 of file pagingmodel.h.

◆ initialize() [8/12]

template<typename DataClassType , typename ErrorClassType >
QtRestClient::PagingModel::initialize ( GenericRestReply< Paging< DataClassType >, ErrorClassType > *  reply,
RestClass restClass 
)
inline

Initialize the model from a rest reply and a fetcher to use to send requests.

Template Parameters
DataClassTypeThe type of data to be presented by the model
ErrorClassTypeThe ErrorClassType as needed by the GenericRestReply
Parameters
replyA rest reply returning a paging object to intialize the model from
restClassThe RestClass to use to fetch the paging data from the remote server

The model will first clear itself and then wait (asynchronously) for the reply to finish. Once that happend, it will fill itself with the data from that reply. After that, the information returned by the paging of the reply is used to continue to fill the model.

See also
PagingModel::typeId, QtRestClient::GenericRestReply

Definition at line 184 of file pagingmodel.h.

◆ initialize() [9/12]

QtRestClient::PagingModel::initialize ( QtRestClient::IPaging paging,
QtRestClient::IPagingModelFetcher fetcher,
int  typeId = QMetaType::UnknownType 
)

Initialize the model from a rest reply and a fetcher to use to send requests.

Parameters
pagingThe paging object to initialize the model from
fetcherThe IPagingModelFetcher to use to fetch the paging data from the remote server
typeIdThe type of data to be presented by the model

The model will first clear itself and then fill itself from the data that the paging provides. After that, the information returned by the paging of the reply is used to continue to fill the model.

See also
PagingModel::typeId, QtRestClient::IPaging

◆ initialize() [10/12]

QtRestClient::PagingModel::initialize ( QtRestClient::IPaging paging,
QtRestClient::RestClass restClass,
int  typeId = QMetaType::UnknownType 
)

Initialize the model from a rest reply and a fetcher to use to send requests.

Parameters
pagingThe paging object to initialize the model from
restClassThe RestClass to use to fetch the paging data from the remote server
typeIdThe type of data to be presented by the model

The model will first clear itself and then fill itself from the data that the paging provides. After that, the information returned by the paging of the reply is used to continue to fill the model.

See also
PagingModel::typeId, QtRestClient::IPaging

◆ initialize() [11/12]

QtRestClient::PagingModel::initialize ( QtRestClient::RestReply reply,
QtRestClient::IPagingModelFetcher fetcher,
int  typeId = QMetaType::UnknownType 
)

Initialize the model from a paging object and a fetcher to use to send requests.

Parameters
replyA rest reply returning a paging object to intialize the model from
fetcherThe IPagingModelFetcher to use to fetch the paging data from the remote server
typeIdThe type of data to be presented by the model

The model will first clear itself and then wait (asynchronously) for the reply to finish. Once that happend, it will fill itself with the data from that reply. After that, the information returned by the paging of the reply is used to continue to fill the model.

See also
PagingModel::typeId, QtRestClient::RestReply

◆ initialize() [12/12]

QtRestClient::PagingModel::initialize ( QtRestClient::RestReply reply,
QtRestClient::RestClass restClass,
int  typeId = QMetaType::UnknownType 
)

Initialize the model from a paging object and a fetcher to use to send requests.

Parameters
replyA rest reply returning a paging object to intialize the model from
restClassThe RestClass to use to fetch the paging data from the remote server
typeIdThe type of data to be presented by the model

The model will first clear itself and then wait (asynchronously) for the reply to finish. Once that happend, it will fill itself with the data from that reply. After that, the information returned by the paging of the reply is used to continue to fill the model.

See also
PagingModel::typeId, QtRestClient::RestReply

◆ object()

template<typename T >
T QtRestClient::PagingModel::object ( const QModelIndex index) const
inline

Returns the object at the given index.

Template Parameters
TThe type of object to return. Must match PagingModel::typeId

Definition at line 191 of file pagingmodel.h.

Property Documentation

◆ typeId

QtRestClient::PagingModel::typeId
read

Holds the type the model fetches data for.

Default: QMetaType::UnknownType

This type can only be changed be (re)initializing the model using one of the initialize() methods. After that was done, it can be used to retrieve the type id of the data that is beeing presented by the model.

Accessors
READtypeId()
NOTIFYtypeIdChanged()
See also
PagingModel::initialize

Definition at line 40 of file pagingmodel.h.


The documentation for this class was generated from the following files:
QObject::Q_PROPERTY
Q_PROPERTY(...)
QtRestClient::RestClass
A class to perform requests to an API.
Definition: restclass.h:19
QString
QObject::Q_GADGET
Q_GADGETQ_GADGET
QtRestClient::PagingModel
A Qt item model that fills itself from a Paging object obtained via the network.
Definition: pagingmodel.h:35