5 #include <QApplication>
14 #include <QTreeWidget>
15 #include <QVBoxLayout>
17 #include <SimoxUtility/algorithm/string.h>
24 #include <RobotAPI/libraries/armem/aron/MemoryID.aron.generated.h>
48 treeItemMetadata =
new QTreeWidgetItem({
"Metadata"});
49 treeItemMetadata->addChild(
new QTreeWidgetItem({
"Confidence"}));
50 treeItemMetadata->addChild(
new QTreeWidgetItem({
"Time Created"}));
51 treeItemMetadata->addChild(
new QTreeWidgetItem({
"Time Sent"}));
52 treeItemMetadata->addChild(
new QTreeWidgetItem({
"Time Arrived"}));
53 treeItemMetadata->addChild(
new QTreeWidgetItem({
"Time Last Accessed"}));
55 QList<QTreeWidgetItem*> items = {treeItemInstanceID, treeItemMetadata};
56 tree->insertTopLevelItems(0, items);
58 treeItemInstanceID->setExpanded(
true);
59 treeItemMetadata->setExpanded(
false);
68 instance = &
memory.getInstance(
id);
71 aronType =
memory.getProviderSegment(
id).aronType();
80 update(*instance, aronType);
86 currentInstance = instance;
95 updateInstanceID(currentInstance->id());
96 updateMetaData(currentInstance->metadata());
104 void InstanceView::updateInstanceID(
const MemoryID&
id)
111 std::vector<std::string> items =
119 ARMARX_CHECK_EQUAL(
static_cast<size_t>(treeItemMetadata->childCount()), items.size());
121 for (
const std::string& item : items)
123 treeItemMetadata->child(i++)->setText(
int(
Columns::VALUE), QString::fromStdString(item));
127 QMenu* InstanceView::buildActionsMenu(
const QPoint& pos)
131 const QTreeWidgetItem* item =
tree->itemAt(pos);
132 if (item == this->treeItemInstanceID && currentInstance.has_value())
136 parentMenu->addAction(action);
143 void InstanceView::prepareTreeContextMenu(
const QPoint& pos)
145 if (currentInstance.has_value())
147 auto* menu = buildActionsMenu(pos);
150 menu->actions().isEmpty() ?
nullptr : menu);
158 return currentInstance->data();