OfficeAssistant_Win10/OfficeAssistant_msvc/sqlitehelper.h

70 lines
1.6 KiB
C++

#pragma once
#include <QtSql/QSqlDatabase>
#include <QtSql/QSqlError>
#include <QtSql/QSqlQuery>
#include <QString>
#include <QObject>
#include <QDate>
#include <QtNetwork/QtNetwork>
#include "buttonstruct.h"
struct ConfigResponse;
class ConfigRequest;
struct Record2;
class SoftwareRequest;
typedef struct tagRecord{
int id;
int sort;
QString app_id;
bool locked;
QString type;
QString category_id;
QString logo;
QString name;
QString orig_name;
QString version;
QString dev;
time_t create_time;
time_t use_time;
QString op;
QString func;
QString path;
QString url;
bool status;
}Record;
#include "netio.h"
struct Categrory
{
int id;
int total;
QString name;
bool display;
int sort;
};
class SQLiteHelper : public QObject
{
Q_OBJECT
public:
SQLiteHelper(QObject *parent = nullptr);
bool update_software();
bool insert_software(QString name, QString orig_name, QString path, QString sort, bool* categories);
bool edit_software(QString name, QString orig_name, QString path, QString sort, bool* categories,QString type="");
bool get_software(QList<ButtonStruct>* buttons, ConfigResponse* config_response);
bool update_app();
bool get_buttons(QList<ButtonStruct> &buttons);
bool get_category(QList<Categrory>& categrories, bool is_edit,bool all=false);
bool set_category(QList<Categrory>& categrories);
bool get_all_software(QList<Record> &softwares,int category);
bool get_a_software(QString orig_name, Record2 *record);
QSqlDatabase db;
~SQLiteHelper();
private:
QNetworkReply* reply;
QEventLoop eventLoop;
bool downloadSuccess;
void cancelDownload();
};