1 // Copyright (C) 2006-2008 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 _VALUEDELEGATE_HXX
20 #define _VALUEDELEGATE_HXX
22 #include "CaseSwitch.hxx"
24 #include <QItemDelegate>
25 #include <QModelIndex>
43 virtual ~GenericEditor();
44 virtual void setSubject(Subject* subject);
45 virtual void setColumn(int column);
46 virtual void setDelegate(const ValueDelegate* delegate);
47 virtual QString GetStrValue();
48 virtual Subject* getSubject();
49 virtual int getColumnInSubject();
50 virtual void setData(QVariant val);
51 virtual bool firstSetData();
55 const ValueDelegate* _delegate;
59 class GeneralEditor: public QLineEdit, public GenericEditor
64 GeneralEditor(Subject* subject,
65 const ValueDelegate* delegate,
68 virtual ~GeneralEditor();
69 virtual QString GetStrValue();
70 virtual void setData(QVariant val);
73 class IntEditor: public QSpinBox, public GenericEditor
78 IntEditor(Subject* subject,
79 const ValueDelegate* delegate,
83 virtual QString GetStrValue();
84 virtual void setData(QVariant val);
87 class CaseSwitchEditor: public CaseSwitch, public GenericEditor
92 CaseSwitchEditor(Subject* subject,
93 const ValueDelegate* delegate,
96 virtual ~CaseSwitchEditor();
97 virtual QString GetStrValue();
98 virtual void setData(QVariant val);
101 class ValueDelegate : public QItemDelegate
106 ValueDelegate(QObject *parent = 0);
107 virtual ~ValueDelegate();
109 virtual QWidget *createEditor(QWidget *parent,
110 const QStyleOptionViewItem &option,
111 const QModelIndex &index) const;
113 virtual void setEditorData(QWidget *editor,
114 const QModelIndex &index) const;
115 virtual void setModelData(QWidget *editor,
116 QAbstractItemModel *model,
117 const QModelIndex &index) const;
119 virtual void updateEditorGeometry(QWidget *editor,
120 const QStyleOptionViewItem &option,
121 const QModelIndex &index) const;
122 virtual void setResultEditing(QWidget *editor, bool isOk);
125 mutable std::map<Subject*, std::string> _errorMap;