]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
PAL10125 - by double click on reference original object becomes selected
authorasl <asl@opencascade.com>
Tue, 25 Oct 2005 08:13:21 +0000 (08:13 +0000)
committerasl <asl@opencascade.com>
Tue, 25 Oct 2005 08:13:21 +0000 (08:13 +0000)
src/SalomeApp/SalomeApp_Application.cxx
src/SalomeApp/SalomeApp_Application.h

index 3323060ac0feac610f31987366d7a291c4a0f45d..a94e0fb6057b238870f33f32cf9454f178711218 100644 (file)
@@ -56,6 +56,7 @@
 #include <QtxResourceEdit.h>
 
 #include <OB_Browser.h>
+#include <OB_ListItem.h>
 
 #include <PythonConsole_PyConsole.h>
 
@@ -1460,6 +1461,7 @@ QWidget* SalomeApp_Application::createWindow( const int flag )
     ob->setFilter( new SalomeApp_OBFilter( selectionMgr() ) );
 
     ob->setNameTitle( tr( "OBJ_BROWSER_NAME" ) );
+    connect( ob->listView(), SIGNAL( doubleClicked( QListViewItem* ) ), this, SLOT( onDblClick( QListViewItem* ) ) );
 
     bool autoSize = resMgr->booleanValue( "ObjectBrowser", "auto_size", false );
     for ( int i = SalomeApp_DataObject::CT_Value; i <= SalomeApp_DataObject::CT_RefEntry; i++ )
@@ -2243,3 +2245,46 @@ SUIT_Accel* SalomeApp_Application::accel() const
 {
   return myAccel;
 }
+
+/*!find original object by double click on item */
+void SalomeApp_Application::onDblClick( QListViewItem* it )
+{
+  OB_ListItem* item = dynamic_cast<OB_ListItem*>( it );
+  SalomeApp_Study* study = dynamic_cast<SalomeApp_Study*>( activeStudy() );
+
+  if( study && item )
+  {
+    SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>( item->dataObject() );
+    if( !obj )
+      return;
+
+    QString entry = obj->entry();
+    _PTR(SObject) sobj = study->studyDS()->FindObjectID( entry.latin1() ), ref;
+    
+    if( sobj && sobj->ReferencedObject( ref ) )
+    {
+      entry = ref->GetID();
+      QListViewItemIterator anIt( item->listView() );
+      for( ; anIt.current(); anIt++ )
+      {
+       OB_ListItem* item = dynamic_cast<OB_ListItem*>( anIt.current() );
+       if( !item )
+         continue;
+
+       SalomeApp_DataObject* original = dynamic_cast<SalomeApp_DataObject*>( item->dataObject() );
+       if( original->entry()!=entry )
+         continue;
+
+       OB_Browser* br = objectBrowser();
+       br->setSelected( original );
+       SUIT_DataObject* p = original->parent();
+       while( p )
+       {
+         br->setOpen( p );
+         p = p->parent();
+       }
+       break;
+      }
+    }
+  }
+}
index f5d7406bf94eb748e672327d51d1857d64eaa12e..ff332ab1d85efe71b942865177b025635dd95d57 100644 (file)
@@ -36,6 +36,8 @@ class SUIT_Accel;
 
 class SALOME_LifeCycleCORBA;
 
+class QListViewItem;
+
 #ifdef WIN32
 #pragma warning( disable:4251 )
 #endif
@@ -132,6 +134,7 @@ private slots:
   void                                onSelection();
   void                                onRefresh();
   void                                onDeleteReferences();
+  void                                onDblClick( QListViewItem* );
 
 protected:
   virtual void                        createActions();