forked from qt-creator/qt-creator
TaskTreeRunner: Add setup and done handlers
They might be more convenient than runner's signals. Change-Id: Ie50afd12f8db6a7f125b1b728a59297d85a48f34 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -9,13 +9,19 @@ namespace Tasking {
|
||||
|
||||
TaskTreeRunner::~TaskTreeRunner() = default;
|
||||
|
||||
void TaskTreeRunner::start(const Group &recipe)
|
||||
void TaskTreeRunner::start(const Group &recipe,
|
||||
const SetupHandler &setupHandler,
|
||||
const DoneHandler &doneHandler)
|
||||
{
|
||||
m_taskTree.reset(new TaskTree(recipe));
|
||||
connect(m_taskTree.get(), &TaskTree::done, this, [this](DoneWith result) {
|
||||
connect(m_taskTree.get(), &TaskTree::done, this, [this, doneHandler](DoneWith result) {
|
||||
m_taskTree.release()->deleteLater();
|
||||
if (doneHandler)
|
||||
doneHandler(result);
|
||||
emit done(result);
|
||||
});
|
||||
if (setupHandler)
|
||||
setupHandler(m_taskTree.get());
|
||||
emit aboutToStart(m_taskTree.get());
|
||||
m_taskTree->start();
|
||||
}
|
||||
|
@@ -15,12 +15,17 @@ class TASKING_EXPORT TaskTreeRunner : public QObject
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
using SetupHandler = std::function<void(TaskTree *)>;
|
||||
using DoneHandler = std::function<void(DoneWith)>;
|
||||
|
||||
~TaskTreeRunner();
|
||||
|
||||
bool isRunning() const { return bool(m_taskTree); }
|
||||
|
||||
// When task tree is running it resets the old task tree.
|
||||
void start(const Group &recipe);
|
||||
void start(const Group &recipe,
|
||||
const SetupHandler &setupHandler = {},
|
||||
const DoneHandler &doneHandler = {});
|
||||
|
||||
// TODO: rename to cancel(), also in TaskTree API, adapt docs.
|
||||
// When task tree is running it emits done(DoneWith::Cancel) synchronously.
|
||||
|
Reference in New Issue
Block a user