OfficeAssistant_Win10/OfficeAssistant_msvc/sqlitehelper.h

80 lines
2.2 KiB
C
Raw Normal View History

2023-08-18 19:09:55 +08:00
#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;
2023-08-15 20:12:36 +08:00
struct Record2;
class SoftwareRequest;
typedef struct tagRecord{
int id;
int sort;
2023-08-18 19:09:55 +08:00
QString initial_position;
QString app_id;
bool locked;
2023-08-18 19:09:55 +08:00
bool is_navbar;
bool is_elite;
QString type;
QString category_id;
QString logo;
2023-08-18 19:09:55 +08:00
QString img;
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"
2023-08-13 12:16:22 +08:00
struct Categrory
{
int id;
2023-08-15 20:12:36 +08:00
int total;
2023-08-13 12:16:22 +08:00
QString name;
bool display;
int sort;
};
class SQLiteHelper : public QObject
{
Q_OBJECT
public:
SQLiteHelper(QObject *parent = nullptr);
bool update_software();
2023-08-18 19:09:55 +08:00
bool insert_software(QString name, QString orig_name, QString path, QString sort, bool* categories, QString logo="", QString img="",QString type="app",bool locked=false,QString op="soft",QString func="",QString url="",bool is_navbar=false,bool is_elite=false,QString dev="");
2023-08-13 12:16:22 +08:00
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);
2023-08-18 19:09:55 +08:00
bool get_software(QList<ButtonStruct>* button_structs,QString background_color , QString title_color, QString title_cover_color);
bool update_app();
2023-08-13 12:16:22 +08:00
bool get_buttons(QList<ButtonStruct> &buttons);
2023-08-15 20:12:36 +08:00
bool get_category(QList<Categrory>& categrories, bool is_edit,bool all=false);
2023-08-13 12:16:22 +08:00
bool set_category(QList<Categrory>& categrories);
bool get_all_software(QList<Record> &softwares,int category);
2023-08-15 20:12:36 +08:00
bool get_a_software(QString orig_name, Record2 *record);
2023-08-18 19:09:55 +08:00
bool update_total();//警告:这个函数必须用于事务中
bool use_software(QString orig_name);
2023-08-13 12:16:22 +08:00
QSqlDatabase db;
~SQLiteHelper();
private:
QNetworkReply* reply;
QEventLoop eventLoop;
bool downloadSuccess;
2023-08-18 19:09:55 +08:00
bool delete_software(QString orig_name);
bool execute_query(QString sql, QList<Record>& softwares);
void cancelDownload();
};