ProjectManager: Add convenience Task subclasses

For Compile, BuildSystem and Deployment. Unclutters user code and reduces
binary size.

Change-Id: Ia18e917bb411754162e9f4ec6056d752a020bb50
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2020-01-15 08:56:11 +01:00
parent 7e19d1af7c
commit 0334b6e491
56 changed files with 1233 additions and 1548 deletions

View File

@@ -400,10 +400,7 @@ void QbsBuildStep::handleProcessResult(
void QbsBuildStep::createTaskAndOutput(ProjectExplorer::Task::TaskType type, const QString &message,
const QString &file, int line)
{
ProjectExplorer::Task task = ProjectExplorer::Task(type, message,
Utils::FilePath::fromString(file), line,
ProjectExplorer::Constants::TASK_CATEGORY_COMPILE);
emit addTask(task, 1);
emit addTask(CompileTask(type, message, FilePath::fromString(file), line), 1);
emit addOutput(message, OutputFormat::Stdout);
}

View File

@@ -147,9 +147,7 @@ void QbsCleanStep::handleProgress(int value)
void QbsCleanStep::createTaskAndOutput(ProjectExplorer::Task::TaskType type, const QString &message, const QString &file, int line)
{
Task task(type, message, Utils::FilePath::fromString(file), line,
ProjectExplorer::Constants::TASK_CATEGORY_COMPILE);
emit addTask(task, 1);
emit addTask(CompileTask(type, message, Utils::FilePath::fromString(file), line), 1);
emit addOutput(message, OutputFormat::Stdout);
}

View File

@@ -202,9 +202,7 @@ void QbsInstallStep::handleProgress(int value)
void QbsInstallStep::createTaskAndOutput(ProjectExplorer::Task::TaskType type,
const QString &message, const QString &file, int line)
{
ProjectExplorer::Task task = ProjectExplorer::Task(type, message,
Utils::FilePath::fromString(file), line,
ProjectExplorer::Constants::TASK_CATEGORY_COMPILE);
const CompileTask task(type, message, Utils::FilePath::fromString(file), line);
emit addTask(task, 1);
emit addOutput(message, OutputFormat::Stdout);
}

View File

@@ -197,8 +197,8 @@ QbsBuildSystem::QbsBuildSystem(QbsBuildConfiguration *bc)
m_sourcesForGeneratedFiles.clear();
});
connect(m_session, &QbsSession::errorOccurred, this, [](QbsSession::Error e) {
TaskHub::addTask(Task::Error, tr("Fatal qbs error: %1").arg(QbsSession::errorString(e)),
ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM);
const QString msg = tr("Fatal qbs error: %1").arg(QbsSession::errorString(e));
TaskHub::addTask(BuildSystemTask(Task::Error, msg));
});
connect(m_session, &QbsSession::fileListUpdated, this, &QbsBuildSystem::delayParsing);
@@ -644,9 +644,8 @@ void QbsBuildSystem::updateAfterBuild()
void QbsBuildSystem::generateErrors(const ErrorInfo &e)
{
for (const ErrorInfoItem &item : e.items) {
TaskHub::addTask(Task::Error, item.description,
ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM,
item.filePath, item.line);
TaskHub::addTask(BuildSystemTask(Task::Error, item.description,
item.filePath, item.line));
}
}

View File

@@ -494,9 +494,8 @@ void QbsSession::handlePacket(const QJsonObject &packet)
// TODO: This loop occurs a lot. Factor it out.
for (const ErrorInfoItem &item : errorInfo.items) {
TaskHub::addTask(Task::Warning, item.description,
ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM,
item.filePath, item.line);
TaskHub::addTask(BuildSystemTask(Task::Warning, item.description,
item.filePath, item.line));
}
} else if (type == "task-started") {
emit taskStarted(packet.value("description").toString(),