1 | // Copyright (C) 2024 Jarek Kobus |
---|---|
2 | // Copyright (C) 2024 The Qt Company Ltd. |
3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
4 | |
5 | #include "tasktreerunner.h" |
6 | |
7 | #include "tasktree.h" |
8 | |
9 | QT_BEGIN_NAMESPACE |
10 | |
11 | namespace Tasking { |
12 | |
13 | TaskTreeRunner::~TaskTreeRunner() = default; |
14 | |
15 | void TaskTreeRunner::start(const Group &recipe, |
16 | const SetupHandler &setupHandler, |
17 | const DoneHandler &doneHandler) |
18 | { |
19 | m_taskTree.reset(p: new TaskTree(recipe)); |
20 | connect(sender: m_taskTree.get(), signal: &TaskTree::done, context: this, slot: [this, doneHandler](DoneWith result) { |
21 | m_taskTree.release()->deleteLater(); |
22 | if (doneHandler) |
23 | doneHandler(result); |
24 | emit done(result); |
25 | }); |
26 | if (setupHandler) |
27 | setupHandler(m_taskTree.get()); |
28 | emit aboutToStart(taskTree: m_taskTree.get()); |
29 | m_taskTree->start(); |
30 | } |
31 | |
32 | void TaskTreeRunner::cancel() |
33 | { |
34 | if (m_taskTree) |
35 | m_taskTree->cancel(); |
36 | } |
37 | |
38 | void TaskTreeRunner::reset() |
39 | { |
40 | m_taskTree.reset(); |
41 | } |
42 | |
43 | } // namespace Tasking |
44 | |
45 | QT_END_NAMESPACE |
46 |