2013-12-20 13:47:26 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "Task.h"
|
2021-11-20 16:08:34 +00:00
|
|
|
#include "QObjectPtr.h"
|
2013-12-20 13:47:26 +00:00
|
|
|
|
|
|
|
#include <QQueue>
|
|
|
|
|
2021-07-25 18:11:59 +01:00
|
|
|
class SequentialTask : public Task
|
2013-12-20 13:47:26 +00:00
|
|
|
{
|
2018-07-15 13:51:05 +01:00
|
|
|
Q_OBJECT
|
2013-12-20 13:47:26 +00:00
|
|
|
public:
|
2022-04-01 13:10:51 +01:00
|
|
|
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 13:47:26 +00:00
|
|
|
|
2021-11-21 22:36:55 +00:00
|
|
|
void addTask(Task::Ptr task);
|
2013-12-20 13:47:26 +00:00
|
|
|
|
2022-04-01 13:10:51 +01:00
|
|
|
public slots:
|
|
|
|
bool abort() override;
|
2013-12-20 13:47:26 +00:00
|
|
|
|
2022-06-02 23:34:08 +01:00
|
|
|
protected
|
2013-12-20 13:47:26 +00:00
|
|
|
slots:
|
2022-06-02 23:34:08 +01:00
|
|
|
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 13:47:26 +00:00
|
|
|
|
2022-04-13 23:23:12 +01:00
|
|
|
protected:
|
|
|
|
void setStepStatus(QString status) { m_step_status = status; emit stepStatus(status); };
|
2022-04-01 13:10:51 +01:00
|
|
|
|
2022-04-13 23:23:12 +01:00
|
|
|
protected:
|
2022-04-01 13:10:51 +01:00
|
|
|
QString m_name;
|
|
|
|
QString m_step_status;
|
|
|
|
|
2021-11-21 22:36:55 +00:00
|
|
|
QQueue<Task::Ptr > m_queue;
|
2018-07-15 13:51:05 +01:00
|
|
|
int m_currentIndex;
|
2022-04-01 13:10:51 +01:00
|
|
|
|
|
|
|
qint64 m_stepProgress = 0;
|
|
|
|
qint64 m_stepTotalProgress = 100;
|
2022-05-09 14:53:52 +01:00
|
|
|
|
|
|
|
bool m_aborted = false;
|
2013-12-20 13:47:26 +00:00
|
|
|
};
|