Salome HOME
*** empty log message ***
[modules/gui.git] / src / SalomeApp / SalomeApp_Selection.cxx
1
2 #include "SalomeApp_Selection.h"
3
4 #include "SalomeApp_SelectionMgr.h"
5 #include "SalomeApp_DataOwner.h"
6 #include "SalomeApp_Study.h"
7 #include "SalomeApp_Application.h"
8
9 #include "SUIT_Session.h"
10
11 SalomeApp_Selection::SalomeApp_Selection()
12 : myStudy( 0 )
13 {
14 }
15
16 SalomeApp_Selection::~SalomeApp_Selection()
17 {
18 }
19
20 void SalomeApp_Selection::init( const QString& client, SalomeApp_SelectionMgr* mgr)
21 {
22   myPopupClient = client;
23   
24   if( mgr )
25   {
26     if ( mgr->application() )
27       myStudy = dynamic_cast<SalomeApp_Study*>( mgr->application()->activeStudy() );
28
29     SUIT_DataOwnerPtrList sel;
30     mgr->selected( sel );
31     SUIT_DataOwnerPtrList::const_iterator anIt = sel.begin(), aLast = sel.end();
32     for( ; anIt!=aLast; anIt++ )
33     {
34       SUIT_DataOwner* owner = ( SUIT_DataOwner* )( (*anIt ).get() );
35       SalomeApp_DataOwner* sowner = dynamic_cast<SalomeApp_DataOwner*>( owner );
36       if( sowner ) {
37         myEntries.append( sowner->entry() );
38         processOwner( sowner );
39       }
40     }
41   }
42 }
43
44 int SalomeApp_Selection::count() const
45 {
46   return myEntries.count();
47 }
48
49 QtxValue SalomeApp_Selection::param( const int, const QString& ) const
50 {
51   return QtxValue();
52 }
53
54 QtxValue SalomeApp_Selection::globalParam( const QString& p ) const
55 {
56   if( p=="client" )
57     return myPopupClient;
58   else
59     return QtxPopupMgr::Selection::globalParam( p );
60 }
61
62 void SalomeApp_Selection::processOwner( const SalomeApp_DataOwner* )
63 {
64 }
65
66 QString SalomeApp_Selection::entry( const int index ) const
67 {
68   if ( index >= 0 && index < count() )
69     return myEntries[ index ];
70   return QString();
71 }