Salome HOME
PAL10110 - incorrect title of dialog of file selection for file preference item
[modules/gui.git] / src / ObjBrowser / OB_Browser.cxx
index bc429a7d0ba70d7eff3f1dff59768058665678c8..a660a57d762860607f6a1f12c68544be83fdc7ef 100755 (executable)
@@ -179,6 +179,7 @@ void OB_Browser::setRootObject( SUIT_DataObject* theRoot )
   if ( theRoot )
     curObj = storeState( selObjs, openObjs, selKeys, openKeys, curKey );
 
+  removeConnections( myRoot );
   if ( myRoot != theRoot && isAutoDeleteObjects() )
     delete myRoot;
 
@@ -455,6 +456,12 @@ void OB_Browser::setColumnShown( const int id, const bool on )
   myView->setShown( myColumnIds[id], on );
 }
 
+void OB_Browser::setWidthMode( QListView::WidthMode mode )
+{
+  for ( int i = 0, n = myView->columns(); i < n; i++ )
+    myView->setColumnWidthMode( i, mode );
+}
+
 QValueList<int> OB_Browser::columns() const
 {
   QValueList<int> lst;
@@ -479,14 +486,9 @@ void OB_Browser::setAppropriateColumn( const int id, const bool on )
   myView->setAppropriate( myColumnIds[id], on );
 }
 
-void OB_Browser::updateTree( SUIT_DataObject* o )
+void OB_Browser::updateTree( SUIT_DataObject* obj )
 {
-  updateTree( o ? o : getRootObject(), false );
-}
-
-void OB_Browser::updateTree( SUIT_DataObject* obj, const bool notify )
-{
-  if ( !obj )
+  if ( !obj && !(obj = getRootObject()) )
     return;
 
   DataObjectKey curKey;
@@ -497,14 +499,6 @@ void OB_Browser::updateTree( SUIT_DataObject* obj, const bool notify )
 
   SUIT_DataObject* curObj = storeState( selObjs, openObjs, selKeys, openKeys, curKey );
 
-  if ( notify )
-  {
-    bool upd = isAutoUpdate();
-    setAutoUpdate( false );
-    emit aboutRefresh();
-    setAutoUpdate( upd );
-  }
-
   createConnections( obj );
   updateView( obj );
 
@@ -518,7 +512,7 @@ void OB_Browser::updateTree( SUIT_DataObject* obj, const bool notify )
 
 void OB_Browser::replaceTree( SUIT_DataObject* src, SUIT_DataObject* trg )
 {
-  if ( !src || !trg || src->root() != getRootObject() )
+  if ( !src || !trg || src == trg || src->root() != getRootObject() )
     return;
 
   DataObjectKey curKey;
@@ -534,7 +528,8 @@ void OB_Browser::replaceTree( SUIT_DataObject* src, SUIT_DataObject* trg )
 
   src->setParent( 0 );
 
-  if ( src != trg && isAutoDeleteObjects() )
+  removeConnections( src );
+  if ( isAutoDeleteObjects() )
     delete src;
 
   if ( parent && pos != -1 )
@@ -745,6 +740,7 @@ void OB_Browser::removeReferences( QListViewItem* item )
     return;
 
   SUIT_DataObject* obj = dataObject( item );
+  obj->disconnect( this, SLOT( onDestroyed( SUIT_DataObject* ) ) );
   myItems.remove( obj );
 
   QListViewItem* i = item->firstChild();
@@ -769,6 +765,20 @@ void OB_Browser::createConnections( SUIT_DataObject* obj )
     it.current()->connect( this, SLOT( onDestroyed( SUIT_DataObject* ) ) );
 }
 
+void OB_Browser::removeConnections( SUIT_DataObject* obj )
+{
+  if ( !obj )
+    return;
+
+  DataObjectList childList;
+  obj->children( childList, true );
+
+  childList.prepend( obj );
+
+  for ( DataObjectListIterator it( childList ); it.current(); ++it )
+    it.current()->disconnect( this, SLOT( onDestroyed( SUIT_DataObject* ) ) );
+}
+
 SUIT_DataObject* OB_Browser::storeState( DataObjectMap& selObjs, DataObjectMap& openObjs,
                                          DataObjectKeyMap& selKeys, DataObjectKeyMap& openKeys,
                                          DataObjectKey& curKey ) const
@@ -875,11 +885,6 @@ void OB_Browser::onExpand()
     expand( listViewItem( itr.current() ) );
 }
 
-void OB_Browser::onRefresh()
-{
-  updateTree( getRootObject(), true );
-}
-
 void OB_Browser::onColumnVisible( int id )
 {
   setColumnShown( id, !isColumnVisible( id ) );
@@ -997,7 +1002,6 @@ void OB_Browser::contextMenuPopup( QPopupMenu* menu )
     menu->insertItem( tr( "MEN_EXPAND_ALL" ), this, SLOT( onExpand() ) );
     menu->insertSeparator();
   }
-  menu->insertItem( tr( "MEN_REFRESH" ), this, SLOT( onRefresh() ) );
 }
 
 void OB_Browser::expand( QListViewItem* item )
@@ -1040,6 +1044,7 @@ void OB_Browser::removeObject( SUIT_DataObject* obj, const bool autoUpd )
 
   QListViewItem* item = listViewItem( obj );
 
+  obj->disconnect( this, SLOT( onDestroyed( SUIT_DataObject* ) ) );
   myItems.remove( obj );
 
   if ( obj == myRoot )
@@ -1077,9 +1082,9 @@ void OB_Browser::openBranch( QListViewItem* item, const int level )
   if ( !item || level < 1 || !item->childCount() )
     return;
 
-  item->setOpen( true );
   while ( item )
   {
+    item->setOpen( true );
     openBranch( item->firstChild(), level - 1 );
     item = item->nextSibling();
   }