1 #ifndef QTRESTCLIENT_PAGINGMODEL_H
2 #define QTRESTCLIENT_PAGINGMODEL_H
4 #include "QtRestClient/qtrestclient_global.h"
5 #include "QtRestClient/ipaging.h"
6 #include "QtRestClient/restreply.h"
7 #include "QtRestClient/restclass.h"
9 #ifndef Q_RESTCLIENT_NO_JSON_SERIALIZER
10 #include "QtRestClient/paging_fwd.h"
11 #include "QtRestClient/genericrestreply.h"
14 #include <QtCore/qabstractitemmodel.h>
15 #include <QtCore/qscopedpointer.h>
16 #include <QtCore/qpointer.h>
33 class PagingModelPrivate;
40 Q_PROPERTY(
int typeId READ typeId NOTIFY typeIdChanged)
44 static constexpr
int ModelDataRole = Qt::UserRole;
61 #ifndef Q_RESTCLIENT_NO_JSON_SERIALIZER
67 inline void initialize(
const QUrl &initialUrl,
RestClass *restClass);
75 template <
typename DataClassType,
typename ErrorClassType = QObject*>
78 template <
typename DataClassType,
typename ErrorClassType = QObject*>
86 QVariant headerData(
int section, Qt::Orientation orientation = Qt::Horizontal,
int role = Qt::DisplayRole)
const override;
92 bool canFetchMore(
const QModelIndex &parent)
const override;
105 template <
typename T>
114 int addColumn(
const QString &text);
116 int addColumn(
const QString &text,
const char *propertyName);
118 void addRole(
int column,
int role,
const char *propertyName);
124 void fetchError(QPrivateSignal);
127 void typeIdChanged(
int typeId, QPrivateSignal);
152 #ifndef Q_RESTCLIENT_NO_JSON_SERIALIZER
156 initialize(initialUrl, fetcher, qMetaTypeId<T>());
162 initialize(initialUrl, restClass, qMetaTypeId<T>());
177 template<
typename DataClassType,
typename ErrorClassType>
180 initialize(reply, fetcher, qMetaTypeId<DataClassType>());
183 template<
typename DataClassType,
typename ErrorClassType>
186 initialize(reply, restClass, qMetaTypeId<DataClassType>());
190 template <
typename T>
193 Q_ASSERT_X(
typeId() == QMetaType::UnknownType || qMetaTypeId<T>() ==
typeId(), Q_FUNC_INFO,
"object must be used with the stores typeId");
201 #endif // QTRESTCLIENT_PAGINGMODEL_H