6 #include <QTreeWidgetItem>
14 SkillExecutionTreeWidget::runContextMenu(
const QPoint& pos)
19 QMenu* menu =
new QMenu();
22 QAction* stopSkillAction =
new QAction(
"Stop execution",
this);
23 const auto& executions =
memory->getExecutions();
32 QAction* rerunSkillAction =
new QAction(
"Re-execute with similar parameters",
this);
33 menu->addAction(stopSkillAction);
34 menu->addAction(rerunSkillAction);
35 connect(stopSkillAction,
38 &SkillExecutionTreeWidget::stopSelectedExecution);
39 connect(rerunSkillAction,
42 &SkillExecutionTreeWidget::rerunSkillWithSimilarParams);
45 menu->popup(this->viewport()->mapToGlobal(pos));
49 SkillExecutionTreeWidget::stopSelectedExecution()
51 if (!selectionValid())
57 SkillExecutionTreeWidget::rerunSkillWithSimilarParams()
59 if (!selectionValid())
62 skills::SkillExecutionID currentExecutionId = this->selectedExecution.
skillExecutionId;
63 auto executions =
memory->getExecutions();
64 if (executions.empty())
67 if (executions.count(currentExecutionId) == 0)
70 ARMARX_IMPORTANT <<
"The selected execution was not found in memory. The GUI is unable "
71 "to determine the parametrization for this execution.";
74 auto params = executions[currentExecutionId].parameters;
76 ARMARX_INFO <<
"Re-executing the skill " << currentExecutionId.skillId
77 <<
" with previous parameters.";
80 this->
memory->startExecutionWithParams(currentExecutionId.skillId, params);
91 SkillExecutionTreeWidget::setupUi()
93 this->setColumnCount(6);
95 this->setContextMenuPolicy(Qt::CustomContextMenu);
97 QTreeWidgetItem* qtreewidgetitem = this->headerItem();
98 qtreewidgetitem->setText(5,
"");
99 qtreewidgetitem->setText(4,
"");
100 qtreewidgetitem->setText(3,
"Status");
101 qtreewidgetitem->setText(2,
"SkillID");
102 qtreewidgetitem->setText(1,
"Executor");
103 qtreewidgetitem->setText(0,
"Timestamp");
105 this->setColumnWidth(4, 30);
111 SkillExecutionTreeWidget::connectSignals()
114 &QTreeWidget::customContextMenuRequested,
116 &SkillExecutionTreeWidget::runContextMenu);
118 &QTreeWidget::currentItemChanged,
120 &SkillExecutionTreeWidget::executionSelectionChanged);
124 SkillExecutionTreeWidget::selectionValid()
130 SkillExecutionTreeWidget::executionSelectionChanged(QTreeWidgetItem* current,
131 QTreeWidgetItem* previous)
134 SkillExecutionTreeWidgetItem* selected =
135 dynamic_cast<SkillExecutionTreeWidgetItem*
>(current);
145 if (
update.statuses.empty())
150 for (
const auto& [k,
v] :
update.statuses)
156 for (
int i = 0; i < this->topLevelItemCount(); ++i)
180 item->updateItem(statusUpdate.
status);