Skip to content

Commit 26eca61

Browse files
committed
Use same placement of modules and gates when duplicating a view
1 parent bc7ec53 commit 26eca61

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

plugins/gui/src/context_manager_widget/context_manager_widget.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,8 +263,18 @@ namespace hal
263263

264264
UserActionCompound* act = new UserActionCompound;
265265
act->setUseCreatedObject();
266+
267+
// TODO: check whether name + " (Copy)" is already in use
266268
act->addAction(new ActionCreateObject(UserActionObjectType::ContextView,clicked_context->name() + " (Copy)"));
267-
act->addAction(new ActionAddItemsToObject(clicked_context->modules(),clicked_context->gates()));
269+
270+
ActionAddItemsToObject* actAddItems = new ActionAddItemsToObject(clicked_context->modules(),clicked_context->gates());
271+
GridPlacement plc;
272+
QMap<Node, QPoint> contextNodeMap = clicked_context->getLayouter()->nodeToPositionMap();
273+
for (auto it = contextNodeMap.begin(); it != contextNodeMap.end(); it++)
274+
plc.insert(it.key(), it.value());
275+
actAddItems->setPlacementHint(plc);
276+
act->addAction(actAddItems);
277+
268278
act->exec();
269279
}
270280

0 commit comments

Comments
 (0)