AronTreeWidgetDictInputModalController.cpp
Go to the documentation of this file.
2 
4 
5 #include "../../visitors/AronTreeWidgetCreator.h"
6 
7 namespace armarx::skills::gui
8 {
10  const std::string& label,
11  AronTreeWidgetItem* item,
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
armarx::skills::gui::AronTreeWidgetDictInputModalController::AronTreeWidgetDictInputModalController
AronTreeWidgetDictInputModalController(const std::string &label, AronTreeWidgetItem *item, QTreeWidget *parent)
Definition: AronTreeWidgetDictInputModalController.cpp:9
All.h
armarx::skills::gui::aron_tree_widget::constantes::TREE_WIDGET_ITEM_NAME
const int TREE_WIDGET_ITEM_NAME
Definition: Data.h:7
armarx::skills::gui::AronTreeWidgetItem::aronType
aron::type::VariantPtr aronType
Definition: AronTreeWidgetItem.h:30
AronTreeWidgetDictInputModalController.h
armarx::skills::gui
Definition: PeriodicUpdateWidget.cpp:11
armarx::skills::gui::AronTreeWidgetModal::submit
virtual void submit()
Definition: AronTreeWidgetModal.h:50
armarx::skills::gui::AronTreeWidgetModal::reset
virtual void reset()
Definition: AronTreeWidgetModal.h:30
armarx::skills::gui::AronTreeWidgetModal::item
AronTreeWidgetItem * item
Definition: AronTreeWidgetModal.h:57
armarx::skills::gui::AronTreeWidgetModal
Definition: AronTreeWidgetModal.h:18
armarx::ctrlutil::v
double v(double t, double v0, double a0, double j)
Definition: CtrlUtil.h:39
armarx::aron::type::detail::SpecializedVariantBase< type::dto::Dict, Dict >::DynamicCastAndCheck
static std::shared_ptr< Dict > DynamicCastAndCheck(const VariantPtr &n)
Definition: SpecializedVariant.h:124
armarx::aron::type::visit
void visit(VisitorImplementation &v, typename VisitorImplementation::Input &t)
The visit function.
Definition: Visitor.h:42
armarx::skills::gui::AronTreeWidgetItem
Definition: AronTreeWidgetItem.h:19
armarx::skills::gui::AronTreeWidgetModal::init
AronTreeWidgetItem init
Definition: AronTreeWidgetModal.h:56
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33