qt_demoe/control/saveruntime/saveruntime.h

77 lines
1.7 KiB
C
Raw Normal View History

#ifndef SAVERUNTIME_H
#define SAVERUNTIME_H
2021-09-26 01:50:09 +00:00
/**
* :feiyangqingyun(QQ:517216493) 2016-12-16
* 1.
* 2.
* 3.
* 4.
* 5.
*/
#include <QObject>
#include <QDateTime>
2021-10-07 02:57:25 +00:00
class QTimer;
#ifdef quc
2020-12-24 10:00:09 +00:00
class Q_DECL_EXPORT SaveRunTime : public QObject
#else
class SaveRunTime : public QObject
#endif
{
Q_OBJECT
public:
static SaveRunTime *Instance();
explicit SaveRunTime(QObject *parent = 0);
private:
static QScopedPointer<SaveRunTime> self;
2021-10-07 02:57:25 +00:00
//日志文件路径
QString path;
//日志文件名称
QString name;
//最后的编号
int lastID;
2021-10-07 02:57:25 +00:00
//保存间隔
int saveInterval;
2021-10-07 02:57:25 +00:00
//开始时间
QDateTime startTime;
2021-10-07 02:57:25 +00:00
//日志文件
QString logFile;
2021-10-07 02:57:25 +00:00
//保存文件定时器
QTimer *timerSave;
private:
2021-10-07 02:57:25 +00:00
//比较两个时间差值
void getDiffValue(const QDateTime &startTime, const QDateTime &endTime, int &day, int &hour, int &minute);
2021-10-07 02:57:25 +00:00
public Q_SLOTS:
//启动服务
void start();
//停止服务
void stop();
2021-10-07 02:57:25 +00:00
//新建目录
void newPath();
//初始化日志文件
void initLog();
//追加一条记录到日志文件
void appendLog();
//保存运行时间到日志文件
void saveLog();
2021-10-07 02:57:25 +00:00
//设置文件保存目录
void setPath(const QString &path);
2021-10-07 02:57:25 +00:00
//设置文件名称
void setName(const QString &name);
2021-10-07 02:57:25 +00:00
//设置保存间隔
void setSaveInterval(int saveInterval);
};
#endif // SAVERUNTIME_H