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>

+ Inheritance diagram for EQueryThread:
+ 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. More...
 
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). More...
 
void cancel ()
 
void result (QObject *client, QVariant requestId, int querySize, QSqlRecord record)
 Is emitted, if a result for a queued query is fetched. More...
 
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. More...
 
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. More...
 
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::EQueryThread ( QObject *  parent = 0)
+ Here is the call graph for this function:

◆ ~EQueryThread()

EQueryThread::~EQueryThread ( )

Member Function Documentation

◆ addToQueue

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:

◆ allConnected

void EQueryThread::allConnected ( )
signal
+ Here is the caller graph for this function:

◆ cancel

void EQueryThread::cancel ( )
signal
+ Here is the caller graph for this function:

◆ cancelQuery

void EQueryThread::cancelQuery ( )
slot
+ Here is the call graph for this function:

◆ configureDB

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:

◆ dbSetup

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

◆ execQuery

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.

◆ finished

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:

◆ finishedByPass

void EQueryThread::finishedByPass ( QObject *  client,
QVariant  requestId,
bool  status 
)
privateslot
+ Here is the caller graph for this function:

◆ isStarted()

bool EQueryThread::isStarted ( ) const
+ Here is the caller graph for this function:

◆ result

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:

◆ resultByPass

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

Internally used to by pass the fetched results.

+ Here is the caller graph for this function:

◆ run()

void EQueryThread::run ( )
+ Here is the call graph for this function:

◆ setRange

void EQueryThread::setRange ( int  min,
int  max 
)
signal
+ Here is the caller graph for this function:

◆ setRangeByPass

void EQueryThread::setRangeByPass ( int  min,
int  max 
)
privateslot
+ Here is the caller graph for this function:

◆ setStarted

void EQueryThread::setStarted ( )
privateslot
+ Here is the caller graph for this function:

◆ setValue

void EQueryThread::setValue ( int  value)
signal
+ Here is the caller graph for this function:

◆ setValueByPass

void EQueryThread::setValueByPass ( int  value)
privateslot
+ Here is the caller graph for this function:

◆ waitForStart()

bool EQueryThread::waitForStart ( )
+ Here is the call graph for this function:

Member Data Documentation

◆ finishedStartup

bool EQueryThread::finishedStartup
private

◆ worker

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: