Salome HOME
New item (FontItem), allowing to show information about font setting and to select...
[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, QObject* parent ) :
6 QObject( parent ), 
7 mySelMgr( selMgr ),
8 myBlock( false ),
9 myEnabled( true ),
10 myAutoBlock( true )
11 {
12   if ( selMgr )
13     selMgr->installSelector( this );
14 }
15
16 SUIT_Selector::~SUIT_Selector()
17 {
18   if ( selectionMgr() )
19     selectionMgr()->removeSelector( this );
20 }
21
22 SUIT_SelectionMgr* SUIT_Selector::selectionMgr() const
23 {
24   return mySelMgr;
25 }
26
27 bool SUIT_Selector::isEnabled() const
28 {
29   return myEnabled;
30 }
31
32 void SUIT_Selector::setEnabled( const bool on )
33 {
34   myEnabled = on;
35 }
36
37 bool SUIT_Selector::autoBlock() const
38 {
39   return myAutoBlock;
40 }
41
42 void SUIT_Selector::setAutoBlock( const bool on )
43 {
44   myAutoBlock = on;
45 }
46
47 void SUIT_Selector::selected( SUIT_DataOwnerPtrList& lst ) const
48 {
49   lst.clear();
50   getSelection( lst );
51 }
52
53 void SUIT_Selector::setSelected( const SUIT_DataOwnerPtrList& lst )
54 {
55   if ( !isEnabled() )
56     return;
57
58   bool block = myBlock;
59   myBlock = true;
60
61   setSelection( lst );
62
63   myBlock = block;
64 }
65
66 void SUIT_Selector::selectionChanged()
67 {
68   if ( selectionMgr() && isEnabled() && ( !autoBlock() || !myBlock ) )
69     selectionMgr()->selectionChanged( this );
70 }
71
72 bool SUIT_Selector::hasSelectionMode( const int mode ) const
73 {
74   if ( !selectionMgr() )
75     return false;
76
77   return selectionMgr()->hasSelectionMode( mode );
78 }
79
80 void SUIT_Selector::selectionModes( QValueList<int>& lst ) const
81 {
82   if ( selectionMgr() )
83     selectionMgr()->selectionModes( lst );
84 }