1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- #ifndef SQLITEWRAPPER_H
- #define SQLITEWRAPPER_H
- #include "sqldef.h"
- #include <QObject>
- #include <QSqlError>
- #include <QStandardItemModel>
- #include <QtDebug>
- #include <QtSql/QSqlDatabase>
- #include <QtSql/QSqlQuery>
- #include <QtSql/QSqlRecord>
- class SqliteWrapper : public QObject {
- Q_OBJECT
- public:
- explicit SqliteWrapper(QObject* parent = nullptr);
- SqliteWrapper(QString fileName, QString dbName);
-
- void setFileName(QString fileName);
- void setDbName(QString dbName);
- void open();
- void close();
- bool isOpened();
-
- void select(QString sql, QStandardItemModel* model);
- void select(QString sql, QSqlQuery& qry);
- void selectToTreeView(QString sql, int pid, QStandardItemModel* model);
- void loadItemData(int pid, QStandardItemModel* model, QStandardItem* parentItem, QList<TreeviewData>& items);
-
- int findId(QString tableName, QString fieldName, QString fieldValue);
- bool execute(QString sql);
- void truncateTables(QStringList& tables);
- QSqlDatabase& getDataBase();
- int getMaxId(QString tableName);
- void prepare(QString sql, QSqlQuery& qry);
- private:
- QString fileName;
- QString dbName;
- QSqlDatabase database;
- bool opened;
- signals:
- public slots:
- };
- #endif
|