LibEngsas
Public Slots | Signals | Public Member Functions | Private Slots | Private Attributes | List of all members
EQueryThread Class Reference

Allows to execute SQL-Queries asynchronous.Should be stopped right that: More...

#include <equerythread.h>

+ Collaboration diagram for EQueryThread:

Public Slots

void execQuery (QObject *client, QVariant requestId, QString queryString, QString errorMsg, QList< QVariant > bindValues=QList< QVariant >())
 Adds a query to the queue.
void cancelQuery ()
void dbSetup (QString dbname, QString username, QString password, QString host, QString driver)

Signals

void configureDB (QString dbname, QString username, QString password, QString host, QString driver)
void addToQueue (QObject *client, QVariant requestId, QString queryString, QString errorMsg, QList< QVariant > bindValues)
 Adds a new query to the queue of the query worker (Internally used).
void cancel ()
void result (QObject *client, QVariant requestId, int querySize, QSqlRecord record)
 Is emitted, if a result for a queued query is fetched.
void setRange (int min, int max)
void setValue (int value)
void finished (QObject *client, QVariant requestId, bool status)
 Emitted to indicate the result status of a query.
void allConnected ()

Public Member Functions

 EQueryThread (QObject *parent=0)
 ~EQueryThread ()
void run ()
bool isStarted () const
bool waitForStart ()

Private Slots

void resultByPass (QObject *client, QVariant requestId, int querySize, QSqlRecord record)
 Internally used to by pass the fetched results.
void setRangeByPass (int min, int max)
void setValueByPass (int value)
void finishedByPass (QObject *client, QVariant requestId, bool status)
void setStarted ()

Private Attributes

EQueryWorkerworker
bool finishedStartup

Detailed Description

Allows to execute SQL-Queries asynchronous.

Should be stopped right that:

EQueryThread.cancelQuery(); // to stop running query
thread.quit(); // to stop eventloop
thread.wait(1000); // to give the thread max 1s to be stopped

Constructor & Destructor Documentation

EQueryThread::EQueryThread ( QObject *  parent = 0)

+ Here is the call graph for this function:

EQueryThread::~EQueryThread ( )

Member Function Documentation

void EQueryThread::addToQueue ( QObject *  client,
QVariant  requestId,
QString  queryString,
QString  errorMsg,
QList< QVariant >  bindValues 
)
signal

Adds a new query to the queue of the query worker (Internally used).

Note
This signal is only used to communicate with the QueryWorker.

The query itself is stored in queryString. To use placeholders, add them in bindValues. To allow the processing of the results at the connected objects correctly, the requestId is appended unchanged to emitted result() signal for this query. To display an error message if the query failed, set the errorMsg to a meaningful message.

+ Here is the caller graph for this function:

void EQueryThread::allConnected ( )
signal

+ Here is the caller graph for this function:

void EQueryThread::cancel ( )
signal

+ Here is the caller graph for this function:

void EQueryThread::cancelQuery ( )
slot

+ Here is the call graph for this function:

void EQueryThread::configureDB ( QString  dbname,
QString  username,
QString  password,
QString  host,
QString  driver 
)
signal

used to configure database at QueryWorker

+ Here is the caller graph for this function:

void EQueryThread::dbSetup ( QString  dbname,
QString  username,
QString  password,
QString  host,
QString  driver 
)
slot

+ Here is the call graph for this function:

void EQueryThread::execQuery ( QObject *  client,
QVariant  requestId,
QString  queryString,
QString  errorMsg,
QList< QVariant >  bindValues = QList<QVariant>() 
)
slot

Adds a query to the queue.

Prepares an QSqlQuery with query queryString. Afterwards it binds all values from bindValues. This values must be ordered (Placeholder ? not :fieldName). To allow the identification of the result by the client, use requestId. The related emit of the result() signal, contains the unchagend requestId and also the pointer to client. To display an error message if the query failed, set the errorMsg to a meaningful message.

+ Here is the call graph for this function:

void EQueryThread::finished ( QObject *  client,
QVariant  requestId,
bool  status 
)
signal

Emitted to indicate the result status of a query.

To identify the query, the client and requestId is also given.

+ Here is the caller graph for this function:

void EQueryThread::finishedByPass ( QObject *  client,
QVariant  requestId,
bool  status 
)
privateslot

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool EQueryThread::isStarted ( ) const

+ Here is the caller graph for this function:

void EQueryThread::result ( QObject *  client,
QVariant  requestId,
int  querySize,
QSqlRecord  record 
)
signal

Is emitted, if a result for a queued query is fetched.

The client and requestId are unchanged and should be used by the caller to identify it's queries.

+ Here is the caller graph for this function:

void EQueryThread::resultByPass ( QObject *  client,
QVariant  requestId,
int  querySize,
QSqlRecord  record 
)
privateslot

Internally used to by pass the fetched results.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void EQueryThread::run ( )

+ Here is the call graph for this function:

void EQueryThread::setRange ( int  min,
int  max 
)
signal

+ Here is the caller graph for this function:

void EQueryThread::setRangeByPass ( int  min,
int  max 
)
privateslot

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void EQueryThread::setStarted ( )
privateslot

+ Here is the caller graph for this function:

void EQueryThread::setValue ( int  value)
signal

+ Here is the caller graph for this function:

void EQueryThread::setValueByPass ( int  value)
privateslot

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool EQueryThread::waitForStart ( )

+ Here is the call graph for this function:

Member Data Documentation

bool EQueryThread::finishedStartup
private
EQueryWorker* EQueryThread::worker
private

this object run's completely at the other thread therefore the communication is done through the event loop with help of signals and slots


The documentation for this class was generated from the following files: