1 #include "SalomeApp_OBSelector.h"
3 #include "SalomeApp_DataOwner.h"
4 #include "SalomeApp_DataObject.h"
6 #include <OB_Browser.h>
8 #include <SUIT_DataObjectIterator.h>
10 SalomeApp_OBSelector::SalomeApp_OBSelector( OB_Browser* ob, SUIT_SelectionMgr* mgr )
16 connect( myBrowser, SIGNAL( selectionChanged() ), this, SLOT( onSelectionChanged() ) );
19 SalomeApp_OBSelector::~SalomeApp_OBSelector()
23 OB_Browser* SalomeApp_OBSelector::browser() const
28 void SalomeApp_OBSelector::getSelection( SUIT_DataOwnerPtrList& list ) const
33 DataObjectList objlist;
34 myBrowser->getSelected( objlist );
35 for ( DataObjectListIterator it( objlist ); it.current(); ++it )
37 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>( it.current() );
39 list.append( SUIT_DataOwnerPtr( new SalomeApp_DataOwner( obj->entry() ) ) );
43 void SalomeApp_OBSelector::setSelection( const SUIT_DataOwnerPtrList& list )
48 QMap<QString, SalomeApp_DataObject*> map;
51 DataObjectList objList;
52 for ( SUIT_DataOwnerPtrList::const_iterator it = list.begin(); it != list.end(); ++it )
54 const SalomeApp_DataOwner* owner = dynamic_cast<const SalomeApp_DataOwner*>( (*it).operator->() );
55 if ( owner && map.contains( owner->entry() ) )
56 objList.append( map[owner->entry()] );
59 myBrowser->setSelected( objList );
62 void SalomeApp_OBSelector::onSelectionChanged()
67 void SalomeApp_OBSelector::fillEntries( QMap<QString, SalomeApp_DataObject*>& entires )
74 for ( SUIT_DataObjectIterator it( myBrowser->getRootObject(),
75 SUIT_DataObjectIterator::DepthLeft ); it.current(); ++it )
77 SalomeApp_DataObject* obj = dynamic_cast<SalomeApp_DataObject*>( it.current() );
79 entires.insert( obj->entry(), obj );