45 lines
1.1 KiB
C++
Executable File
45 lines
1.1 KiB
C++
Executable File
#ifndef DATABASEMANAGER_H
|
|
#define DATABASEMANAGER_H
|
|
#include <QSqlDatabase>
|
|
#include <QVariantMap>
|
|
|
|
// 数据库管理类
|
|
class DatabaseManager {
|
|
public:
|
|
enum Channel {
|
|
MainChannel = 1,
|
|
SecondaryChannel
|
|
};
|
|
struct File {
|
|
int id; // id
|
|
Channel channel; // 通道
|
|
QString datetime; // 时间 yyyy-MM-dd hh:mm:ss
|
|
QString filename; // 文件名
|
|
};
|
|
static DatabaseManager* getInstace();
|
|
~DatabaseManager();
|
|
|
|
bool open();
|
|
void close();
|
|
|
|
bool insert(File file);
|
|
|
|
bool remove(DatabaseManager::Channel chn, QString name);
|
|
|
|
QList<DatabaseManager::File> getTopTwo();
|
|
QList<DatabaseManager::File> get(QVariantMap params);
|
|
QList<DatabaseManager::File> get(Channel chn);
|
|
QStringList getAllYears(Channel chn);
|
|
QStringList getAllMonths(Channel chn, QString year);
|
|
QStringList getAllDays(Channel, QString year, QString month);
|
|
|
|
private:
|
|
DatabaseManager();
|
|
|
|
private:
|
|
static DatabaseManager* instance;
|
|
QSqlDatabase db;
|
|
};
|
|
|
|
#endif // DATABASEMANAGER_H
|