From 62880cac531b88635c2064419bd9e1fb29b6b512 Mon Sep 17 00:00:00 2001 From: srn Date: Thu, 23 Jun 2005 09:43:27 +0000 Subject: [PATCH] BugId: IPAL8989, implemented Copy/Paste --- src/SalomeApp/SalomeApp_Application.cxx | 83 ++++++++++++++++--------- 1 file changed, 55 insertions(+), 28 deletions(-) diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 968a8f8d7..61a264035 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -534,27 +534,56 @@ void SalomeApp_Application::onSelection() void SalomeApp_Application::onCopy() { + SALOME_ListIO list; + SalomeApp_SelectionMgr* mgr = selectionMgr(); + mgr->selectedObjects(list); + + SalomeApp_Study* study = dynamic_cast(activeStudy()); + if(study == NULL) return; + + _PTR(Study) stdDS = study->studyDS(); + if(!stdDS) return; + + SALOME_ListIteratorOfListIO it( list ); + if(it.More()) + { + _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry()); + try { + studyMgr()->Copy(so); + onSelectionChanged(); + } + catch(...) { + } + } } void SalomeApp_Application::onPaste() { + SALOME_ListIO list; + SalomeApp_SelectionMgr* mgr = selectionMgr(); + mgr->selectedObjects(list); + + SalomeApp_Study* study = dynamic_cast(activeStudy()); + if(study == NULL) return; + + _PTR(Study) stdDS = study->studyDS(); + if(!stdDS) return; + + SALOME_ListIteratorOfListIO it( list ); + if(it.More()) + { + _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry()); + try { + studyMgr()->Paste(so); + updateObjectBrowser( true ); + } + catch(...) { + } + } } void SalomeApp_Application::onSelectionChanged() { - /* - SalomeApp_Module* module = dynamic_cast(activeModule()); - if(module == NULL) return; - - QString ior = module->engineIOR(); - if(ior.length() < 5) return; //Not a real CORBA IOR - CORBA::Object_var obj = orb()->string_to_object(ior.latin1()); - if(CORBA::is_nil(obj)) return; - - SALOMEDS::Driver_var engine = SALOMEDS::Driver::_narrow(obj); - if(CORBA::is_nil(engine)) return; -*/ - SALOME_ListIO list; SalomeApp_SelectionMgr* mgr = selectionMgr(); mgr->selectedObjects(list); @@ -566,28 +595,26 @@ void SalomeApp_Application::onSelectionChanged() if(!stdDS) return; QAction* qaction; - //Varibales isEnabledCopy and isEnabledPaste are used for multi selection. - bool isEnabledCopy = true; - bool isEnabledPaste = true; - for ( SALOME_ListIteratorOfListIO it( list ); it.More() && (isEnabledCopy || isEnabledPaste); it.Next() ) + SALOME_ListIteratorOfListIO it( list ); + if(it.More() && list.Extent() == 1) { _PTR(SObject) so = stdDS->FindObjectID(it.Value()->getEntry()); qaction = action(EditCopyId); - if( isEnabledCopy && studyMgr()->CanCopy(so) ) qaction->setEnabled(true); - else { - isEnabledCopy = false; - qaction->setEnabled(false); - } - + if(studyMgr()->CanCopy(so) ) qaction->setEnabled(true); + else qaction->setEnabled(false); + qaction = action(EditPasteId); - if( isEnabledPaste && studyMgr()->CanPaste(so) ) qaction->setEnabled(true); - else { - isEnabledPaste = false; - qaction->setEnabled(false); - } + if( studyMgr()->CanPaste(so) ) qaction->setEnabled(true); + else qaction->setEnabled(false); } + else { + qaction = action(EditCopyId); + qaction->setEnabled(false); + qaction = action(EditPasteId); + qaction->setEnabled(false); + } } void SalomeApp_Application::onRefresh() -- 2.39.2