From a6b86fc40dddf212f4e71821d6156f298939c7ca Mon Sep 17 00:00:00 2001 From: jfa Date: Tue, 20 May 2008 07:38:50 +0000 Subject: [PATCH] NPAL19658: Deletion problem. Invalid actions were called by shortcuts. --- src/GEOMGUI/GEOM_msg_en.po | 8 +++--- src/GEOMGUI/GeometryGUI.cxx | 12 ++++++--- src/GEOMToolsGUI/GEOMToolsGUI_1.cxx | 38 +++++++++++++++++++---------- 3 files changed, 37 insertions(+), 21 deletions(-) diff --git a/src/GEOMGUI/GEOM_msg_en.po b/src/GEOMGUI/GEOM_msg_en.po index b82b694b6..d234b7340 100644 --- a/src/GEOMGUI/GEOM_msg_en.po +++ b/src/GEOMGUI/GEOM_msg_en.po @@ -245,6 +245,10 @@ msgstr "Warning" msgid "GEOM_REALLY_DELETE" msgstr "Do you really want to delete this %1 object(s):" +#: GEOMToolsGUI_1.cxx +msgid "GEOM_WRN_NO_APPROPRIATE_SELECTION" +msgstr "No appropriate objects selected" + # #============================================================================== # @@ -661,10 +665,6 @@ msgstr "Planar face" msgid "GEOM_POLYGON" msgstr "Polygon" -#Kind of Shape -msgid "GEOM_POLYGON" -msgstr "Polygon" - #Kind of Shape msgid "GEOM_NORMAL" msgstr "Normal direction" diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index b2351ada9..6061c3b79 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -1230,8 +1230,10 @@ bool GeometryGUI::activateModule( SUIT_Study* study ) // Reset actions accelerator keys //action(111)->setAccel(QKeySequence(CTRL + Key_I)); // Import //action(121)->setAccel(QKeySequence(CTRL + Key_E)); // Export - action(111)->setEnabled(true); // Import - action(121)->setEnabled(true); // Export + action(111)->setEnabled(true); // Import: CTRL + Key_I + action(121)->setEnabled(true); // Export: CTRL + Key_E + action( 33)->setEnabled(true); // Delete: Key_Delete + action(901)->setEnabled(true); // Rename: Key_F2 GUIMap::Iterator it; for ( it = myGUIMap.begin(); it != myGUIMap.end(); ++it ) @@ -1290,8 +1292,10 @@ bool GeometryGUI::deactivateModule( SUIT_Study* study ) // Unset actions accelerator keys //action(111)->setAccel(QKeySequence()); // Import //action(121)->setAccel(QKeySequence()); // Export - action(111)->setEnabled(false); // Import - action(121)->setEnabled(false); // Export + action(111)->setEnabled(false); // Import: CTRL + Key_I + action(121)->setEnabled(false); // Export: CTRL + Key_E + action( 33)->setEnabled(false); // Delete: Key_Delete + action(901)->setEnabled(false); // Rename: Key_F2 myOCCSelectors.clear(); getApp()->selectionMgr()->setEnabled( true, OCCViewer_Viewer::Type() ); diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx index 139630563..ba88ac9e0 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -177,7 +177,8 @@ void GEOMToolsGUI::OnSettingsStep() void GEOMToolsGUI::OnRename() { SALOME_ListIO selected; - SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + SalomeApp_Application* app = + dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); if ( app ) { LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); SalomeApp_Study* appStudy = dynamic_cast( app->activeStudy() ); @@ -195,28 +196,39 @@ void GEOMToolsGUI::OnRename() return; } + bool isAny = false; // is there any appropriate object selected for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { Handle(SALOME_InteractiveObject) IObject = It.Value(); _PTR(SObject) obj ( aStudy->FindObjectID(IObject->getEntry()) ); _PTR(GenericAttribute) anAttr; if ( obj ) { - if( obj->FindAttribute(anAttr, "AttributeName") ) { + if ( obj->FindAttribute(anAttr, "AttributeName") ) { _PTR(AttributeName) aName (anAttr); - QString newName = LightApp_NameDlg::getName( app->desktop(), aName->Value().c_str() ); - if ( !newName.isEmpty() ) { - aName->SetValue( newName.latin1() ); // rename the SObject - IObject->setName( newName.latin1() );// rename the InteractiveObject - // Rename the corresponding GEOM_Object - GEOM::GEOM_Object_var anObj = GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj)); - if (!CORBA::is_nil( anObj )) - anObj->SetName( newName.latin1() ); - (dynamic_cast(app->activeModule()))->updateObjBrowser( false ); - } + GEOM::GEOM_Object_var anObj = + GEOM::GEOM_Object::_narrow(GeometryGUI::ClientSObjectToObject(obj)); + if (!CORBA::is_nil(anObj)) { + isAny = true; + QString newName = LightApp_NameDlg::getName( app->desktop(), aName->Value().c_str() ); + if (!newName.isEmpty()) { + aName->SetValue( newName.latin1() ); // rename the SObject + IObject->setName( newName.latin1() );// rename the InteractiveObject + anObj->SetName( newName.latin1() ); // Rename the corresponding GEOM_Object + (dynamic_cast(app->activeModule()))->updateObjBrowser( false ); + } + } // if ( anObj ) } // if ( name attribute ) } // if ( obj ) } // iterator + + if (!isAny) { + SUIT_MessageBox::warn1(app->desktop(), + QObject::tr("WRN_WARNING"), + QObject::tr("GEOM_WRN_NO_APPROPRIATE_SELECTION"), + QObject::tr("BUT_OK")); + return; + } } } } -- 2.39.2