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

Added guards to check for validity of execution selection

parent 74eeb224
No related branches found
No related tags found
1 merge request!406Refactor skill memory GUI
...@@ -45,12 +45,16 @@ namespace armarx::skills::gui ...@@ -45,12 +45,16 @@ namespace armarx::skills::gui
void void
SkillExecutionTreeWidget::stopSelectedExecution() SkillExecutionTreeWidget::stopSelectedExecution()
{ {
if (!selectionValid())
return;
memory->stopExecution(this->selectedExecution.skillExecutionId); memory->stopExecution(this->selectedExecution.skillExecutionId);
} }
void void
SkillExecutionTreeWidget::rerunSkillWithSimilarParams() SkillExecutionTreeWidget::rerunSkillWithSimilarParams()
{ {
if (!selectionValid())
return;
// we don't want to hold state in the gui, so we need to get the parameters from memory: // 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; skills::SkillExecutionID currentExecutionId = this->selectedExecution.skillExecutionId;
auto update = memory->getLatestUpdate(); auto update = memory->getLatestUpdate();
...@@ -67,6 +71,12 @@ namespace armarx::skills::gui ...@@ -67,6 +71,12 @@ namespace armarx::skills::gui
this->memory->startExecutionWithParams(currentExecutionId.skillId, params); this->memory->startExecutionWithParams(currentExecutionId.skillId, params);
} }
inline bool
SkillExecutionTreeWidget::selectionValid()
{
return selectedExecution.skillExecutionId.skillId.skillName != skills::SkillID::UNKNOWN;
}
void void
SkillExecutionTreeWidget::stopAllExecutions() SkillExecutionTreeWidget::stopAllExecutions()
{ {
...@@ -83,6 +93,14 @@ namespace armarx::skills::gui ...@@ -83,6 +93,14 @@ namespace armarx::skills::gui
} }
} }
void
SkillExecutionTreeWidget::executionSelectionChanged(QTreeWidgetItem* current,
QTreeWidgetItem* previous)
{
// update internal state
this->selectedExecution.skillExecutionId = *current;
}
void void
SkillExecutionTreeWidget::refresh() SkillExecutionTreeWidget::refresh()
{ {
......
...@@ -57,6 +57,12 @@ namespace armarx::skills::gui ...@@ -57,6 +57,12 @@ namespace armarx::skills::gui
private: private:
void setupUi(); void setupUi();
/**
* @brief Checks the validity of the selected item at run time.
* @return the validity.
*/
bool selectionValid();
SelectedExecution selectedExecution; SelectedExecution selectedExecution;
}; };
} // 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