Skip to content
Snippets Groups Projects
Commit e880df06 authored by Rainer Kartmann's avatar Rainer Kartmann
Browse files

Add action to copy selected instance ID

parent f5fee209
No related branches found
No related tags found
2 merge requests!171Periodic merge of armem/dev into master,!170ArMem Viewer: Resolve Memory IDs
......@@ -222,7 +222,7 @@ namespace armarx::armem::gui::instance
}
aron::Path InstanceView::getElementPath(QTreeWidgetItem* item) const
aron::Path InstanceView::getElementPath(const QTreeWidgetItem* item) const
{
QStringList qpath = item->data(int(Columns::KEY), Qt::UserRole).toStringList();
aron::Path path = deserializePath(qpath);
......@@ -232,15 +232,26 @@ namespace armarx::armem::gui::instance
void InstanceView::prepareTreeContextMenu(const QPoint& pos)
{
QTreeWidgetItem* item = tree->itemAt(pos);
if (item == nullptr || item->parent() == nullptr)
const QTreeWidgetItem* item = tree->itemAt(pos);
if (item == nullptr)
{
// No item or top level item => no context menu.
return;
return; // No item => no context menu.
}
QMenu menu(this);
if (item == this->treeItemInstanceID && currentInstance.has_value())
{
if (QAction* action = makeActionCopyMemoryID(currentInstance->id()))
{
menu.addAction(action);
}
}
else if (item->parent() == nullptr)
{
return; // Other top level item => no context menu.
}
// Type descriptor based actions
aron::type::Descriptor type = static_cast<aron::type::Descriptor>(item->data(int(Columns::TYPE), Qt::UserRole).toInt());
switch (type)
......
......@@ -68,7 +68,7 @@ namespace armarx::armem::gui::instance
void showErrorMessage(const std::string& message);
aron::Path getElementPath(QTreeWidgetItem* item) const;
aron::Path getElementPath(const QTreeWidgetItem* item) const;
std::optional<MemoryID> getElementMemoryID(const aron::Path& elementPath);
QAction* makeActionResolveMemoryID(const MemoryID& id);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment