1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#include "builderreceiver.h"
6#include "mainframe/buildmanager.h"
7#include "common/common.h"
8#include "services/project/projectservice.h"
9
10BuilderReceiver::BuilderReceiver(QObject *parent)
11 : dpf::EventHandler(parent)
12{
13
14}
15
16dpf::EventHandler::Type BuilderReceiver::type()
17{
18 return dpf::EventHandler::Type::Sync;
19}
20
21QStringList BuilderReceiver::topics()
22{
23 return {project.topic, T_DEBUGGER, symbol.topic};
24}
25
26void BuilderReceiver::eventProcess(const dpf::Event &event)
27{
28 if (event.data() == project.activedProject.name) {
29 QVariant proInfoVar = event.property(project.activedProject.pKeys[0]);
30 dpfservice::ProjectInfo projectInfo = qvariant_cast<dpfservice::ProjectInfo>(proInfoVar);
31 BuildManager::instance()->setActivedProjectInfo(projectInfo.kitName(), projectInfo.workspaceFolder());
32 } else if (event.data() == project.createdProject.name) {
33 QVariant proInfoVar = event.property(project.createdProject.pKeys[0]);
34 dpfservice::ProjectInfo projectInfo = qvariant_cast<dpfservice::ProjectInfo>(proInfoVar);
35 BuildManager::instance()->setActivedProjectInfo(projectInfo.kitName(), projectInfo.workspaceFolder());
36 } else if (event.data() == project.deletedProject.name) {
37 QVariant proInfoVar = event.property(project.deletedProject.pKeys[0]);
38 dpfservice::ProjectInfo projectInfo = qvariant_cast<dpfservice::ProjectInfo>(proInfoVar);
39 BuildManager::instance()->clearActivedProjectInfo();
40 } else if (event.data() == symbol.parseDone.name) {
41 bool bSuccess = event.property("success").toBool();
42 if(!bSuccess) {
43 QString workspace = event.property("workspace").toString();
44 QString language = event.property("language").toString();
45 const QString &storage = workspace;
46
47 QString errMsg = QDialog::tr(
48 "Error parsing project symbol\n"
49 "workspace: %0\n"
50 "language: %1\n"
51 "storage: %2\n")
52 .arg(workspace)
53 .arg(language)
54 .arg(storage);
55
56 BuildManager::instance()->addOutput(errMsg, OutputPane::ErrorMessage);
57 }
58 }
59}
60
61