7 #include "../ColorPalettes.h"
8 #include "../visitors/AronTreeWidgetConverter.h"
13 QTreeWidgetItem* currentItem) :
16 auto names = enumPtr->getAcceptedValueNames();
17 auto outerLayout =
new QHBoxLayout();
18 outerLayout->setContentsMargins(0, 0, 0, 0);
19 innerWidget =
new QComboBox();
20 outerLayout->addWidget(innerWidget);
22 for (
const auto& n :
names)
24 innerWidget->addItem(n.c_str());
26 innerWidget->setInsertPolicy(QComboBox::NoInsert);
27 innerWidget->setEditable(
true);
28 innerWidget->setCurrentIndex(0);
30 setLayout(outerLayout);
32 SIGNAL(currentTextChanged(
const QString&)),
34 SLOT(textChanged(
const QString&))));
64 innerWidget->setEditText(text);
65 highlightUnparsableEntries();
71 return innerWidget->currentText();
74 std::pair<bool, aron::data::IntPtr>
77 auto crAron = std::make_shared<aron::data::Int>(element_type->getPath());
80 auto valueMap = element_type->getAcceptedValueMap();
81 std::string toParse =
getText().toStdString();
83 auto searchRes = valueMap.find(toParse);
84 if (searchRes != valueMap.end())
86 crAron->setValue(searchRes->second);
87 return {
true, crAron};
90 auto accVals = element_type->getAcceptedValues();
94 res = simox::alg::to_<int>(toParse);
96 catch (
const simox::error::SimoxError& err)
98 ARMARX_VERBOSE <<
"Failed to parse IntEnum: Could not convert \'" << toParse
99 <<
"\' to an int. It also was not one of the accepted strings.";
100 return {
false,
nullptr};
102 if (std::find(accVals.begin(), accVals.end(), res) != accVals.end())
105 crAron->setValue(res);
110 <<
"but this int is not part of the accepted values.";
111 return {
false,
nullptr};
113 return {
true, crAron};
117 IntEnumWidget::highlightUnparsableEntries()
131 IntEnumWidget::textChanged(
const QString&)
134 highlightUnparsableEntries();