SkillExecutionTreeWidgetItem.cpp
Go to the documentation of this file.
2 
3 namespace armarx::skills::gui
4 {
5  SkillExecutionTreeWidgetItem*
7  const SkillExecutionID& needle)
8  {
9  if (!haystack)
10  {
11  return nullptr;
12  }
13 
14  if (needle == haystack->executionId)
15  {
16  return haystack;
17  }
18  for (int i = 0; i < haystack->childCount(); ++i)
19  {
20  auto el = dynamic_cast<SkillExecutionTreeWidgetItem*>(haystack->child(i));
21  if (!el)
22  {
23  // Dynamic casting failed. Skip element...
24  // We assume, that only this type can contain children in the tree.
25  continue;
26  }
28  }
29  return nullptr;
30  }
31 
34  {
35  return this->executionId;
36  }
37 
38  void
40  {
41  this->setText(0,
42  QString::fromStdString(executionId.executionStartedTime.toDateTimeString()));
43  this->setText(1, QString::fromStdString(executionId.executorName));
44  this->setText(2, QString::fromStdString(executionId.skillId.toString()));
45  for (std::pair<skills::SkillStatus, std::string> i : EXECUTION_STATUS_TO_STRING)
46  {
47  if (i.first == skillStatus)
48  {
49  this->setText(3, QString::fromStdString(i.second));
50  }
51  }
52  updateButtonState(skillStatus);
53  }
54 
55  void
57  {
58  memory->stopExecution(executionId);
59  }
60 
61  void
62  SkillExecutionTreeWidgetItem::setupUi()
63  {
64  parentTree->insertTopLevelItem(0, this);
65  abortButton = new QPushButton();
66  abortButton->setMinimumHeight(20);
67  abortButton->setMaximumHeight(20);
68  parentTree->setItemWidget(this, 4, abortButton);
69 
70  QPixmap pix(":/icons/process-stop-7.ico");
71  QIcon icon(pix);
72 
73  abortButton->setIcon(icon);
74 
75 
76  connectSignals();
77  }
78 
79  void
80  SkillExecutionTreeWidgetItem::connectSignals()
81  {
82  connect(abortButton,
83  &QPushButton::clicked,
84  this,
86  }
87 
88  void
89  SkillExecutionTreeWidgetItem::updateButtonState(SkillStatus& skillStatus)
90  {
91  abortButton->setDisabled(skillStatus == SkillStatus::Aborted ||
92  skillStatus == SkillStatus::Failed ||
93  skillStatus == SkillStatus::Succeeded);
94  }
95 } // namespace armarx::skills::gui
armarx::skills::SkillExecutionID
Definition: SkillExecutionID.h:19
armarx::skills::SkillID::toString
std::string toString() const
Definition: SkillID.cpp:64
armarx::skills::SkillExecutionID::executorName
std::string executorName
Definition: SkillExecutionID.h:22
armarx::skills::SkillStatus::Aborted
@ Aborted
armarx::skills::SkillExecutionID::executionStartedTime
armarx::core::time::DateTime executionStartedTime
Definition: SkillExecutionID.h:23
armarx::skills::gui::SkillExecutionTreeWidgetItem::SearchRecursiveForMatch
static SkillExecutionTreeWidgetItem * SearchRecursiveForMatch(SkillExecutionTreeWidgetItem *haystack, const skills::SkillExecutionID &needle)
Definition: SkillExecutionTreeWidgetItem.cpp:6
armarx::memory
Brief description of class memory.
Definition: memory.h:39
armarx::skills::gui::SkillExecutionTreeWidgetItem::executionId
skills::SkillExecutionID executionId
Definition: SkillExecutionTreeWidgetItem.h:54
armarx::skills::gui::SkillExecutionTreeWidgetItem::abortExecution
void abortExecution()
Definition: SkillExecutionTreeWidgetItem.cpp:56
armarx::skills::gui
Definition: PeriodicUpdateWidget.cpp:11
armarx::skills::gui::SkillExecutionTreeWidgetItem
Definition: SkillExecutionTreeWidgetItem.h:28
SkillExecutionTreeWidgetItem.h
armarx::skills::gui::SkillExecutionTreeWidgetItem::updateItem
void updateItem(skills::SkillStatus &skillStatus)
Definition: SkillExecutionTreeWidgetItem.cpp:39
armarx::skills::SkillExecutionID::skillId
SkillID skillId
Definition: SkillExecutionID.h:21
armarx::skills::gui::SkillExecutionTreeWidgetItem::getExecutionId
skills::SkillExecutionID getExecutionId()
Definition: SkillExecutionTreeWidgetItem.cpp:33
armarx::core::time::DateTime::toDateTimeString
std::string toDateTimeString() const
Definition: DateTime.cpp:81
armarx::skills::SkillStatus
SkillStatus
Definition: SkillStatusUpdate.h:20
armarx::skills::SkillStatus::Succeeded
@ Succeeded
armarx::skills::SkillStatus::Failed
@ Failed