Salome HOME
refs #416: to store the open state of object browser items in the binary array
[modules/gui.git] / src / SALOME_PYQT / SALOME_PYQT_GUILight / SALOME_PYQT_ModuleLight.cxx
index f00641efa4faaf0e8be14cf7a4926db6e2964fa1..21567b75d7c2e298422be47e92ad7fbb5c753532 100644 (file)
@@ -1,9 +1,9 @@
-// Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -27,7 +27,8 @@
 #include "CAM_Application.h"
 #include "SUITApp_init_python.hxx"
 #include "SUIT_DataObjectIterator.h"
-
+#include "LightApp_Application.h"
+#include "SUIT_DataBrowser.h"
 #include "sipAPISalomePyQtGUILight.h"
 
 #ifndef GUI_DISABLE_CORBA
@@ -141,6 +142,11 @@ void SALOME_PYQT_ModuleLight::initialize( CAM_Application* app )
 
   // ... then call helper
   myHelper->initialize( app );
+  SUIT_DataBrowser* ob = getApp()->objectBrowser();
+  if (ob && ob->model()) {
+    connect( ob->model(), SIGNAL( clicked( SUIT_DataObject*, int ) ),
+             myHelper, SLOT( onObjectBrowserClicked( SUIT_DataObject*, int ) ), Qt::UniqueConnection );
+  }
 }
 
 /*!
@@ -162,7 +168,7 @@ bool SALOME_PYQT_ModuleLight::activateModule( SUIT_Study* study )
   \sa PyModuleHelper::deactivate()
 */
 bool SALOME_PYQT_ModuleLight::deactivateModule( SUIT_Study* study )
-{
+{  
   // call helper
   bool res = myHelper->deactivate( study );
     
@@ -170,6 +176,21 @@ bool SALOME_PYQT_ModuleLight::deactivateModule( SUIT_Study* study )
   return LightApp_Module::deactivateModule( study ) && res;
 }
 
+/*!
+  \brief Close of the module.
+
+  This function is usually used in order to close the module's 
+  specific menus and toolbars and perform other such actions
+  required when the module is closed.
+*/
+void SALOME_PYQT_ModuleLight::onModelClosed()
+{
+  // call helper
+  myHelper->modelClosed(application()->activeStudy());
+  LightApp_Module::onModelClosed();
+}
+
+
 /*!
   \brief Get the dockable windows associated with the module.
   \param winMap output map of dockable windows in form { <window_type> : <dock_area> }
@@ -452,6 +473,22 @@ QColor SALOME_PYQT_ModuleLight::getColor( const QString& entry ) const
   return color;
 }
 
+void SALOME_PYQT_ModuleLight::setObjectPosition( const QString& theEntry, int thePos )
+{
+  SALOME_PYQT_DataObjectLight* dataObj = findObject( theEntry );
+  if ( dataObj )
+    dataObj->setPosition(thePos);
+}
+
+int SALOME_PYQT_ModuleLight::getObjectPosition( const QString& theEntry )
+{
+  SALOME_PYQT_DataObjectLight* dataObj = findObject( theEntry );
+  if ( dataObj )
+    return dataObj->position();
+  return -1;
+}
+
+
 /*!
   \brief Set reference to another data object
   \param entry data object entry