Files
qt-creator/tests/manual/tasktree/taskwidget.h
Jarek Kobus b6208ab34a TaskTree: Introduce ParallelLimit
The parallel limit constrains the number of parallel tasks
run in the same time. So, if e.g. a group contains 10 children
and the parallel limit is 6, only first 6 tasks are being started
on the beginning and the rest 4 are being postponed until some
running tasks are finished. So, when the one of 6 running tasks
finishes the group starts the 7th task and so on.

Setting parallel limit to 1 means sequential invocation in fact.

The value of 0 means there is no limit and all tasks are run at once.

Remove the ExecuteMode enum, as this is modelled now by the
parallelLimit.

Change-Id: Ice59318be0915401f05bb5a5804078bdc591d09f
Reviewed-by: hjk <hjk@qt.io>
2023-01-06 15:28:19 +00:00

84 lines
1.7 KiB
C++

// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include <utils/layoutbuilder.h>
#include <utils/tasktree.h>
#include <QWidget>
class StateIndicator;
QT_BEGIN_NAMESPACE
class QCheckBox;
class QComboBox;
class QLabel;
class QSpinBox;
QT_END_NAMESPACE
enum class State {
Initial,
Running,
Done,
Error
};
enum class ExecuteMode {
Sequential, // default
Parallel
};
class StateWidget : public QWidget
{
public:
StateWidget();
void setState(State state);
protected:
StateIndicator *m_stateIndicator = nullptr;
};
class TaskWidget : public StateWidget
{
public:
TaskWidget();
void setBusyTime(int seconds);
int busyTime() const;
void setSuccess(bool success);
bool isSuccess() const;
private:
QLabel *m_infoLabel = nullptr;
QSpinBox *m_spinBox = nullptr;
QCheckBox *m_checkBox = nullptr;
};
class GroupWidget : public StateWidget
{
public:
GroupWidget();
void setExecuteMode(ExecuteMode mode);
Utils::Tasking::ParallelLimit executeMode() const;
void setWorkflowPolicy(Utils::Tasking::WorkflowPolicy policy);
Utils::Tasking::WorkflowPolicy workflowPolicy() const;
private:
void updateExecuteMode();
void updateWorkflowPolicy();
QComboBox *m_executeCombo = nullptr;
QComboBox *m_workflowCombo = nullptr;
ExecuteMode m_executeMode = ExecuteMode::Sequential;
Utils::Tasking::WorkflowPolicy m_workflowPolicy = Utils::Tasking::WorkflowPolicy::StopOnError;
};
class TaskGroup : public Utils::Layouting::Row
{
public:
TaskGroup(QWidget *group, std::initializer_list<Utils::LayoutBuilder::LayoutItem> items);
};