From 0cc8986912e1c700eac8d02df425561bbb46128d Mon Sep 17 00:00:00 2001 From: asl Date: Tue, 25 Oct 2005 08:13:21 +0000 Subject: [PATCH] PAL10125 - by double click on reference original object becomes selected --- src/SalomeApp/SalomeApp_Application.cxx | 45 +++++++++++++++++++++++++ src/SalomeApp/SalomeApp_Application.h | 3 ++ 2 files changed, 48 insertions(+) diff --git a/src/SalomeApp/SalomeApp_Application.cxx b/src/SalomeApp/SalomeApp_Application.cxx index 3323060ac..a94e0fb60 100644 --- a/src/SalomeApp/SalomeApp_Application.cxx +++ b/src/SalomeApp/SalomeApp_Application.cxx @@ -56,6 +56,7 @@ #include #include +#include #include @@ -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( it ); + SalomeApp_Study* study = dynamic_cast( activeStudy() ); + + if( study && item ) + { + SalomeApp_DataObject* obj = dynamic_cast( 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( anIt.current() ); + if( !item ) + continue; + + SalomeApp_DataObject* original = dynamic_cast( 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; + } + } + } +} diff --git a/src/SalomeApp/SalomeApp_Application.h b/src/SalomeApp/SalomeApp_Application.h index f5d7406bf..ff332ab1d 100644 --- a/src/SalomeApp/SalomeApp_Application.h +++ b/src/SalomeApp/SalomeApp_Application.h @@ -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(); -- 2.39.2