From 3e2dacc5ae3d561000e39ea48a065067ca34764d Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 22 Oct 2015 17:06:30 +0300 Subject: [PATCH] Fix of Delete operation bug and Rename improvement --- src/XGUI/XGUI_ContextMenuMgr.cpp | 9 +++++---- src/XGUI/XGUI_ObjectsBrowser.cpp | 6 +++++- src/XGUI/XGUI_Workshop.cpp | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/XGUI/XGUI_ContextMenuMgr.cpp b/src/XGUI/XGUI_ContextMenuMgr.cpp index 190f2ef3d..b90e3e085 100644 --- a/src/XGUI/XGUI_ContextMenuMgr.cpp +++ b/src/XGUI/XGUI_ContextMenuMgr.cpp @@ -495,9 +495,10 @@ QStringList XGUI_ContextMenuMgr::actionObjectGroups(const QString& theName) 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(); } diff --git a/src/XGUI/XGUI_ObjectsBrowser.cpp b/src/XGUI/XGUI_ObjectsBrowser.cpp index 2df67c449..a083bc3db 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.cpp +++ b/src/XGUI/XGUI_ObjectsBrowser.cpp @@ -101,8 +101,12 @@ void XGUI_DataTree::commitData(QWidget* theEditor) 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; diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index b46d8d692..184cafe05 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -1116,9 +1116,9 @@ void XGUI_Workshop::deleteObjects() 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(); -- 2.39.2