From: vsv Date: Thu, 22 Oct 2015 14:06:30 +0000 (+0300) Subject: Fix of Delete operation bug and Rename improvement X-Git-Tag: V_2.0.0_alfa1~72 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3e2dacc5ae3d561000e39ea48a065067ca34764d;p=modules%2Fshaper.git Fix of Delete operation bug and Rename improvement --- 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();