LibEngsas
equerythread.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010 - 2012 EngSaS - Engineering Solutions and Services Langenbach. All rights reserved.
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Lesser General Public
6  License as published by the Free Software Foundation; either
7  version 2.1 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Lesser General Public License for more details.
13 
14  You should have received a copy of the GNU Lesser General Public
15  License along with this library; if not, write to the Free Software
16  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17  MA 02110-1301 USA.
18 */
19 
20 #ifndef EQUERYTHREAD_H
21 #define EQUERYTHREAD_H
22 
23 #include "eglobal.h"
24 #include <QThread>
25 
26 class EQueryWorker;
27 
28 #include <QSqlQuery>
29 #include <QSqlRecord>
30 #include <QVariant>
31 
43 class E_CORE_EXPORT EQueryThread : public QThread
44 {
45  Q_OBJECT
46  public:
47  EQueryThread( QObject* parent = 0 );
48  ~EQueryThread();
49 
50  void run();
51  bool isStarted() const;
52  bool waitForStart();
53 
54  public slots:
64  void execQuery(QObject *client, QVariant requestId,
65  QString queryString, QString errorMsg,
66  QList<QVariant> bindValues = QList<QVariant>());
67  void cancelQuery();
68  void dbSetup(QString dbname, QString username, QString password, QString host, QString driver);
69 
70  private slots:
74  void resultByPass(QObject *client, QVariant requestId, int querySize, QSqlRecord record);
75  void setRangeByPass(int min, int max);
76  void setValueByPass(int value);
77  void finishedByPass(QObject* client, QVariant requestId, bool status);
78  void setStarted();
79 
80  private:
88 
89  signals:
93  void configureDB(QString dbname, QString username, QString password, QString host, QString driver);
104  void addToQueue(QObject *client, QVariant requestId, QString queryString, QString errorMsg, QList<QVariant> bindValues);
105  void cancel();
112  void result(QObject *client, QVariant requestId, int querySize, QSqlRecord record);
113  void setRange(int min, int max);
114  void setValue(int value);
121  void finished(QObject *client, QVariant requestId, bool status);
122  void allConnected();
123 };
124 
125 #endif // EQUERYTHREAD_H