49 lines
1.2 KiB
C++
Executable File
49 lines
1.2 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 year; // 年
|
||
QString month; // 月
|
||
QString day; // 日
|
||
QString time; // 时分秒,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
|