void XGUI_ContextMenuMgr::onRename()
{
- ModuleBase_OperationAction* anAction = new ModuleBase_OperationAction("Rename", this);
- XGUI_OperationMgr* anOpMgr = myWorkshop->operationMgr();
- anOpMgr->startOperation(anAction);
+ QObjectPtrList anObjects = myWorkshop->selector()->selection()->selectedObjects();
+ if (!myWorkshop->abortAllOperations())
+ return;
+ // restore selection in case if dialog box was shown
+ myWorkshop->objectBrowser()->setObjectsSelected(anObjects);
myWorkshop->objectBrowser()->onEditItem();
- anOpMgr->commitOperation();
}
XGUI_DataModel* aModel = dataModel();
ObjectPtr aObj = aModel->object(aIndexList.first());
- if (XGUI_Tools::canRename(aObj, aName))
+ if (XGUI_Tools::canRename(aObj, aName)) {
+ SessionPtr aMgr = ModelAPI_Session::get();
+ aMgr->startOperation("Rename");
aObj->data()->setName(qPrintable(aName));
+ aMgr->finishOperation();
+ }
}
}
aEntrance = 0;
return;
}
+ QObjectPtrList anObjects = mySelector->selection()->selectedObjects();
if (!abortAllOperations())
return;
- QObjectPtrList anObjects = mySelector->selection()->selectedObjects();
// It is necessary to clear selection in order to avoid selection changed event during
// deletion and negative consequences connected with processing of already deleted items
mySelector->clearSelection();