Line data Source code
1 : #ifndef DBOPERATION_H
2 : #define DBOPERATION_H
3 :
4 : #include <QSqlDatabase>
5 : #include <QSqlQuery>
6 : #include <QSqlError>
7 :
8 : #include "SyncOperation.h"
9 :
10 : /*!
11 : \brief A synchronous operation with database access.
12 : Subclass this for operations that need to run DB queries synchronously.
13 : */
14 : class DBOperation : public SyncOperation
15 : {
16 : Q_OBJECT
17 : public:
18 : explicit DBOperation(OperationManager* parent);
19 20 : virtual ~DBOperation() = default;
20 :
21 : public slots:
22 : QSqlDatabase db();
23 :
24 : protected:
25 :
26 : /*!
27 : \brief Call this to report a SQL error. Logs the error and sets the error flag.
28 : \param query
29 : \param errorString The text that will be logged along with the error.
30 : */
31 : void reportSQLError(const QSqlQuery& query, const QString& errorString);
32 : };
33 :
34 : #endif // DBOPERATION_H
|