Salome HOME
New method "isSynchronizing()"
[modules/gui.git] / src / SUIT / SUIT_SelectionMgr.h
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 // 
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either 
6 // version 2.1 of the License.
7 // 
8 // This library is distributed in the hope that it will be useful 
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public  
14 // License along with this library; if not, write to the Free Software 
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/
18 //
19 #ifndef SUIT_SELECTIONMGR_H
20 #define SUIT_SELECTIONMGR_H
21
22 #include "SUIT_Selector.h"
23 #include "SUIT_DataOwner.h"
24 #include "SUIT_SelectionFilter.h"
25
26 #include <qobject.h>
27 #include <qptrlist.h>
28 #include <qvaluelist.h>
29
30 class SUIT_EXPORT SUIT_SelectionMgr : public QObject
31 {
32   Q_OBJECT
33
34 public:
35   SUIT_SelectionMgr( const bool = true, QObject* = 0 );
36   virtual ~SUIT_SelectionMgr();
37
38   void            clearSelected();
39   virtual void    selected( SUIT_DataOwnerPtrList&, const QString& = QString::null ) const;
40   virtual void    setSelected( const SUIT_DataOwnerPtrList&, const bool = false );
41
42   void            selectors( QPtrList<SUIT_Selector>& ) const;
43   void            selectors( const QString&, QPtrList<SUIT_Selector>& ) const;
44
45
46   void            setEnabled( const bool, const QString& = QString::null );
47
48
49   bool            hasSelectionMode( const int ) const;
50   void            selectionModes( QValueList<int>& ) const;
51
52   void            setSelectionModes( const int );
53   virtual void    setSelectionModes( const QValueList<int>& );
54
55   void            appendSelectionModes( const int );
56   virtual void    appendSelectionModes( const QValueList<int>& );
57
58   void            removeSelectionModes( const int );
59   virtual void    removeSelectionModes( const QValueList<int>& );
60
61
62   bool            isOk( const SUIT_DataOwner* ) const;
63   bool            isOk( const SUIT_DataOwnerPtr& ) const;
64
65   bool            hasFilter( SUIT_SelectionFilter* ) const;
66
67   virtual void    installFilter( SUIT_SelectionFilter*, const bool = true );
68   virtual void    removeFilter( SUIT_SelectionFilter* );
69   virtual void    clearFilters();
70
71   bool            autoDeleteFilter() const;
72   void            setAutoDeleteFilter( const bool );
73
74   bool            isSynchronizing() const;
75
76 signals:
77   void            selectionChanged();
78
79 protected:
80   virtual void    selectionChanged( SUIT_Selector* );
81
82   typedef QPtrListIterator<SUIT_Selector>        SelectorListIterator;
83
84   virtual void    installSelector( SUIT_Selector* );
85   virtual void    removeSelector( SUIT_Selector* );
86
87 private:
88   void            filterOwners( const SUIT_DataOwnerPtrList&, SUIT_DataOwnerPtrList& ) const;
89
90   typedef QPtrList<SUIT_Selector>                SelectorList;
91   typedef QPtrList<SUIT_SelectionFilter>         SelFilterList;
92   typedef QPtrListIterator<SUIT_SelectionFilter> SelFilterListIterator;
93
94 protected:
95   SelectorList    mySelectors;
96
97 private:
98   SelFilterList   myFilters;
99   QValueList<int> mySelModes;
100   int             myIterations;
101   bool            myIsSelChangeEnabled;
102
103   friend class SUIT_Selector;
104 };
105
106 #endif