6#include <QTreeWidgetItem>
17 QTreeWidget* contextMenuParent,
19 parentItem(i), contextMenuParent(contextMenuParent), pos(pos), index(
x)
24 AronTreeWidgetContextMenuVisitor::addDeleteAction()
32 auto aronType = castedParent->aronType->getDescriptor();
35 QMenu contextMenu(
"Context menu", contextMenuParent);
36 actions.emplace_back(
"remove element", contextMenuParent);
37 action_callbacks.push_back([
this]()
mutable { this->executeDelete(); });
42 AronTreeWidgetContextMenuVisitor::executeDelete()
44 auto* containerPtr = parentItem->QTreeWidgetItem::parent();
45 containerPtr->removeChild(parentItem);
49 if (castedContainer &&
53 for (
int i = index; i < castedContainer->childCount(); ++i)
55 std::string numberString = std::to_string(i);
56 castedContainer->child(i)->setText(0, numberString.c_str());
60 containerPtr->setText(1, numElemsText);
62 auto currFont = castedContainer->font(1);
63 currFont.setItalic(
true);
64 castedContainer->setFont(1, currFont);
76 armarx::AronTreeWidgetContextMenuVisitor::addAddAction()
78 actions.emplace_back(
"Add element", contextMenuParent);
79 action_callbacks.push_back([
this]()
mutable { this->executeAddElement(); });
83 AronTreeWidgetContextMenuVisitor::executeAddElement()
85 AronTreeWidgetCreatorVisitor creator(parentItem);
88 if (!creator.createdQWidgetItem)
90 throw std::runtime_error(
"Creation of TreeElementChild failed unexpectedly");
96 if (castedContainer &&
101 castedContainer->setText(1, numElemsText);
103 auto currFont = castedContainer->font(1);
104 currFont.setItalic(
true);
105 castedContainer->setFont(1, currFont);
210 ARMARX_WARNING <<
"Tried to open Context menu on unknown aron type";
216 QMenu menu(
"Context Menu", contextMenuParent);
217 for (
auto& el : actions)
221 auto* chosenAction = menu.exec(contextMenuParent->mapToGlobal(pos));
229 auto it = actions.begin();
231 while (it != actions.end())
233 if (chosenAction == &*it)
235 action_callbacks[count]();
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
void visit(VisitorImplementation &v, typename VisitorImplementation::Input &t)
The visit function.
std::shared_ptr< class Quaternion > QuaternionPtr
std::shared_ptr< Object > ObjectPtr
std::shared_ptr< class Double > DoublePtr
std::shared_ptr< class Matrix > MatrixPtr
std::shared_ptr< class Image > ImagePtr
std::shared_ptr< class Long > LongPtr
std::shared_ptr< class String > StringPtr
std::shared_ptr< class PointCloud > PointCloudPtr
std::shared_ptr< class Pair > PairPtr
std::shared_ptr< class NDArray > NDArrayPtr
std::shared_ptr< class Int > IntPtr
std::shared_ptr< class Float > FloatPtr
std::shared_ptr< class Bool > BoolPtr
std::shared_ptr< class Tuple > TuplePtr
std::shared_ptr< class Dict > DictPtr
std::shared_ptr< IntEnum > IntEnumPtr
std::shared_ptr< class List > ListPtr
QString generateNumElementsText(int num)
This file offers overloads of toIce() and fromIce() functions for STL container types.
typename VisitorBase< const type::VariantPtr >::Input Input