QEverCloud  3.0.0
Unofficial Evernote Cloud API for Qt
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Types | Signals | Public Member Functions | List of all members
qevercloud::AsyncResult Class Reference

Returned by asynchonous versions of functions. More...

#include <AsyncResult.h>

Inheritance diagram for qevercloud::AsyncResult:

Public Types

typedef QVariant(* ReadFunctionType )(QByteArray replyData)
 

Signals

void finished (QVariant result, QSharedPointer< EverCloudExceptionData > error)
 Emitted upon asyncronous call completition. More...
 

Public Member Functions

 AsyncResult (QString url, QByteArray postData, ReadFunctionType readFunction=AsyncResult::asIs, bool autoDelete=true, QObject *parent=Q_NULLPTR)
 
 AsyncResult (QNetworkRequest request, QByteArray postData, ReadFunctionType readFunction=AsyncResult::asIs, bool autoDelete=true, QObject *parent=Q_NULLPTR)
 
 ~AsyncResult ()
 
bool waitForFinished (int timeout=-1)
 Wait for asyncronous operation to complete. More...
 

Detailed Description

Returned by asynchonous versions of functions.

Wait for AsyncResult::finished signal.

Intended usage is something like this:

NoteStore* ns;
Note note;
...
QObject::connect(ns->createNoteAsync(note), &AsyncResult::finished, [ns](QVariant result, QSharedPointer<EverCloudExceptionData> error) {
if(!error.isNull()) {
// do something in case of an error
} else {
Note note = result.value<Note>();
// process returned result
}
});

Member Typedef Documentation

typedef QVariant(* qevercloud::AsyncResult::ReadFunctionType)(QByteArray replyData)

Constructor & Destructor Documentation

qevercloud::AsyncResult::AsyncResult ( QString  url,
QByteArray  postData,
ReadFunctionType  readFunction = AsyncResult::asIs,
bool  autoDelete = true,
QObject *  parent = Q_NULLPTR 
)
qevercloud::AsyncResult::AsyncResult ( QNetworkRequest  request,
QByteArray  postData,
ReadFunctionType  readFunction = AsyncResult::asIs,
bool  autoDelete = true,
QObject *  parent = Q_NULLPTR 
)
qevercloud::AsyncResult::~AsyncResult ( )

Member Function Documentation

void qevercloud::AsyncResult::finished ( QVariant  result,
QSharedPointer< EverCloudExceptionData error 
)
signal

Emitted upon asyncronous call completition.

Parameters
result
errorerror.isNull() != true in case of an error. See EverCloudExceptionData for more details.

AsyncResult deletes itself after emitting this signal. You don't have to manage it's lifetime explicitly.

bool qevercloud::AsyncResult::waitForFinished ( int  timeout = -1)

Wait for asyncronous operation to complete.

Parameters
timeoutMaximum time to wait in milliseconds. Forever if < 0.
Returns
true if finished succesfully, flase in case of the timeout