AronTreeWidgetDictInputModalController.cpp
Go to the documentation of this file.
2 
4 
5 #include "../../visitors/AronTreeWidgetCreator.h"
6 
7 namespace armarx
8 {
10  AronTreeWidgetModal(label, item, parent)
11  {
12  widget.setupUi(this);
13 
14  // set header
15  widget.groupBoxInput->setTitle(QString::fromStdString(label));
16  reset();
17 
18  // connect signals
19  connect(widget.pushButtonAddElement, &QPushButton::clicked,
20  this, &AronTreeWidgetDictInputModalController::addEmptyElement);
21 
22  connect(widget.pushButtonReset, &QPushButton::clicked,
23  this, &AronTreeWidgetDictInputModalController::reset);
24  connect(widget.pushButtonSubmit, &QPushButton::clicked,
25  this, &AronTreeWidgetDictInputModalController::submit);
26 
27  }
28 
29  void AronTreeWidgetDictInputModalController::submit()
30  {
31  for (const auto& added : addedItems)
32  {
33  //item->addChild(added->copy());
34  }
35 
37  }
38 
39  void AronTreeWidgetDictInputModalController::reset()
40  {
42 
43  // reset to initial value
44  widget.treeWidgetDict->clear();
45  for (int i = 0; i < init.childCount(); ++i)
46  {
47  auto el = init.child(i);
48  widget.treeWidgetDict->addTopLevelItem(el->clone());
49  }
50  }
51 
52  void AronTreeWidgetDictInputModalController::addEmptyElement()
53  {
54  QString s = widget.lineEditKey->text();
55  widget.lineEditKey->setText("Enter Key");
56 
57  if (widget.treeWidgetDict->findItems(s, Qt::MatchFlag::MatchExactly, 0).empty())
58  {
59  auto t = item->aronType;
61  auto ac = d->getAcceptedType();
62 
63  AronTreeWidgetCreatorVisitor v(nullptr);
64  v.setTopLevelWidget(widget.treeWidgetDict);
65  aron::type::visit(v, ac);
66 
67  if (v.createdQWidgetItem)
68  {
69  v.createdQWidgetItem->setText(aron_tree_widget::constantes::TREE_WIDGET_ITEM_NAME,
70  s);
71  addedItems.push_back(v.createdQWidgetItem);
72  widget.treeWidgetDict->addTopLevelItem(v.createdQWidgetItem);
73  }
74  }
75  }
76 }
AronTreeWidgetDictInputModalController.h
armarx::AronTreeWidgetModal::reset
virtual void reset()
Definition: AronTreeWidgetModal.h:26
armarx::AronTreeWidgetItem
Definition: AronTreeWidgetItem.h:19
armarx::AronTreeWidgetModal::submit
virtual void submit()
Definition: AronTreeWidgetModal.h:41
All.h
armarx::AronTreeWidgetDictInputModalController::AronTreeWidgetDictInputModalController
AronTreeWidgetDictInputModalController(const std::string &label, AronTreeWidgetItem *item, QTreeWidget *parent)
Definition: AronTreeWidgetDictInputModalController.cpp:9
armarx::AronTreeWidgetModal::init
AronTreeWidgetItem init
Definition: AronTreeWidgetModal.h:48
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::aron_tree_widget::constantes::TREE_WIDGET_ITEM_NAME
const int TREE_WIDGET_ITEM_NAME
Definition: Data.h:7
armarx::AronTreeWidgetModal
Definition: AronTreeWidgetModal.h:17
armarx::ctrlutil::s
double s(double t, double s0, double v0, double a0, double j)
Definition: CtrlUtil.h:33
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::AronTreeWidgetItem::aronType
aron::type::VariantPtr aronType
Definition: AronTreeWidgetItem.h:30
armarx::AronTreeWidgetModal::item
AronTreeWidgetItem * item
Definition: AronTreeWidgetModal.h:49