forked from qt-creator/qt-creator
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:
@@ -1412,10 +1412,10 @@ void TaskNode::invokeEndHandler(bool success)
|
|||||||
it from a source and writing it to a destination might look as follows:
|
it from a source and writing it to a destination might look as follows:
|
||||||
|
|
||||||
\code
|
\code
|
||||||
static QByteArray load(const FilePath &fileName) { ... }
|
static QByteArray load(const QString &fileName) { ... }
|
||||||
static void save(const FilePath &fileName, const QByteArray &array) { ... }
|
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
|
struct CopyStorage { // [1] custom inter-task struct
|
||||||
QByteArray content; // [2] custom inter-task data
|
QByteArray content; // [2] custom inter-task data
|
||||||
@@ -1449,6 +1449,13 @@ void TaskNode::invokeEndHandler(bool success)
|
|||||||
};
|
};
|
||||||
return root;
|
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
|
\endcode
|
||||||
|
|
||||||
In the example above, the inter-task data consists of a QByteArray content
|
In the example above, the inter-task data consists of a QByteArray content
|
||||||
|
|||||||
Reference in New Issue
Block a user