#ifndef DATABASEMANAGER_H #define DATABASEMANAGER_H #include #include // 数据库管理类 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 getTopTwo(); QList get(QVariantMap params); QList 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