QtRestClient  3.0.0
A library for generic JSON-based REST-APIs, with a mechanism to map JSON to Qt objects
qmlgenericrestreply.h
1 #ifndef QTRESTCLIENT_QMLGENERICRESTREPLY_H
2 #define QTRESTCLIENT_QMLGENERICRESTREPLY_H
3 
4 #include <QtCore/QObject>
5 
6 #include <QtQml/QJSValue>
7 #include <QtQml/QJSEngine>
8 
9 #include <QtJsonSerializer/SerializerBase>
10 
11 #include <QtRestClient/RestReply>
12 
13 #ifdef DOXYGEN_RUN
15 
24 #else
25 namespace QtRestClient {
26 
27 class QmlGenericRestReply : public QObject
28 #endif
29 {
30  Q_OBJECT
31 
41  Q_PROPERTY(QtRestClient::RestReply *reply MEMBER _reply CONSTANT)
50  Q_PROPERTY(QString returnType READ returnType CONSTANT)
59  Q_PROPERTY(QString errorType READ errorType CONSTANT)
60 
61 public:
63  Q_INVOKABLE QmlGenericRestReply(QtJsonSerializer::SerializerBase *serializer,
64  QJSEngine *engine,
65  int returnType,
66  int errorType,
68 
70  QString returnType() const;
72  QString errorType() const;
73 
74 public Q_SLOTS:
82  void addCompletedHandler(const QJSValue &completedHandler);
91  void addSucceededHandler(const QJSValue &succeededHandler);
100  void addFailedHandler(const QJSValue &failedHandler);
110  void addErrorHandler(const QJSValue &errorHandler);
111 
112 private:
113  QtJsonSerializer::SerializerBase *_serializer;
114  QJSEngine *_engine;
115  int _returnType;
116  int _errorType;
117  RestReply* _reply;
118 
119  bool checkOk(const QJSValue &fn) const;
120 };
121 
122 }
123 
124 Q_DECLARE_METATYPE(QtRestClient::QmlGenericRestReply*)
125 
126 #endif // QTRESTCLIENT_QMLGENERICRESTREPLY_H
de::skycoder42::QtRestClient::GenericRestReply::reply
QtRestClient::RestReply reply
The original QtRestClient::RestReply that this one wrapps.
Definition: qmlgenericrestreply.h:41
QtRestClient
The Namespace containing all classes of the QtRestClient module.
Definition: genericrestreply.h:14
de::skycoder42::QtRestClient::RestReply
The QML version of QtRestClient::RestReply.
Definition: qmlrestreply.h:22
de::skycoder42::QtRestClient::GenericRestReply::addErrorHandler
void addErrorHandler(const QJSValue &errorHandler)
Add a method to be called if an error occured.
de::skycoder42::QtRestClient
The QML import for the QtRestClient QML module.
Definition: qmlgenericrestreply.h:14
de::skycoder42::QtRestClient::GenericRestReply::addFailedHandler
void addFailedHandler(const QJSValue &failedHandler)
Add a method to be called if the request has failed.
QString
de::skycoder42::QtRestClient::GenericRestReply::addSucceededHandler
void addSucceededHandler(const QJSValue &succeededHandler)
Add a method to be called when the request has been completed successfully.
QJSEngine
QJSValue
QObject
de::skycoder42::QtRestClient::GenericRestReply::addCompletedHandler
void addCompletedHandler(const QJSValue &completedHandler)
Add a method to be called when the request has been completed.
de::skycoder42::QtRestClient::GenericRestReply
The QML version of QtRestClient::GenericRestReply.
Definition: qmlgenericrestreply.h:23