AronTreeWidgetDictInputModalController.cpp
Go to the documentation of this file.
2
4
6
8{
10 const std::string& label,
12 QTreeWidget* parent) :
13 AronTreeWidgetModal(label, item, parent)
14 {
15 widget.setupUi(this);
16
17 // set header
18 widget.groupBoxInput->setTitle(QString::fromStdString(label));
19 reset();
20
21 // connect signals
22 connect(widget.pushButtonAddElement,
23 &QPushButton::clicked,
24 this,
25 &AronTreeWidgetDictInputModalController::addEmptyElement);
26
27 connect(widget.pushButtonReset,
28 &QPushButton::clicked,
29 this,
30 &AronTreeWidgetDictInputModalController::reset);
31 connect(widget.pushButtonSubmit,
32 &QPushButton::clicked,
33 this,
34 &AronTreeWidgetDictInputModalController::submit);
35 }
36
37 void
38 AronTreeWidgetDictInputModalController::submit()
39 {
40 /*
41 for (const auto& added : addedItems)
42 {
43 item->addChild(added->copy());
44 }
45*/
46
48 }
49
50 void
51 AronTreeWidgetDictInputModalController::reset()
52 {
54
55 // reset to initial value
56 widget.treeWidgetDict->clear();
57 for (int i = 0; i < init.childCount(); ++i)
58 {
59 auto el = init.child(i);
60 widget.treeWidgetDict->addTopLevelItem(el->clone());
61 }
62 }
63
64 void
65 AronTreeWidgetDictInputModalController::addEmptyElement()
66 {
67 QString s = widget.lineEditKey->text();
68 widget.lineEditKey->setText("Enter Key");
69
70 if (widget.treeWidgetDict->findItems(s, Qt::MatchFlag::MatchExactly, 0).empty())
71 {
72 auto t = item->aronType;
74 auto ac = d->getAcceptedType();
75
76 AronTreeWidgetCreatorVisitor v(nullptr);
77 v.setTopLevelWidget(widget.treeWidgetDict);
78 aron::type::visit(v, ac);
79
80 if (v.createdQWidgetItem)
81 {
82 v.createdQWidgetItem->setText(aron_tree_widget::constantes::TREE_WIDGET_ITEM_NAME,
83 s);
84 addedItems.push_back(v.createdQWidgetItem);
85 widget.treeWidgetDict->addTopLevelItem(v.createdQWidgetItem);
86 }
87 }
88 }
89} // namespace armarx::skills::gui
static std::shared_ptr< Dict > DynamicCastAndCheck(const VariantPtr &n)
AronTreeWidgetDictInputModalController(const std::string &label, AronTreeWidgetItem *item, QTreeWidget *parent)
AronTreeWidgetModal(const std::string &label, AronTreeWidgetItem *item, QTreeWidget *parent)
void visit(VisitorImplementation &v, typename VisitorImplementation::Input &t)
The visit function.
Definition Visitor.h:39