1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
---|---|
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #include "problemoutputpane.h" |
6 | #include "tasks/taskmanager.h" |
7 | #include "services/builder/task.h" |
8 | |
9 | |
10 | #include "common/common.h" |
11 | |
12 | #include <QVBoxLayout> |
13 | |
14 | ProblemOutputPane::ProblemOutputPane(QWidget *parent) |
15 | : QWidget(parent) |
16 | { |
17 | QVBoxLayout *layout = new QVBoxLayout(); |
18 | layout->addWidget(TaskManager::instance()->getView()); |
19 | setLayout(layout); |
20 | } |
21 | |
22 | ProblemOutputPane::~ProblemOutputPane() |
23 | { |
24 | |
25 | } |
26 | |
27 | void ProblemOutputPane::clearContents() |
28 | { |
29 | TaskManager::instance()->clearTasks(); |
30 | } |
31 | |
32 | void ProblemOutputPane::addTask(const Task &task, int linkedOutputLines, int skipLines) |
33 | { |
34 | TaskManager::instance()->slotAddTask(task, linkedOutputLines, skipLines); |
35 | } |
36 | |
37 | |
38 | void ProblemOutputPane::contextMenuEvent(QContextMenuEvent * event) |
39 | { |
40 | if (nullptr == menu) { |
41 | menu = new QMenu(this); |
42 | menu->setParent(this); |
43 | menu->addActions(actionFactory()); |
44 | } |
45 | |
46 | menu->move(event->globalX(), event->globalY()); |
47 | menu->show(); |
48 | } |
49 | |
50 | QList<QAction*> ProblemOutputPane::actionFactory() |
51 | { |
52 | QList<QAction*> list; |
53 | auto action = new QAction(this); |
54 | action->setText(tr("Clear")); |
55 | connect(action, &QAction::triggered, [this](){ |
56 | clearContents(); |
57 | }); |
58 | list.append(action); |
59 | return list; |
60 | } |
61 | |
62 | |
63 |