Fix component renaming

master
Jeremy Hu 2020-01-18 17:43:24 +09:30
parent a7f22efd1b
commit 9ca0102b52
2 changed files with 16 additions and 0 deletions

View File

@ -772,6 +772,10 @@ Tips:
<source>Iteration</source> <source>Iteration</source>
<translation></translation> <translation></translation>
</message> </message>
<message>
<source>Rename</source>
<translation></translation>
</message>
</context> </context>
<context> <context>
<name>PartWidget</name> <name>PartWidget</name>

View File

@ -767,6 +767,7 @@ void PartTreeWidget::showContextMenu(const QPoint &pos, bool shorted)
contextMenu.addSeparator(); contextMenu.addSeparator();
std::vector<QAction *> groupsActions; std::vector<QAction *> groupsActions;
QAction renameAction(tr("Rename"), this);
QAction deleteAction(tr("Delete"), this); QAction deleteAction(tr("Delete"), this);
QAction moveToTopAction(tr("Top"), this); QAction moveToTopAction(tr("Top"), this);
QAction moveUpAction(tr("Up"), this); QAction moveUpAction(tr("Up"), this);
@ -845,6 +846,17 @@ void PartTreeWidget::showContextMenu(const QPoint &pos, bool shorted)
}; };
addChildGroupsFunc(QUuid(), 0); addChildGroupsFunc(QUuid(), 0);
if (nullptr != component && nullptr == part) {
auto componentId = component->id;
connect(&renameAction, &QAction::triggered, [=]() {
auto findItem = m_componentItemMap.find(componentId);
if (findItem != m_componentItemMap.end()) {
editItem(findItem->second);
}
});
contextMenu.addAction(&renameAction);
}
contextMenu.addSeparator(); contextMenu.addSeparator();
deleteAction.setIcon(Theme::awesome()->icon(fa::trash)); deleteAction.setIcon(Theme::awesome()->icon(fa::trash));