Salome HOME
eed5d3e8968d4506b874db7bfa413d226f1503a0
[modules/gui.git] / src / QDS / QDS_Table.h
1 // Copyright (C) 2007-2021  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 #ifndef QDS_TABLE_H
24 #define QDS_TABLE_H
25
26 #include "QDS_Datum.h"
27
28 #include <QtxTable.h>
29
30 #include <QMap>
31 #include <QVector>
32
33 class QDS_EXPORT QDS_Table : public QtxTable
34 {
35   class DeleteFilter;
36
37   Q_OBJECT
38
39   Q_PROPERTY( bool KeepEditors READ isKeepEditors WRITE setKeepEditors )
40
41 public:
42   QDS_Table( QWidget* = 0, const char* = 0 );
43   QDS_Table( int, int, QWidget* = 0, const char* = 0 );
44   virtual ~QDS_Table();
45
46   QDS_Datum*       verticalHeaderEditor() const;
47   QDS_Datum*       horizontalHeaderEditor() const;
48   QDS_Datum*       headerEditor( const Orientation ) const;
49
50   void             setVerticalHeaderEditor( QDS_Datum* );
51   void             setHorizontalHeaderEditor( QDS_Datum* );
52
53   void             setHeaderEditor( QDS_Datum* );
54   virtual void     setHeaderEditor( const Orientation, QDS_Datum* );
55
56   QDS_Datum*       tableEditor() const;
57   virtual void     setTableEditor( QDS_Datum* );
58
59   QDS_Datum*       rowEditor( const int ) const;
60   QDS_Datum*       columnEditor( const int ) const;
61
62   virtual void     setRowEditor( const int, QDS_Datum* );
63   virtual void     setColumnEditor( const int, QDS_Datum* );
64
65   QDS_Datum*       cellEditor( const int, const int ) const;
66   virtual void     setCellEditor( const int, const int, QDS_Datum* );
67
68   QDS_Datum*       actualCellEditor( const int, const int ) const;
69
70   virtual void     setNumRows( int );
71   virtual void     setNumCols( int );
72   virtual void     clearCellWidget( int, int );
73
74   bool             isKeepEditors() const;
75   void             setKeepEditors( const bool );
76
77 protected:
78   virtual QWidget* createHeaderEditor( QHeader*, const int, const bool = true );
79   virtual QWidget* createEditor( int, int, bool ) const;
80   virtual void     endEdit( int, int, bool, bool );
81   virtual void     setCellContentFromEditor( int, int );
82   virtual void     setHeaderContentFromEditor( QHeader*, const int, QWidget* );
83
84 private:
85   void             initEditor( QDS_Datum* );
86   QDS_Datum*       datum( const QWidget* ) const;
87
88 private:
89   typedef QVector<QDS_Datum*>         DatumVector;
90   typedef QMap<int, QDS_Datum*>       DatumMap;
91   typedef QMap<int, DatumMap>         CellMap;
92
93 private:
94   QDS_Datum*       myHorEdit;
95   QDS_Datum*       myVerEdit;
96   DatumVector      myRowEdit;
97   DatumVector      myColEdit;
98   CellMap          myCellEdit;
99   QDS_Datum*       myTableEdit;
100   bool             myKeepEdits;
101 };
102
103 #endif