Salome HOME
Fix for the bug #255: VTK viewer is not updated after modification of objects.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_DataBrowser.cxx
index f4cc73c2b0ad64f157d411c65e972e741280dd89..2c16b0c6383c3efdc03373dc493ce0ad033d9aab 100644 (file)
@@ -42,8 +42,15 @@ HYDROGUI_DataBrowser::HYDROGUI_DataBrowser( HYDROGUI_Module* theModule, SUIT_Dat
 {
   SUIT_ResourceMgr* resMgr = theModule->getApp()->resourceMgr();
 
+  if ( ( !theRoot ) && theModule )
+  {
+    // Initialize the root with the module data model
+    setRoot( new CAM_ModuleObject( theModule->dataModel(), NULL ) );
+  }
+
   setSortMenuEnabled( true );
   setAutoUpdate( true );
+  setUpdateModified( true );
 
   if ( resMgr->hasValue( "ObjectBrowser", "auto_hide_search_tool" ) )
     searchTool()->enableAutoHide( resMgr->booleanValue( "ObjectBrowser", "auto_hide_search_tool" ) );
@@ -53,7 +60,8 @@ HYDROGUI_DataBrowser::HYDROGUI_DataBrowser( HYDROGUI_Module* theModule, SUIT_Dat
 
   QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
   QString RefObjCol = tr( "REF_OBJECT_COLUMN" );
-  QString BathymetryCol = tr( "BATHYMETRY_COLUMN" );
+  QString AltitudeCol = tr( "ALTITUDE_COLUMN" );
+
   SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( model() );
   //RKV: treeModel->setSearcher( theModule->getApp() );
   treeModel->setSearcher( this ); //RKV
@@ -61,8 +69,8 @@ HYDROGUI_DataBrowser::HYDROGUI_DataBrowser( HYDROGUI_Module* theModule, SUIT_Dat
   treeModel->setAppropriate( EntryCol, Qtx::Toggled );
   treeModel->registerColumn( 0, RefObjCol, HYDROGUI_DataObject::RefObjectId );
   treeModel->setAppropriate( RefObjCol, Qtx::Toggled );
-  treeModel->registerColumn( 0, BathymetryCol, HYDROGUI_DataObject::BathymetryId );
-  treeModel->setAppropriate( BathymetryCol, Qtx::Toggled );
+  treeModel->registerColumn( 0, AltitudeCol, HYDROGUI_DataObject::AltitudeObjId );
+  treeModel->setAppropriate( AltitudeCol, Qtx::Toggled );
 
   // Mantis issue 0020136: Drag&Drop in OB
   SUIT_ProxyModel* proxyModel = dynamic_cast<SUIT_ProxyModel*>(treeModel);
@@ -70,6 +78,33 @@ HYDROGUI_DataBrowser::HYDROGUI_DataBrowser( HYDROGUI_Module* theModule, SUIT_Dat
     connect( proxyModel, 
       SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
       SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
+
+    //// Connect signal emitted after editing for updating after objects renaming
+    SUIT_TreeModel* aMiniModel = dynamic_cast<SUIT_TreeModel*>( proxyModel->sourceModel() );
+    if ( aMiniModel )
+    {
+      connect( aMiniModel, SIGNAL( dataChanged( const QModelIndex &, const QModelIndex & ) ), 
+        SIGNAL( dataChanged() ) );
+    }
+
+    // Do updating also in the module's main object browser.
+    if ( theModule )
+    {
+      SUIT_DataBrowser* aModulBrowser = theModule->getApp()->objectBrowser();
+      if ( aModulBrowser )
+      {
+        SUIT_ProxyModel* aPModel = dynamic_cast<SUIT_ProxyModel*>(aModulBrowser->model());
+        if ( aPModel )
+        {
+          SUIT_TreeModel* aModel = dynamic_cast<SUIT_TreeModel*>(aPModel->sourceModel());
+          //connect( proxyModel, SIGNAL( dataChanged( const QModelIndex &, const QModelIndex & ) ), 
+          //  aPModel, SIGNAL( dataChanged( const QModelIndex &, const QModelIndex & ) ) );
+          //connect( proxyModel, SIGNAL( dataChanged( const QModelIndex &, const QModelIndex & ) ), 
+          //  aModel, SIGNAL( dataChanged( const QModelIndex &, const QModelIndex & ) ) );
+          connect( proxyModel, SIGNAL( modelUpdated() ), aModel, SIGNAL( modelUpdated() ) );
+        }
+      }
+    }
   }
 
   // temporary commented