| 274 | } |
| 275 | |
| 276 | void VariableTree::contextMenuEvent(QContextMenuEvent* event) |
| 277 | { |
| 278 | auto* const selectedVariable = this->selectedVariable(); |
| 279 | if (!selectedVariable) |
| 280 | return; |
| 281 | |
| 282 | // set up menu |
| 283 | QMenu contextMenu(this->parentWidget()); |
| 284 | |
| 285 | m_contextMenuTitle->setText(selectedVariable == variableCollection()->watches()->returnValueVariable() |
| 286 | ? i18nc("%1 - the name of a GDB variable, e.g. \"$1\"", |
| 287 | "%1 (last function return value)", selectedVariable->expression()) |
| 288 | : selectedVariable->expression()); |
| 289 | contextMenu.addAction(m_contextMenuTitle); |
| 290 | |
| 291 | if (selectedVariable->canSetFormat()) { |
| 292 | contextMenu.addMenu(m_formatMenu); |
| 293 | } |
| 294 | |
| 295 | const auto formatMenuActions = m_formatMenu->actions(); |
| 296 | for (QAction* act : formatMenuActions) { |
| 297 | if (act->data().toInt() == selectedVariable->format()) { |
| 298 | act->setChecked(true); |
| 299 | } |
| 300 | } |
| 301 | |
| 302 | if (qobject_cast<Watches*>(selectedVariable->parent())) { |
| 303 | contextMenu.addAction(m_watchDelete); |
| 304 | } |
| 305 | |
| 306 | contextMenu.addSeparator(); |
| 307 | contextMenu.addAction(m_copyVariableValue); |
| 308 | if (canStopOnChange(*selectedVariable)) { |
| 309 | contextMenu.addAction(m_stopOnChange); |
| 310 | } |
| 311 | |
| 312 | contextMenu.exec(event->globalPos()); |
| 313 | } |
| 314 | |
| 315 | QModelIndex VariableTree::mapViewIndexToTreeModelIndex(const QModelIndex& viewIndex) const |
| 316 | { |
nothing calls this directly
no test coverage detected