1 // Copyright (C) 2006-2014 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, or (at your option) any later version.
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
20 #ifndef _VALUEDELEGATE_HXX
21 #define _VALUEDELEGATE_HXX
23 #include "CaseSwitch.hxx"
25 #include <QItemDelegate>
26 #include <QModelIndex>
44 virtual ~GenericEditor();
45 virtual void setSubject(Subject* subject);
46 virtual void setColumn(int column);
47 virtual void setDelegate(const ValueDelegate* delegate);
48 virtual QString GetStrValue();
49 virtual Subject* getSubject();
50 virtual int getColumnInSubject();
51 virtual void setData(QVariant val);
52 virtual bool firstSetData();
56 const ValueDelegate* _delegate;
60 class GeneralEditor: public QLineEdit, public GenericEditor
65 GeneralEditor(Subject* subject,
66 const ValueDelegate* delegate,
69 virtual ~GeneralEditor();
70 virtual QString GetStrValue();
71 virtual void setData(QVariant val);
74 class NameEditor: public QLineEdit, public GenericEditor
79 NameEditor(Subject* subject,
80 const ValueDelegate* delegate,
83 virtual ~NameEditor();
84 virtual QString GetStrValue();
85 virtual void setData(QVariant val);
88 class IntEditor: public QSpinBox, public GenericEditor
93 IntEditor(Subject* subject,
94 const ValueDelegate* delegate,
98 virtual QString GetStrValue();
99 virtual void setData(QVariant val);
102 class CaseSwitchEditor: public CaseSwitch, public GenericEditor
107 CaseSwitchEditor(Subject* subject,
108 const ValueDelegate* delegate,
110 QWidget* parent = 0);
111 virtual ~CaseSwitchEditor();
112 virtual QString GetStrValue();
113 virtual void setData(QVariant val);
116 class ValueDelegate : public QItemDelegate
121 ValueDelegate(QObject *parent = 0);
122 virtual ~ValueDelegate();
124 virtual QWidget *createEditor(QWidget *parent,
125 const QStyleOptionViewItem &option,
126 const QModelIndex &index) const;
128 virtual void setEditorData(QWidget *editor,
129 const QModelIndex &index) const;
130 virtual void setModelData(QWidget *editor,
131 QAbstractItemModel *model,
132 const QModelIndex &index) const;
134 virtual void updateEditorGeometry(QWidget *editor,
135 const QStyleOptionViewItem &option,
136 const QModelIndex &index) const;
137 virtual void setResultEditing(QWidget *editor, bool isOk);
140 mutable std::map<Subject*, std::string> _errorMap;