]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Fix for "delete invalid reference" popup item rule and functionality.
authorasl <asl@opencascade.com>
Wed, 7 Dec 2005 12:35:29 +0000 (12:35 +0000)
committerasl <asl@opencascade.com>
Wed, 7 Dec 2005 12:35:29 +0000 (12:35 +0000)
src/SalomeApp/SalomeApp_Application.cxx
src/SalomeApp/SalomeApp_Application.h

index 26df49c6c67ec9f26b0b3c5d8b67a6c90e8a5fb1..502ab9bd2f3bdaf9c192f18e121fda81e214fa4c 100644 (file)
@@ -385,29 +385,27 @@ void SalomeApp_Application::onSelectionChanged()
 }
 
 /*!Delete references.*/
-void SalomeApp_Application::onDeleteReferences()
+void SalomeApp_Application::onDeleteInvalidReferences()
 {
   SALOME_ListIO aList;
   LightApp_SelectionMgr* mgr = selectionMgr();
   mgr->selectedObjects(aList);
 
-  if (aList.Extent() < 1) return;
+  if( aList.IsEmpty() )
+    return;
 
   SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(activeStudy());
   _PTR(Study) aStudyDS = aStudy->studyDS();
   _PTR(StudyBuilder) aStudyBuilder = aStudyDS->NewBuilder();
   _PTR(SObject) anObj;
 
-  for ( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() )
+  for( SALOME_ListIteratorOfListIO it( aList ); it.More(); it.Next() )
+    if ( it.Value()->hasEntry() )
     {
-      if ( it.Value()->hasEntry() )
-       {
-         _PTR(SObject) aSObject = aStudyDS->FindObjectID( it.Value()->getEntry() );
-         if ( aSObject->ReferencedObject(anObj) )
-           aStudyBuilder->RemoveReference(aSObject);
-       }
+      _PTR(SObject) aSObject = aStudyDS->FindObjectID( it.Value()->getEntry() );
+       if( aSObject && aSObject->ReferencedObject( anObj ) && QString( anObj->GetName().c_str() ).isEmpty() )
+        aStudyBuilder->RemoveReference( aSObject );
     }
-
   updateObjectBrowser();
 }
 
@@ -705,38 +703,27 @@ void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* t
 
   // "Delete reference" item should appear only for invalid references
 
-  // Check if selected objects is invalid references
-  bool isInvalidRefs = true;
-
-  if ( aList.Extent() < 1 )
-    isInvalidRefs = false;
+  // isInvalidRefs will be true, if at least one of selected objects is invalid reference
+  bool isInvalidRefs = false;
+  SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(activeStudy());
+  _PTR(Study) aStudyDS = aStudy->studyDS();
+  _PTR(SObject) anObj;
 
-  if ( isInvalidRefs )
+  for( SALOME_ListIteratorOfListIO it( aList ); it.More() && !isInvalidRefs; it.Next() )
+    if( it.Value()->hasEntry() )
     {
-      SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(activeStudy());
-      _PTR(Study) aStudyDS = aStudy->studyDS();
-      _PTR(SObject) anObj;
-
-      for ( SALOME_ListIteratorOfListIO it( aList ); it.More() && isInvalidRefs; it.Next() )
-       {
-         if ( it.Value()->hasEntry() )
-           {
-             _PTR(SObject) aSObject = aStudyDS->FindObjectID( it.Value()->getEntry() );
-              SALOMEDS_SObject* aSO = dynamic_cast<SALOMEDS_SObject*>(aSObject.get());
-              if( aSO )
-                if ( aSObject->ReferencedObject(anObj) == false || !QString(anObj->GetName().c_str()).isEmpty() )
-                  isInvalidRefs = false;
-           }
-       }
+      _PTR(SObject) aSObject = aStudyDS->FindObjectID( it.Value()->getEntry() );
+      if( aSObject && aSObject->ReferencedObject( anObj ) && QString( anObj->GetName().c_str() ).isEmpty() )
+       isInvalidRefs = true;
     }
 
   // Add "Delete refrence" item to popup
   if ( isInvalidRefs )
-    {
-      thePopup->insertSeparator();
-      thePopup->insertItem( tr( "MEN_DELETE_REFERENCE" ), this, SLOT( onDeleteReferences() ) );
-      return;
-    }
+  {
+    thePopup->insertSeparator();
+    thePopup->insertItem( tr( "MEN_DELETE_REFERENCE" ), this, SLOT( onDeleteInvalidReferences() ) );
+    return;
+  }
 
   // "Activate module" item should appear only if it's necessary
   if (aList.Extent() != 1)
@@ -748,7 +735,6 @@ void SalomeApp_Application::contextMenuPopup( const QString& type, QPopupMenu* t
   if (currentModule && currentModule->moduleName() == aModuleTitle)
     return;
   thePopup->insertItem( tr( "MEN_OPENWITH" ), this, SLOT( onOpenWith() ) );
-
 }
 
 /*!Update obect browser:
@@ -782,7 +768,7 @@ void SalomeApp_Application::updateObjectBrowser( const bool updateModels )
   if ( objectBrowser() )
   {
     objectBrowser()->updateGeometry();
-    objectBrowser()->updateTree();
+    objectBrowser()->updateTree( 0, false );
   }
 }
 
index 865fd2bd09904ed74f2c4356c5c7022fc66a016b..2462e557b770edd06345a45f22b3cbc1a88fad7c 100644 (file)
@@ -85,7 +85,7 @@ protected:
   virtual void                        updateDesktopTitle();
 
 private slots:
-  void                                onDeleteReferences();
+  void                                onDeleteInvalidReferences();
   void                                onDblClick( QListViewItem* );
   void                                onProperties();
   void                                onDumpStudy();