bill-manager/ui/mainwindow.h
2023-05-06 13:45:39 +08:00

63 lines
1.1 KiB
C++

//
// Created by skyone on 2023/4/24.
//
#ifndef QT_STATIC_MAINWINDOW_H
#define QT_STATIC_MAINWINDOW_H
#include <vector>
#include <QWidget>
#include <QDialog>
#include <QSqlDatabase>
typedef struct {
int id;
QString object;
double price;
long date;
QString comment;
} Record;
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QWidget {
Q_OBJECT
public:
explicit MainWindow(QWidget *parent = nullptr);
~MainWindow() override;
void renderData();
static bool insertRecord(const QString &object, double price, const QString &comment);
void applyQuery(const QString&);
void applySearch(const QString&);
void applySQL(QSqlQuery&);
public slots:
void handleQuery();
void handleSearch();
void handleAddSubmit();
void handlePreviousPage();
void handleNextPage();
private:
Ui::MainWindow *ui;
QSqlDatabase db;
std::vector<Record> data;
double sum = 0;
double average = 0;
int days = 0;
int page_current = 0;
int all_size = 0;
QString query = "";
bool query_is_current = false;
};
#endif //QT_STATIC_MAINWINDOW_H