2021-08-06 10:20:03 +08:00
|
|
|
|
#ifndef WORKERFACTORY_H
|
|
|
|
|
#define WORKERFACTORY_H
|
|
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
|
#include "../common/mydefine.h"
|
|
|
|
|
#include "../common/reflect.h"
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 备份还原相关任务处理类基类
|
|
|
|
|
*/
|
|
|
|
|
class Worker : public QObject
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2021-08-17 10:07:35 +08:00
|
|
|
|
explicit Worker();
|
2021-08-06 10:20:03 +08:00
|
|
|
|
virtual ~Worker();
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
// 检测结果信号
|
|
|
|
|
void checkResult(int result);
|
2021-08-26 20:12:48 +08:00
|
|
|
|
// 进度百分比
|
|
|
|
|
void progress(int currentRate);
|
2021-08-06 10:20:03 +08:00
|
|
|
|
// 工作结果信号
|
|
|
|
|
void workResult(bool result);
|
2022-01-18 17:35:26 +08:00
|
|
|
|
// 任务取消
|
|
|
|
|
void cancel();
|
2021-08-06 10:20:03 +08:00
|
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
// 环境检测
|
|
|
|
|
void checkEnv();
|
|
|
|
|
|
|
|
|
|
// 任务处理
|
|
|
|
|
void doWork();
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
// 环境检测,个性化部分派生类去实现
|
2021-08-24 18:08:18 +08:00
|
|
|
|
virtual bool checkEnvEx();
|
2021-08-06 10:20:03 +08:00
|
|
|
|
|
|
|
|
|
// 任务处理,个性化部分派生类去实现
|
|
|
|
|
virtual void doWorkEx();
|
|
|
|
|
|
|
|
|
|
// 任务取消,个性化部分派生类去实现
|
|
|
|
|
virtual void cancelEx();
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
void setParam(const BackupWrapper& backupWrapper) { m_backupWrapper = backupWrapper; }
|
|
|
|
|
|
2021-11-15 13:36:00 +08:00
|
|
|
|
public:
|
|
|
|
|
// 同一时间只能运行一个备份/还原等操作
|
2021-08-06 10:20:03 +08:00
|
|
|
|
BackupWrapper m_backupWrapper;
|
2022-01-18 17:35:26 +08:00
|
|
|
|
// 是否取消操作
|
|
|
|
|
bool m_bCancel;
|
2021-08-06 10:20:03 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief 备份还原相关任务工厂类
|
|
|
|
|
*/
|
|
|
|
|
class WorkerFactory
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
/**
|
|
|
|
|
* @brief 根据操作类型和位置创建相应的处理类
|
|
|
|
|
* @param type 操作类型,如:系统备份, 系统还原
|
|
|
|
|
* @param position 本地备份还是U盘备份: 0-本地备份;1-移动设备备份
|
|
|
|
|
* @return Worker派生类对象指针,需调用者释放此对象
|
|
|
|
|
*/
|
|
|
|
|
static Worker * createWorker(int type, int position);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // WORKERFACTORY_H
|