PrismLauncher/launcher/tasks/SequentialTask.h

50 lines
1.2 KiB
C
Raw Normal View History

#pragma once
#include "Task.h"
2021-11-20 16:08:34 +00:00
#include "QObjectPtr.h"
#include <QQueue>
class SequentialTask : public Task
{
2018-07-15 13:51:05 +01:00
Q_OBJECT
public:
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; }
2021-11-21 22:36:55 +00:00
void addTask(Task::Ptr task);
public slots:
bool abort() override;
protected
slots:
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);
protected:
void setStepStatus(QString status) { m_step_status = status; emit stepStatus(status); };
protected:
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;
qint64 m_stepProgress = 0;
qint64 m_stepTotalProgress = 100;
bool m_aborted = false;
};