QEverCloud  3.0.0
Unofficial Evernote Cloud API for Qt
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
AsyncResult.h
Go to the documentation of this file.
1 
9 #ifndef QEVERCLOUD_ASYNC_RESULT_H
10 #define QEVERCLOUD_ASYNC_RESULT_H
11 
12 #include "qt4helpers.h"
13 #include "export.h"
14 #include "EverCloudException.h"
15 #include <QObject>
16 #include <QNetworkRequest>
17 
18 namespace qevercloud {
19 
20 QT_FORWARD_DECLARE_CLASS(AsyncResultPrivate)
21 
22 
43 class QEVERCLOUD_EXPORT AsyncResult: public QObject
44 {
45  Q_OBJECT
46  Q_DISABLE_COPY(AsyncResult)
47 private:
48  static QVariant asIs(QByteArray replyData);
49 
50 public:
51  typedef QVariant (*ReadFunctionType)(QByteArray replyData);
52 
53  AsyncResult(QString url, QByteArray postData, ReadFunctionType readFunction = AsyncResult::asIs,
54  bool autoDelete = true, QObject * parent = Q_NULLPTR);
55 
56  AsyncResult(QNetworkRequest request, QByteArray postData, ReadFunctionType readFunction = AsyncResult::asIs,
57  bool autoDelete = true, QObject * parent = Q_NULLPTR);
58 
59  ~AsyncResult();
60 
67  bool waitForFinished(int timeout = -1);
68 
69 Q_SIGNALS:
78  void finished(QVariant result, QSharedPointer<EverCloudExceptionData> error);
79 
80 private Q_SLOTS:
81  void onReplyFetched(QObject * rp);
82  void start();
83 
84 private:
85  AsyncResultPrivate * const d_ptr;
86  Q_DECLARE_PRIVATE(AsyncResult)
87 };
88 
89 } // namespace qevercloud
90 
91 #endif // QEVERCLOUD_ASYNC_RESULT_H
#define QEVERCLOUD_EXPORT
Definition: export.h:23
Definition: AsyncResult.h:18
Returned by asynchonous versions of functions.
Definition: AsyncResult.h:43