Salome HOME
Initial version
[modules/gui.git] / src / SUIT / SUIT_Selector.cxx
1 #include "SUIT_Selector.h"
2
3 #include "SUIT_SelectionMgr.h"
4
5 SUIT_Selector::SUIT_Selector( SUIT_SelectionMgr* selMgr )
6 : mySelMgr( selMgr ),
7 myBlock( false ),
8 myEnabled( true ),
9 myAutoBlock( true )
10 {
11   if ( selMgr )
12     selMgr->installSelector( this );
13 }
14
15 SUIT_Selector::~SUIT_Selector()
16 {
17   if ( selectionMgr() )
18     selectionMgr()->removeSelector( this );
19 }
20
21 SUIT_SelectionMgr* SUIT_Selector::selectionMgr() const
22 {
23   return mySelMgr;
24 }
25
26 bool SUIT_Selector::isEnabled() const
27 {
28   return myEnabled;
29 }
30
31 void SUIT_Selector::setEnabled( const bool on )
32 {
33   myEnabled = on;
34 }
35
36 bool SUIT_Selector::autoBlock() const
37 {
38   return myAutoBlock;
39 }
40
41 void SUIT_Selector::setAutoBlock( const bool on )
42 {
43   myAutoBlock = on;
44 }
45
46 void SUIT_Selector::selected( SUIT_DataOwnerPtrList& lst ) const
47 {
48   lst.clear();
49   getSelection( lst );
50 }
51
52 void SUIT_Selector::setSelected( const SUIT_DataOwnerPtrList& lst )
53 {
54   if ( !isEnabled() )
55     return;
56
57   bool block = myBlock;
58   myBlock = true;
59
60   setSelection( lst );
61
62   myBlock = block;
63 }
64
65 void SUIT_Selector::selectionChanged()
66 {
67   if ( selectionMgr() && isEnabled() && ( !autoBlock() || !myBlock ) )
68     selectionMgr()->selectionChanged( this );
69 }
70
71 bool SUIT_Selector::hasSelectionMode( const int mode ) const
72 {
73   if ( !selectionMgr() )
74     return false;
75
76   return selectionMgr()->hasSelectionMode( mode );
77 }
78
79 void SUIT_Selector::selectionModes( QValueList<int>& lst ) const
80 {
81   if ( selectionMgr() )
82     selectionMgr()->selectionModes( lst );
83 }