2013-12-20 19:17:26 +05:30
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Task.h"
|
2021-11-20 21:38:34 +05:30
|
|
|
#include "QObjectPtr.h"
|
2013-12-20 19:17:26 +05:30
|
|
|
|
|
|
|
#include <QQueue>
|
|
|
|
|
2021-07-25 22:41:59 +05:30
|
|
|
class SequentialTask : public Task
|
2013-12-20 19:17:26 +05:30
|
|
|
{
|
2018-07-15 18:21:05 +05:30
|
|
|
Q_OBJECT
|
2013-12-20 19:17:26 +05:30
|
|
|
public:
|
2022-04-01 17:40:51 +05:30
|
|
|
explicit SequentialTask(QObject *parent = nullptr, const QString& task_name = "");
|
|
|
|
virtual ~SequentialTask();
|
|
|
|
|
|
|
|
inline auto isMultiStep() const -> bool override { return m_queue.size() > 1; };
|
|
|
|
auto getStepProgress() const -> qint64 override;
|
|
|
|
auto getStepTotalProgress() const -> qint64 override;
|
|
|
|
|
|
|
|
inline auto getStepStatus() const -> QString override { return m_step_status; }
|
2013-12-20 19:17:26 +05:30
|
|
|
|
2021-11-22 04:06:55 +05:30
|
|
|
void addTask(Task::Ptr task);
|
2013-12-20 19:17:26 +05:30
|
|
|
|
2022-04-01 17:40:51 +05:30
|
|
|
public slots:
|
|
|
|
bool abort() override;
|
2013-12-20 19:17:26 +05:30
|
|
|
|
2022-06-03 04:04:08 +05:30
|
|
|
protected
|
2013-12-20 19:17:26 +05:30
|
|
|
slots:
|
2022-06-03 04:04:08 +05:30
|
|
|
void executeTask() override;
|
|
|
|
|
|
|
|
virtual void startNext();
|
|
|
|
virtual void subTaskFailed(const QString &msg);
|
|
|
|
virtual void subTaskStatus(const QString &msg);
|
|
|
|
virtual void subTaskProgress(qint64 current, qint64 total);
|
2013-12-20 19:17:26 +05:30
|
|
|
|
2022-04-14 03:53:12 +05:30
|
|
|
protected:
|
|
|
|
void setStepStatus(QString status) { m_step_status = status; emit stepStatus(status); };
|
2022-04-01 17:40:51 +05:30
|
|
|
|
2022-04-14 03:53:12 +05:30
|
|
|
protected:
|
2022-04-01 17:40:51 +05:30
|
|
|
QString m_name;
|
|
|
|
QString m_step_status;
|
|
|
|
|
2021-11-22 04:06:55 +05:30
|
|
|
QQueue<Task::Ptr > m_queue;
|
2018-07-15 18:21:05 +05:30
|
|
|
int m_currentIndex;
|
2022-04-01 17:40:51 +05:30
|
|
|
|
|
|
|
qint64 m_stepProgress = 0;
|
|
|
|
qint64 m_stepTotalProgress = 100;
|
2022-05-09 19:23:52 +05:30
|
|
|
|
|
|
|
bool m_aborted = false;
|
2013-12-20 19:17:26 +05:30
|
|
|
};
|