1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #include "symbolreceiver.h" |
6 | #include "mainframe/symboltreeview.h" |
7 | #include "mainframe/symbolkeeper.h" |
8 | |
9 | #include "common/common.h" |
10 | |
11 | #include "services/window/windowservice.h" |
12 | #include "services/project/projectservice.h" |
13 | |
14 | typedef FileOperation FO; |
15 | |
16 | SymbolReceiver::SymbolReceiver(QObject *parent) |
17 | : dpf::EventHandler (parent) |
18 | , dpf::AutoEventHandlerRegister<SymbolReceiver> () |
19 | { |
20 | |
21 | } |
22 | |
23 | dpf::EventHandler::Type SymbolReceiver::type() |
24 | { |
25 | return dpf::EventHandler::Type::Sync; |
26 | } |
27 | |
28 | QStringList SymbolReceiver::topics() |
29 | { |
30 | return {symbol.topic, project.topic}; //绑定menu 事件 |
31 | } |
32 | |
33 | void SymbolReceiver::eventProcess(const dpf::Event &event) |
34 | { |
35 | if (event.data() == project.activedProject.name) { |
36 | QString projectInfoKey = project.activedProject.pKeys[0]; |
37 | dpfservice::ProjectInfo info = qvariant_cast<dpfservice::ProjectInfo> |
38 | (event.property(projectInfoKey)); |
39 | QString workspace = info.workspaceFolder(); |
40 | QString language = info.language(); |
41 | QString storage = FO::checkCreateDir(FO::checkCreateDir(workspace, ".unioncode" ), "symbol" ); |
42 | if (!language.isEmpty() && !storage.isEmpty()) { |
43 | SymbolKeeper::instance()->doParse({workspace, language, storage}); |
44 | } |
45 | SymbolKeeper::instance()->treeView()->setRootPath(storage); |
46 | } else if (event.data() == symbol.parse.name) { // "workspace", "language", "storage" |
47 | bool bSuccess = event.property("success" ).toBool(); |
48 | if(bSuccess) { |
49 | QString workspace = event.property("workspace" ).toString(); |
50 | QString language = event.property("language" ).toString(); |
51 | QString storage = event.property("storage" ).toString(); |
52 | SymbolKeeper::instance()->doParse({workspace, language, storage}); |
53 | SymbolKeeper::instance()->treeView()->setRootPath(storage); |
54 | } |
55 | } |
56 | } |
57 | |