Skip to content
Snippets Groups Projects
Commit 77a5172a authored by Peter Albrecht's avatar Peter Albrecht
Browse files

Added abort button to execution items

parent 7f5b82c6
No related branches found
No related tags found
1 merge request!406Refactor skill memory GUI
Pipeline #17257 passed
...@@ -90,11 +90,13 @@ namespace armarx::skills::gui ...@@ -90,11 +90,13 @@ namespace armarx::skills::gui
void void
SkillExecutionTreeWidget::setupUi() SkillExecutionTreeWidget::setupUi()
{ {
this->setColumnCount(4); this->setColumnCount(6);
this->setContextMenuPolicy(Qt::CustomContextMenu); this->setContextMenuPolicy(Qt::CustomContextMenu);
QTreeWidgetItem* ___qtreewidgetitem = this->headerItem(); QTreeWidgetItem* ___qtreewidgetitem = this->headerItem();
___qtreewidgetitem->setText(5, "");
___qtreewidgetitem->setText(4, "");
___qtreewidgetitem->setText(3, "Status"); ___qtreewidgetitem->setText(3, "Status");
___qtreewidgetitem->setText(2, "SkillID"); ___qtreewidgetitem->setText(2, "SkillID");
___qtreewidgetitem->setText(1, "Executor"); ___qtreewidgetitem->setText(1, "Executor");
...@@ -170,11 +172,9 @@ namespace armarx::skills::gui ...@@ -170,11 +172,9 @@ namespace armarx::skills::gui
if (!found) if (!found)
{ {
// TODO: Sort to executor! // TODO: Sort to executor!
auto item = new SkillExecutionTreeWidgetItem(executionId, memory); auto item = new SkillExecutionTreeWidgetItem(executionId, memory, this);
item->updateItem(statusUpdate.status); item->updateItem(statusUpdate.status);
this->insertTopLevelItem(0, item);
} }
} }
} }
......
...@@ -49,10 +49,38 @@ namespace armarx::skills::gui ...@@ -49,10 +49,38 @@ namespace armarx::skills::gui
this->setText(3, QString::fromStdString(i.second)); this->setText(3, QString::fromStdString(i.second));
} }
} }
updateButtonState(skillStatus);
} }
void SkillExecutionTreeWidgetItem::setupUi() void
SkillExecutionTreeWidgetItem::abortExecution()
{
memory->stopExecution(executionId);
}
void
SkillExecutionTreeWidgetItem::setupUi()
{
parentTree->insertTopLevelItem(0, this);
abortButton = new QPushButton("Abort");
parentTree->setItemWidget(this, 4, abortButton);
connectSignals();
}
void
SkillExecutionTreeWidgetItem::connectSignals()
{ {
connect(abortButton,
&QPushButton::clicked,
this,
&SkillExecutionTreeWidgetItem::abortExecution);
}
void
SkillExecutionTreeWidgetItem::updateButtonState(SkillStatus& skillStatus)
{
abortButton->setDisabled(skillStatus == SkillStatus::Aborted ||
skillStatus == SkillStatus::Failed ||
skillStatus == SkillStatus::Succeeded);
} }
} // namespace armarx::skills::gui } // namespace armarx::skills::gui
#ifndef SKILLEXECUTIONTREEWIDGETITEM_H #ifndef SKILLEXECUTIONTREEWIDGETITEM_H
#define SKILLEXECUTIONTREEWIDGETITEM_H #define SKILLEXECUTIONTREEWIDGETITEM_H
#include <QPushButton>
#include <QTreeWidgetItem> #include <QTreeWidgetItem>
#include "RobotAPI/libraries/skills_gui/executions/SkillExecutionTreeWidget.h"
#include <RobotAPI/libraries/skills/core/SkillExecutionID.h> #include <RobotAPI/libraries/skills/core/SkillExecutionID.h>
#include <RobotAPI/libraries/skills/core/SkillStatusUpdate.h> #include <RobotAPI/libraries/skills/core/SkillStatusUpdate.h>
...@@ -23,17 +25,21 @@ namespace armarx::skills::gui ...@@ -23,17 +25,21 @@ namespace armarx::skills::gui
{skills::SkillStatus::Failed, "Failed"}, {skills::SkillStatus::Failed, "Failed"},
{skills::SkillStatus::Succeeded, "Succeeded"}}; {skills::SkillStatus::Succeeded, "Succeeded"}};
class SkillExecutionTreeWidgetItem : public QTreeWidgetItem, public MemoryCommunicatorBase class SkillExecutionTreeWidgetItem :
public QObject,
public QTreeWidgetItem,
public MemoryCommunicatorBase
{ {
Q_OBJECT
public: public:
SkillExecutionTreeWidgetItem() = delete; SkillExecutionTreeWidgetItem() = delete;
// After constructing an item, it must be manually inserted into the tree!
SkillExecutionTreeWidgetItem(const skills::SkillExecutionID& id, SkillExecutionTreeWidgetItem(const skills::SkillExecutionID& id,
std::shared_ptr<SkillManagerWrapper> _memory) : std::shared_ptr<SkillManagerWrapper> _memory,
MemoryCommunicatorBase(_memory), executionId(id) SkillExecutionTreeWidget* parent) :
MemoryCommunicatorBase(_memory), executionId(id), parentTree(parent)
{ {
setupUi() setupUi();
} }
static SkillExecutionTreeWidgetItem* static SkillExecutionTreeWidgetItem*
...@@ -47,8 +53,15 @@ namespace armarx::skills::gui ...@@ -47,8 +53,15 @@ namespace armarx::skills::gui
protected: protected:
skills::SkillExecutionID executionId; skills::SkillExecutionID executionId;
public slots:
void abortExecution();
private: private:
void setupUi(); void setupUi();
void connectSignals();
void updateButtonState(skills::SkillStatus& skillStatus);
SkillExecutionTreeWidget* parentTree = nullptr;
QPushButton* abortButton = nullptr;
}; };
} // namespace armarx::skills::gui } // namespace armarx::skills::gui
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment