]> SALOME platform Git repositories - modules/hexablock.git/blob - src/HEXABLOCKGUI/HEXABLOCKGUI_DocumentDelegate.hxx
Salome HOME
27d4ff09fa1aafebcb1eb9b598c8ec8883998ade
[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 #include "HEXABLOCKGUI_DocumentItem.hxx"
38 #include "HEXABLOCKGUI_DocumentPanel.hxx"
39
40 namespace HEXABLOCK
41 {
42   namespace GUI
43   {
44       class DocumentDelegate : public QItemDelegate
45       {
46           Q_OBJECT
47       
48       public:
49           void closeDialog();
50           DocumentDelegate( QDockWidget *dw, QObject *parent = 0);
51
52           QWidget *createEditor( QWidget *parent,
53                                  const QStyleOptionViewItem &option,
54                                  const QModelIndex &index) const;
55
56           void setEditorData( QWidget *editor, const QModelIndex &index) const;
57
58           void setModelData( QWidget            *editor,
59                              QAbstractItemModel *model,
60                              const QModelIndex  &index ) const {};
61
62           virtual void updateEditorGeometry( QWidget *editor,
63                                      const QStyleOptionViewItem &option,
64                                      const QModelIndex &index ) const {};
65
66           //Can be used by editor
67           void setDocumentModel( DocumentModel* m ){_documentModel = m;}
68
69           //Selections
70           void setPatternDataSelectionModel( PatternDataSelectionModel* s ){_patternDataSelectionModel = s;}
71           void setPatternBuilderSelectionModel( PatternBuilderSelectionModel* s ){_patternBuilderSelectionModel = s;}
72           void setGroupsSelectionModel( GroupsSelectionModel* s ){_groupsSelectionModel = s ;}
73           void setMeshSelectionModel( MeshSelectionModel* s ){_meshSelectionModel = s;}
74
75       protected:
76           mutable QWidget* _currentEditor;
77           virtual bool editorEvent ( QEvent * event,
78                           QAbstractItemModel * model,
79                           const QStyleOptionViewItem & option, const QModelIndex & index );
80           virtual bool  eventFilter ( QObject * editor, QEvent * event );
81
82       public slots:
83 //           void onCloseEditor( QWidget *, QAbstractItemDelegate::EndEditHint);
84 //           void onCommitData ( QWidget * editor );
85
86       private:
87           QDockWidget* _dw; // creator's container
88
89           // can be used by editor
90           DocumentModel*                _documentModel;
91
92           PatternDataSelectionModel*    _patternDataSelectionModel;
93           PatternBuilderSelectionModel* _patternBuilderSelectionModel;
94           GroupsSelectionModel*         _groupsSelectionModel; 
95           MeshSelectionModel*           _meshSelectionModel;
96
97       private slots:
98           void commitEditor();
99
100       };
101   }
102 }
103
104 #endif