1 // Copyright (C) 2009-2012 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #ifndef __HEXABLOCKGUI_DOCUMENTDELEGATE_HXX_
20 #define __HEXABLOCKGUI_DOCUMENTDELEGATE_HXX_
23 // QEvent * event, QAbstractItemModel
26 #include <QItemDelegate>
27 #include <QModelIndex>
32 #include <QDockWidget>
35 #include "HEXABLOCKGUI_DocumentModel.hxx"
36 #include "HEXABLOCKGUI_DocumentSelectionModel.hxx"
37 #include "HEXABLOCKGUI_DocumentItem.hxx"
38 #include "HEXABLOCKGUI_DocumentPanel.hxx"
44 class DocumentDelegate : public QItemDelegate
50 DocumentDelegate( QDockWidget *dw, QObject *parent = 0);
52 QWidget *createEditor( QWidget *parent,
53 const QStyleOptionViewItem &option,
54 const QModelIndex &index) const;
56 void setEditorData( QWidget *editor, const QModelIndex &index) const;
58 void setModelData( QWidget *editor,
59 QAbstractItemModel *model,
60 const QModelIndex &index ) const {};
62 virtual void updateEditorGeometry( QWidget *editor,
63 const QStyleOptionViewItem &option,
64 const QModelIndex &index ) const {};
66 //Can be used by editor
67 void setDocumentModel( DocumentModel* m ){_documentModel = m;}
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;}
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 );
83 // void onCloseEditor( QWidget *, QAbstractItemDelegate::EndEditHint);
84 // void onCommitData ( QWidget * editor );
87 QDockWidget* _dw; // creator's container
89 // can be used by editor
90 DocumentModel* _documentModel;
92 PatternDataSelectionModel* _patternDataSelectionModel;
93 PatternBuilderSelectionModel* _patternBuilderSelectionModel;
94 GroupsSelectionModel* _groupsSelectionModel;
95 MeshSelectionModel* _meshSelectionModel;