AronTreeWidgetDictInputModalController.cpp
Go to the documentation of this file.
2 
4 
5 #include "../../visitors/AronTreeWidgetCreator.h"
6 
7 namespace armarx
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  for (const auto& added : addedItems)
41  {
42  //item->addChild(added->copy());
43  }
44 
46  }
47 
48  void
49  AronTreeWidgetDictInputModalController::reset()
50  {
52 
53  // reset to initial value
54  widget.treeWidgetDict->clear();
55  for (int i = 0; i < init.childCount(); ++i)
56  {
57  auto el = init.child(i);
58  widget.treeWidgetDict->addTopLevelItem(el->clone());
59  }
60  }
61 
62  void
63  AronTreeWidgetDictInputModalController::addEmptyElement()
64  {
65  QString s = widget.lineEditKey->text();
66  widget.lineEditKey->setText("Enter Key");
67 
68  if (widget.treeWidgetDict->findItems(s, Qt::MatchFlag::MatchExactly, 0).empty())
69  {
70  auto t = item->aronType;
72  auto ac = d->getAcceptedType();
73 
74  AronTreeWidgetCreatorVisitor v(nullptr);
75  v.setTopLevelWidget(widget.treeWidgetDict);
76  aron::type::visit(v, ac);
77 
78  if (v.createdQWidgetItem)
79  {
80  v.createdQWidgetItem->setText(aron_tree_widget::constantes::TREE_WIDGET_ITEM_NAME,
81  s);
82  addedItems.push_back(v.createdQWidgetItem);
83  widget.treeWidgetDict->addTopLevelItem(v.createdQWidgetItem);
84  }
85  }
86  }
87 } // namespace armarx
AronTreeWidgetDictInputModalController.h
armarx::AronTreeWidgetModal::reset
virtual void reset()
Definition: AronTreeWidgetModal.h:30
armarx::AronTreeWidgetItem
Definition: AronTreeWidgetItem.h:19
armarx::AronTreeWidgetModal::submit
virtual void submit()
Definition: AronTreeWidgetModal.h:50
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:56
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:119
armarx::aron::type::visit
void visit(VisitorImplementation &v, typename VisitorImplementation::Input &t)
The visit function.
Definition: Visitor.h:39
armarx::aron_tree_widget::constantes::TREE_WIDGET_ITEM_NAME
const int TREE_WIDGET_ITEM_NAME
Definition: Data.h:7
armarx::AronTreeWidgetModal
Definition: AronTreeWidgetModal.h:18
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:27
armarx::AronTreeWidgetItem::aronType
aron::type::VariantPtr aronType
Definition: AronTreeWidgetItem.h:30
armarx::AronTreeWidgetModal::item
AronTreeWidgetItem * item
Definition: AronTreeWidgetModal.h:57