1// SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd.
2//
3// SPDX-License-Identifier: GPL-3.0-or-later
4
5#include "filebrowserreceiver.h"
6#include "mainframe/treeviewkeeper.h"
7
8#include "services/project/projectservice.h"
9
10#include "common/common.h"
11
12FileBrowserReceiver::FileBrowserReceiver(QObject *parent)
13 : dpf::EventHandler (parent)
14 , dpf::AutoEventHandlerRegister<FileBrowserReceiver> ()
15{
16
17}
18
19dpf::EventHandler::Type FileBrowserReceiver::type()
20{
21 return dpf::EventHandler::Type::Sync;
22}
23
24QStringList FileBrowserReceiver::topics()
25{
26 return {project.topic}; //绑定menu 事件
27}
28
29void FileBrowserReceiver::eventProcess(const dpf::Event &event)
30{
31 if (event.data() == project.activedProject.name) {
32 QVariant proInfoVar = event.property(project.activedProject.pKeys[0]);
33 dpfservice::ProjectInfo proInfo = qvariant_cast<dpfservice::ProjectInfo>(proInfoVar);
34 TreeViewKeeper::instance()->treeView()->setProjectInfo(proInfo);
35 } else if (event.data() == project.deletedProject.name) {
36 TreeViewKeeper::instance()->treeView()->setProjectInfo({});
37 } else if (event.data() == project.createdProject.name) {
38 QVariant proInfoVar = event.property(project.activedProject.pKeys[0]);
39 dpfservice::ProjectInfo proInfo = qvariant_cast<dpfservice::ProjectInfo>(proInfoVar);
40 TreeViewKeeper::instance()->treeView()->setProjectInfo(proInfo);
41 }
42}
43