TaskTree: Some corrections to the copy example

Use QString instead of FilePath.
Rename the diffRecipe into copyRecipe.
Add some code that constructs the tree, connects to its done signal
and starts the tree.

Change-Id: I40e1c4784c736347682071b3e3e99db599ce102a
Reviewed-by: hjk <hjk@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Jarek Kobus
2023-05-26 19:44:17 +02:00
parent cbca40401b
commit ffdb0c7dcc

View File

@@ -1412,10 +1412,10 @@ void TaskNode::invokeEndHandler(bool success)
it from a source and writing it to a destination might look as follows:
\code
static QByteArray load(const FilePath &fileName) { ... }
static void save(const FilePath &fileName, const QByteArray &array) { ... }
static QByteArray load(const QString &fileName) { ... }
static void save(const QString &fileName, const QByteArray &array) { ... }
static TaskItem diffRecipe(const FilePath &source, const FilePath &destination)
static TaskItem copyRecipe(const QString &source, const QString &destination)
{
struct CopyStorage { // [1] custom inter-task struct
QByteArray content; // [2] custom inter-task data
@@ -1449,6 +1449,13 @@ void TaskNode::invokeEndHandler(bool success)
};
return root;
}
const QString source = ...;
const QString destination = ...;
TaskTree taskTree(copyRecipe(source, destination));
connect(&taskTree, &TaskTree::done,
&taskTree, [] { qDebug() << "The copying finished successfully."; });
tasktree.start();
\endcode
In the example above, the inter-task data consists of a QByteArray content