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

Minor refactor

parent 25cc2a94
No related branches found
No related tags found
1 merge request!420Add documentation to skill memory gui
......@@ -14,7 +14,7 @@ namespace armarx::skills::gui
SkillExecutionTreeWidget::runContextMenu(const QPoint& pos)
{
// sanity check
ARMARX_CHECK(selectionValid());
ARMARX_CHECK(selectedExecution.valid());
QMenu* menu = new QMenu();
......@@ -48,15 +48,22 @@ namespace armarx::skills::gui
void
SkillExecutionTreeWidget::stopSelectedExecution()
{
if (!selectionValid())
if (!selectedExecution.valid())
return;
memory->stopExecution(this->selectedExecution.skillExecutionId);
}
bool
SkillExecutionTreeWidget::SelectedExecution::valid()
{
return this->skillExecutionId.skillId.skillName != skills::SkillID::UNKNOWN &&
this->skillExecutionId.executionStartedTime.isValid();
}
void
SkillExecutionTreeWidget::rerunSkillWithSimilarParams()
{
if (!selectionValid())
if (!selectedExecution.valid())
return;
// we don't want to hold state in the gui, so we need to get the parameters from memory:
skills::SkillExecutionID currentExecutionId = this->selectedExecution.skillExecutionId;
......@@ -116,12 +123,6 @@ namespace armarx::skills::gui
&SkillExecutionTreeWidget::executionSelectionChanged);
}
inline bool
SkillExecutionTreeWidget::selectionValid()
{
return selectedExecution.skillExecutionId.skillId.skillName != skills::SkillID::UNKNOWN;
}
void
SkillExecutionTreeWidget::executionSelectionChanged(QTreeWidgetItem* current,
QTreeWidgetItem* previous)
......
......@@ -10,6 +10,7 @@
namespace armarx::skills::gui
{
// cannot be declared in class -> in namespace
static const std::map<skills::SkillStatus, std::string> EXECUTION_STATUS_TO_STRING = {
// Main states
{skills::SkillStatus::Constructing, "Constructing"},
......@@ -32,6 +33,9 @@ namespace armarx::skills::gui
setupUi();
}
/**
* @brief Describes the currently selected execution in the tree.
*/
struct SelectedExecution
{
skills::SkillExecutionID skillExecutionId;
......@@ -44,12 +48,25 @@ namespace armarx::skills::gui
.executionStartedTime = armarx::core::time::DateTime::Invalid()}
{
}
/**
* @brief Checks the validity of the selected item at run time.
* @return the validity.
*/
bool valid();
};
SelectedExecution& getSelectedExecution();
public slots:
/**
* @brief Clears all state of this widget.
*/
void disconnectGui();
/**
* @brief Fetches an update from memory and applies it to this widget.
*/
void updateExecutions();
private slots:
......@@ -62,11 +79,6 @@ namespace armarx::skills::gui
void setupUi();
void connectSignals();
/**
* @brief Checks the validity of the selected item at run time.
* @return the validity.
*/
bool selectionValid();
SelectedExecution selectedExecution;
};
} // 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