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
|
|
|
protected slots:
|
|
|
|
void executeTask() override;
|
|
|
|
public slots:
|
|
|
|
bool abort() override;
|
2013-12-20 13:47:26 +00:00
|
|
|
|
|
|
|
private
|
|
|
|
slots:
|
2018-07-15 13:51:05 +01:00
|
|
|
void startNext();
|
|
|
|
void subTaskFailed(const QString &msg);
|
|
|
|
void subTaskStatus(const QString &msg);
|
|
|
|
void subTaskProgress(qint64 current, qint64 total);
|
2013-12-20 13:47:26 +00:00
|
|
|
|
2022-04-01 13:10:51 +01:00
|
|
|
signals:
|
|
|
|
void stepStatus(QString status);
|
|
|
|
|
2013-12-20 13:47:26 +00:00
|
|
|
private:
|
2022-04-01 13:10:51 +01:00
|
|
|
void setStepStatus(QString status) { m_step_status = status; };
|
|
|
|
|
|
|
|
private:
|
|
|
|
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;
|
2013-12-20 13:47:26 +00:00
|
|
|
};
|