]> SALOME platform Git repositories - modules/hexablock.git/blob - src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentDelegate.hxx
Salome HOME
f8e713cfb599926cab11e5c90b9b8f7a300763bd
[modules/hexablock.git] / src / HEXABLOCKGUI / HEXABLOCKGUI_DocumentDelegate.hxx
1 // Copyright (C) 2009-2012  CEA/DEN, EDF 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/ or email : webmaster.salome@opencascade.com
18 //
19 #ifndef __HEXABLOCKGUI_DOCUMENTDELEGATE_HXX_
20 #define __HEXABLOCKGUI_DOCUMENTDELEGATE_HXX_
21
22
23 // QEvent * event, QAbstractItemModel 
24
25 #include <QEvent>
26 #include <QItemDelegate>
27 #include <QModelIndex>
28 #include <QObject>
29 #include <QSize>
30 #include <QSpinBox>
31
32 #include <QDockWidget>
33
34
35 #include "HEXABLOCKGUI_DocumentModel.hxx"
36 #include "HEXABLOCKGUI_DocumentSelectionModel.hxx"
37
38 namespace HEXABLOCK
39 {
40   namespace GUI
41   {
42       class DocumentDelegate : public QItemDelegate
43       {
44           Q_OBJECT
45       
46       public:
47           DocumentDelegate( QDockWidget *dw, QObject *parent = 0);
48
49           QWidget *createEditor( QWidget *parent,
50                                  const QStyleOptionViewItem &option,
51                                  const QModelIndex &index) const;
52
53           void setEditorData( QWidget *editor, const QModelIndex &index) const;
54
55           void setModelData( QWidget            *editor,
56                              QAbstractItemModel *model,
57                              const QModelIndex  &index ) const;
58
59           void updateEditorGeometry( QWidget *editor,
60                                      const QStyleOptionViewItem &option,
61                                      const QModelIndex &index ) const;
62
63          // can be used by editor
64           void setDocumentModel( DocumentModel* m );
65
66           //  selection
67           void setPatternDataSelectionModel( PatternDataSelectionModel* s );
68           void setPatternBuilderSelectionModel( PatternBuilderSelectionModel* s );
69           void setGroupsSelectionModel( /*QItemSelectionModel**/ GroupsSelectionModel* s );
70           void setMeshSelectionModel( MeshSelectionModel* s );
71
72           virtual bool editorEvent ( QEvent * event, 
73                                      QAbstractItemModel * model, 
74                                      const QStyleOptionViewItem & option, 
75                                      const QModelIndex & index );
76
77       public slots:
78 //           void onCloseEditor( QWidget *, QAbstractItemDelegate::EndEditHint);
79 //           void onCommitData ( QWidget * editor );
80
81       private:
82           QDockWidget *_dw; // editor's container 
83
84           // can be used by editor
85           DocumentModel*                _documentModel;
86
87           PatternDataSelectionModel*    _patternDataSelectionModel;
88           PatternBuilderSelectionModel* _patternBuilderSelectionModel;
89           GroupsSelectionModel*         _groupsSelectionModel; 
90           MeshSelectionModel*           _meshSelectionModel;
91
92       private slots:
93           void commitEditor();
94
95       };
96   }
97 }
98
99 #endif