From 7b13189fc8f8f25a11458ff124b2d23a30b67b9f Mon Sep 17 00:00:00 2001 From: asl Date: Wed, 7 Dec 2005 13:37:47 +0000 Subject: [PATCH] Fix for "delete invalid reference" popup item rule and functionality. --- src/SalomeApp/SalomeApp_Application.cxx | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 502ab9bd2..e77188458 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -389,7 +389,7 @@ void SalomeApp_Application::onDeleteInvalidReferences() { SALOME_ListIO aList; LightApp_SelectionMgr* mgr = selectionMgr(); - mgr->selectedObjects(aList); + mgr->selectedObjects( aList, QString::null, false ); if( aList.IsEmpty() ) return; @@ -402,8 +402,11 @@ void SalomeApp_Application::onDeleteInvalidReferences() for( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() ) if ( it.Value()->hasEntry() ) { - _PTR(SObject) aSObject = aStudyDS->FindObjectID( it.Value()->getEntry() ); - if( aSObject && aSObject->ReferencedObject( anObj ) && QString( anObj->GetName().c_str() ).isEmpty() ) + _PTR(SObject) aSObject = aStudyDS->FindObjectID( it.Value()->getEntry() ), aRefObj = aSObject; + while( aRefObj && aRefObj->ReferencedObject( anObj ) ) + aRefObj = anObj; + + if( aRefObj && aRefObj!=aSObject && QString( aRefObj->GetName().c_str() ).isEmpty() ) aStudyBuilder->RemoveReference( aSObject ); } updateObjectBrowser(); @@ -699,7 +702,7 @@ void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* t // Get selected objects SALOME_ListIO aList; LightApp_SelectionMgr* mgr = selectionMgr(); - mgr->selectedObjects(aList); + mgr->selectedObjects( aList, QString::null, false ); // "Delete reference" item should appear only for invalid references @@ -712,19 +715,25 @@ void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* t for( SALOME_ListIteratorOfListIO it( aList ); it.More() && !isInvalidRefs; it.Next() ) if( it.Value()->hasEntry() ) { - _PTR(SObject) aSObject = aStudyDS->FindObjectID( it.Value()->getEntry() ); - if( aSObject && aSObject->ReferencedObject( anObj ) && QString( anObj->GetName().c_str() ).isEmpty() ) + _PTR(SObject) aSObject = aStudyDS->FindObjectID( it.Value()->getEntry() ), aRefObj = aSObject; + while( aRefObj && aRefObj->ReferencedObject( anObj ) ) + aRefObj = anObj; + + if( aRefObj && aRefObj!=aSObject && QString( aRefObj->GetName().c_str() ).isEmpty() ) isInvalidRefs = true; } - // Add "Delete refrence" item to popup + // Add "Delete reference" item to popup if ( isInvalidRefs ) { thePopup->insertSeparator(); - thePopup->insertItem( tr( "MEN_DELETE_REFERENCE" ), this, SLOT( onDeleteInvalidReferences() ) ); + thePopup->insertItem( tr( "MEN_DELETE_INVALID_REFERENCE" ), this, SLOT( onDeleteInvalidReferences() ) ); return; } + aList.Clear(); + mgr->selectedObjects( aList ); + // "Activate module" item should appear only if it's necessary if (aList.Extent() != 1) return; -- 2.39.2