MCPcopy Create free account
hub / github.com/Codeya-IDE/deepin-ide / contextMenuEvent

Method contextMenuEvent

src/plugins/debugger/interface/breakpointview.cpp:46–102  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44}
45
46void BreakpointView::contextMenuEvent(QContextMenuEvent *event)
47{
48 DTreeView::contextMenuEvent(event);
49 BreakpointModel *bpModel = static_cast<BreakpointModel *>(model());
50 if (bpModel->breakpointSize() == 0)
51 return;
52
53 bool allSelectEnabled = true;
54 bool allSelectDisabled = true;
55 //selectedRows
56 auto rows = selectionModel()->selectedRows();
57 for (auto row : rows) {
58 auto bp = bpModel->BreakpointAt(row.row());
59 if (bp.enabled)
60 allSelectDisabled = false;
61 else
62 allSelectEnabled = false;
63 }
64
65 //all rows
66 bool allEnabled = true;
67 bool allDisabled = true;
68 QModelIndexList allRows;
69 for (int index = 0; index < bpModel->breakpointSize(); index++) {
70 allRows.append(bpModel->index(index, 0));
71 auto bp = bpModel->BreakpointAt(index);
72 if (bp.enabled)
73 allDisabled = false;
74 else
75 allEnabled = false;
76 }
77
78 QMenu menu(this);
79 if (!allSelectEnabled)
80 menu.addAction(tr("Enable selected breakpoints"), this, [=]() { enableBreakpoints(rows); });
81 if (!allSelectDisabled)
82 menu.addAction(tr("Disable selected breakpoints"), this, [=]() { disableBreakpoints(rows); });
83 menu.addSeparator();
84
85 if (!rows.isEmpty())
86 menu.addAction(tr("Remove selected breakpoints"), this, [=]() { removeBreakpoints(rows); });
87
88 menu.addAction(tr("Remove all breakpoints"), this, [=]() { removeBreakpoints(allRows); });
89 menu.addSeparator();
90
91 if (!allEnabled)
92 menu.addAction(tr("Enable all breakpoints"), this, [=]() { enableBreakpoints(allRows); });
93 if (!allDisabled)
94 menu.addAction(tr("Disable all breakpoints"), this, [=]() { disableBreakpoints(allRows); });
95
96 // select one item
97 if (rows.size() == 1) {
98 menu.addAction(tr("Edit Condition"), this, [=]() { editBreakpointCondition(rows.at(0)); });
99 }
100
101 menu.exec(event->globalPos());
102}
103

Callers

nothing calls this directly

Calls 11

modelClass · 0.85
breakpointSizeMethod · 0.80
rowMethod · 0.80
addSeparatorMethod · 0.80
atMethod · 0.80
appendMethod · 0.45
indexMethod · 0.45
addActionMethod · 0.45
isEmptyMethod · 0.45
sizeMethod · 0.45
execMethod · 0.45

Tested by

no test coverage detected