Salome HOME
Image positioning by two points.
[modules/hydro.git] / src / HYDROGUI / HYDROGUI_DataBrowser.cxx
index b6cdedb224516b134715593cbfc522844e113e1a..f4cc73c2b0ad64f157d411c65e972e741280dd89 100644 (file)
@@ -33,6 +33,7 @@
 #include <SUIT_DataObject.h>
 #include <SUIT_ResourceMgr.h>
 #include <SUIT_SelectionMgr.h>
+#include <SUIT_DataObjectIterator.h>
         
 #define VISIBILITY_COLUMN_WIDTH 25
 
@@ -50,22 +51,26 @@ HYDROGUI_DataBrowser::HYDROGUI_DataBrowser( HYDROGUI_Module* theModule, SUIT_Dat
   setWindowTitle( tr( "OBJECT_BROWSER" ) );
   connect( this, SIGNAL( requestUpdate() ), theModule->getApp(), SLOT( onRefresh() ) );
 
+  QString EntryCol = QObject::tr( "ENTRY_COLUMN" );
   QString RefObjCol = tr( "REF_OBJECT_COLUMN" );
   QString BathymetryCol = tr( "BATHYMETRY_COLUMN" );
   SUIT_AbstractModel* treeModel = dynamic_cast<SUIT_AbstractModel*>( model() );
-  treeModel->setSearcher( theModule->getApp() );
+  //RKV: treeModel->setSearcher( theModule->getApp() );
+  treeModel->setSearcher( this ); //RKV
+  treeModel->registerColumn( 0, EntryCol, LightApp_DataObject::EntryId );
+  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 );
 
   // Mantis issue 0020136: Drag&Drop in OB
-  //RKV: TODO: Uncomment for drag and drop
-  //RKV: SUIT_ProxyModel* proxyModel = dynamic_cast<SUIT_ProxyModel*>(treeModel);
-  //RKV: if ( proxyModel ) {
-  //RKV:   connect( proxyModel, SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
-  //RKV:            theModule->getApp(), SLOT( onDropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
-  //RKV: }
+  SUIT_ProxyModel* proxyModel = dynamic_cast<SUIT_ProxyModel*>(treeModel);
+  if ( proxyModel ) {
+    connect( proxyModel, 
+      SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ),
+      SIGNAL( dropped( const QList<SUIT_DataObject*>&, SUIT_DataObject*, int, Qt::DropAction ) ) );
+  }
 
   // temporary commented
   /*
@@ -82,9 +87,22 @@ HYDROGUI_DataBrowser::HYDROGUI_DataBrowser( HYDROGUI_Module* theModule, SUIT_Dat
   treeView()->header()->setResizeMode(SUIT_DataObject::VisibilityId, QHeaderView::Fixed);
   treeView()->header()->moveSection(SUIT_DataObject::NameId,SUIT_DataObject::VisibilityId);
   treeView()->setColumnWidth(SUIT_DataObject::VisibilityId, VISIBILITY_COLUMN_WIDTH);
+  treeView()->hideColumn( SUIT_DataObject::VisibilityId );
+  treeView()->hideColumn( LightApp_DataObject::EntryId );
   //RKV: connectPopupRequest( theModule->getApp(), SLOT( onConnectPopupRequest( SUIT_PopupClient*, QContextMenuEvent* ) ) );
 }
 
 HYDROGUI_DataBrowser::~HYDROGUI_DataBrowser()
 {
 }
+
+SUIT_DataObject* HYDROGUI_DataBrowser::findObject( const QString& theEntry ) const
+{
+  LightApp_DataObject* aCurObj;
+  for ( SUIT_DataObjectIterator it( root(), SUIT_DataObjectIterator::DepthLeft ); it.current(); ++it ) {
+    aCurObj = dynamic_cast<LightApp_DataObject*>( it.current() );
+    if ( aCurObj && aCurObj->entry() == theEntry )
+      return aCurObj;
+  }
+  return NULL;
+}