Salome HOME
Abu : Mise a jour HEXABLOCK
[modules/hexablock.git] / src / HEXABLOCKGUI / HEXABLOCKGUI_DocumentDelegate.hxx
1 // Copyright (C) 2009-2013  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 #include "HEXABLOCKGUI_Export.hxx"
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 #include "HEXABLOCKGUI_DocumentModel.hxx"
35 #include "HEXABLOCKGUI_DocumentSelectionModel.hxx"
36 #include "HEXABLOCKGUI_DocumentItem.hxx"
37 #include "HEXABLOCKGUI_DocumentPanel.hxx"
38
39 namespace HEXABLOCK
40 {
41   namespace GUI
42   {
43       class HEXABLOCK_EXPORT DocumentDelegate : public QItemDelegate
44       {
45           Q_OBJECT
46       
47       public:
48           /// close the editor
49           void closeDialog();
50
51           DocumentDelegate( QDockWidget *dw, QObject *parent = 0);
52
53           /// create the editor
54           QWidget *createEditor( QWidget *parent,
55                                  const QStyleOptionViewItem &option,
56                                  const QModelIndex &index) const;
57
58           /// set editor's data
59           void setEditorData( QWidget *editor, const QModelIndex &index) const;
60
61           /// set the editor's model
62           void setModelData( QWidget            *editor,
63                              QAbstractItemModel *model,
64                              const QModelIndex  &index ) const {};
65
66           virtual void updateEditorGeometry( QWidget *editor,
67                                      const QStyleOptionViewItem &option,
68                                      const QModelIndex &index ) const {};
69
70       protected:
71           mutable QWidget* _currentEditor;
72           virtual bool editorEvent ( QEvent * event,
73                           QAbstractItemModel * model,
74                           const QStyleOptionViewItem & option, const QModelIndex & index );
75           virtual bool  eventFilter ( QObject * editor, QEvent * event );
76
77       private:
78           QDockWidget* _dw; // creator's container
79
80       private slots:
81          // void commitEditor();
82
83       };
84   }
85 }
86
87 #endif