1
/***************************************************************************
2
* Copyright (c) 2004 Werner Mayer <werner.wm.mayer@gmx.de> *
4
* This file is part of the FreeCAD CAx development system. *
6
* This library is free software; you can redistribute it and/or *
7
* modify it under the terms of the GNU Library General Public *
8
* License as published by the Free Software Foundation; either *
9
* version 2 of the License, or (at your option) any later version. *
11
* This library is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU Library General Public License for more details. *
16
* You should have received a copy of the GNU Library General Public *
17
* License along with this library; see the file COPYING.LIB. If not, *
18
* write to the Free Software Foundation, Inc., 59 Temple Place, *
19
* Suite 330, Boston, MA 02111-1307, USA *
21
***************************************************************************/
24
#ifndef PROPERTYEDITORITEM_H
25
#define PROPERTYEDITORITEM_H
28
# include <Gui/Qt4All.h>
33
#include <Base/Type.h>
34
#include <Base/Vector3D.h>
35
#include <Base/Placement.h>
36
#include <App/PropertyStandard.h>
38
Q_DECLARE_METATYPE(Base::Vector3f)
39
Q_DECLARE_METATYPE(Base::Placement)
42
namespace PropertyEditor {
44
class GuiExport PropertyItem : virtual public QObject, public Base::BaseClass
53
/** Sets the current property objects. */
54
void setPropertyData( const std::vector<App::Property*>& );
55
const std::vector<App::Property*>& getPropertyData() const;
57
/** Creates the appropriate editor for this item and sets the editor to the value of overrideValue(). */
58
virtual QWidget* createEditor(QWidget* parent, const QObject* receiver, const char* method) const;
59
virtual void setEditorData(QWidget *editor, const QVariant& data) const;
60
virtual QVariant editorData(QWidget *editor) const;
61
virtual bool isSeparator() const { return false; }
63
void setParent(PropertyItem* parent);
64
PropertyItem *parent() const;
65
void appendChild(PropertyItem *child);
67
void setReadOnly(bool);
68
bool isReadOnly() const;
70
PropertyItem *child(int row);
71
int childCount() const;
72
int columnCount() const;
73
QString propertyName() const;
74
void setPropertyName(const QString&);
75
void setPropertyValue(const QString&);
76
QVariant data(int column, int role) const;
77
bool setData (const QVariant& value);
78
Qt::ItemFlags flags(int column) const;
85
virtual QVariant decoration(const App::Property*) const;
86
virtual QVariant toolTip(const App::Property*) const;
87
virtual QVariant toString(const QVariant&) const;
88
virtual QVariant value(const App::Property*) const;
89
virtual void setValue(const QVariant&);
90
QString pythonIdentifier(const App::Property*) const;
95
std::vector<App::Property*> propertyItems;
96
PropertyItem *parentItem;
97
QList<PropertyItem*> childItems;
102
* Change a string property.
103
* \author Werner Mayer
105
class GuiExport PropertyStringItem: public PropertyItem
109
virtual QWidget* createEditor(QWidget* parent, const QObject* receiver, const char* method) const;
110
virtual void setEditorData(QWidget *editor, const QVariant& data) const;
111
virtual QVariant editorData(QWidget *editor) const;
114
virtual QVariant value(const App::Property*) const;
115
virtual void setValue(const QVariant&);
118
PropertyStringItem();
122
* Dummy property to separate groups of properties.
123
* \author Werner Mayer
125
class GuiExport PropertySeparatorItem : public PropertyItem
129
bool isSeparator() const { return true; }
130
QWidget* createEditor(QWidget* parent, const QObject* receiver, const char* method) const;
135
* \author Werner Mayer
137
class GuiExport PropertyIntegerItem: public PropertyItem
141
virtual QWidget* createEditor(QWidget* parent, const QObject* receiver, const char* method) const;
142
virtual void setEditorData(QWidget *editor, const QVariant& data) const;
143
virtual QVariant editorData(QWidget *editor) const;
146
virtual QVariant value(const App::Property*) const;
147
virtual void setValue(const QVariant&);
150
PropertyIntegerItem();
154
* Change a number with constraints.
155
* \author Werner Mayer
157
class GuiExport PropertyIntegerConstraintItem: public PropertyItem
161
virtual QWidget* createEditor(QWidget* parent, const QObject* receiver, const char* method) const;
162
virtual void setEditorData(QWidget *editor, const QVariant& data) const;
163
virtual QVariant editorData(QWidget *editor) const;
166
virtual QVariant value(const App::Property*) const;
167
virtual void setValue(const QVariant&);
170
PropertyIntegerConstraintItem();
174
* Change a floating point number.
175
* \author Werner Mayer
177
class GuiExport PropertyFloatItem: public PropertyItem
181
virtual QWidget* createEditor(QWidget* parent, const QObject* receiver, const char* method) const;
182
virtual void setEditorData(QWidget *editor, const QVariant& data) const;
183
virtual QVariant editorData(QWidget *editor) const;
186
virtual QVariant toString(const QVariant&) const;
187
virtual QVariant value(const App::Property*) const;
188
virtual void setValue(const QVariant&);
195
* Change a floating point number with constraints.
196
* \author Werner Mayer
198
class GuiExport PropertyFloatConstraintItem: public PropertyItem
202
virtual QWidget* createEditor(QWidget* parent, const QObject* receiver, const char* method) const;
203
virtual void setEditorData(QWidget *editor, const QVariant& data) const;
204
virtual QVariant editorData(QWidget *editor) const;
207
virtual QVariant toString(const QVariant&) const;
208
virtual QVariant value(const App::Property*) const;
209
virtual void setValue(const QVariant&);
212
PropertyFloatConstraintItem();
216
* Edit properties of boolean type.
217
* \author Werner Mayer
219
class GuiExport PropertyBoolItem: public PropertyItem
223
virtual QWidget* createEditor(QWidget* parent, const QObject* receiver, const char* method) const;
224
virtual void setEditorData(QWidget *editor, const QVariant& data) const;
225
virtual QVariant editorData(QWidget *editor) const;
228
virtual QVariant value(const App::Property*) const;
229
virtual void setValue(const QVariant&);
236
* Edit properties of vector type.
237
* \author Werner Mayer
239
class PropertyFloatItem;
240
class GuiExport PropertyVectorItem: public PropertyItem
243
Q_PROPERTY(double x READ x WRITE setX DESIGNABLE true USER true)
244
Q_PROPERTY(double y READ y WRITE setY DESIGNABLE true USER true)
245
Q_PROPERTY(double z READ z WRITE setZ DESIGNABLE true USER true)
248
virtual QWidget* createEditor(QWidget* parent, const QObject* receiver, const char* method) const;
249
virtual void setEditorData(QWidget *editor, const QVariant& data) const;
250
virtual QVariant editorData(QWidget *editor) const;
260
virtual QVariant toString(const QVariant&) const;
261
virtual QVariant value(const App::Property*) const;
262
virtual void setValue(const QVariant&);
265
PropertyVectorItem();
268
PropertyFloatItem* m_x;
269
PropertyFloatItem* m_y;
270
PropertyFloatItem* m_z;
274
* Edit properties of placement type.
275
* \author Werner Mayer
277
class GuiExport PropertyPlacementItem: public PropertyItem
280
Q_PROPERTY(QString Axis READ getAxis)
281
Q_PROPERTY(QString Angle READ getAngle)
282
Q_PROPERTY(QString Position READ getPosition)
285
virtual QWidget* createEditor(QWidget* parent, const QObject* receiver, const char* method) const;
286
virtual void setEditorData(QWidget *editor, const QVariant& data) const;
287
virtual QVariant editorData(QWidget *editor) const;
289
QString getAxis() const;
290
QString getAngle() const;
291
QString getPosition() const;
294
PropertyPlacementItem();
295
virtual QVariant toolTip(const App::Property*) const;
296
virtual QVariant toString(const QVariant&) const;
297
virtual QVariant value(const App::Property*) const;
298
virtual void setValue(const QVariant&);
301
PropertyStringItem* m_d;
302
PropertyStringItem* m_a;
303
PropertyStringItem* m_p;
307
* Edit properties of enum type.
308
* \author Werner Mayer
310
class GuiExport PropertyEnumItem: public PropertyItem
314
virtual QWidget* createEditor(QWidget* parent, const QObject* receiver, const char* method) const;
315
virtual void setEditorData(QWidget *editor, const QVariant& data) const;
316
virtual QVariant editorData(QWidget *editor) const;
319
virtual QVariant value(const App::Property*) const;
320
virtual void setValue(const QVariant&);
327
* Edit properties of enum type.
328
* \author Werner Mayer
330
class GuiExport PropertyStringListItem: public PropertyItem
334
virtual QWidget* createEditor(QWidget* parent, const QObject* receiver, const char* method) const;
335
virtual void setEditorData(QWidget *editor, const QVariant& data) const;
336
virtual QVariant editorData(QWidget *editor) const;
339
QVariant toString(const QVariant&) const;
340
virtual QVariant value(const App::Property*) const;
341
virtual void setValue(const QVariant&);
344
PropertyStringListItem();
348
* Change a color property.
349
* \author Werner Mayer
351
class GuiExport PropertyColorItem: public PropertyItem
355
virtual QWidget* createEditor(QWidget* parent, const QObject* receiver, const char* method) const;
356
virtual void setEditorData(QWidget *editor, const QVariant& data) const;
357
virtual QVariant editorData(QWidget *editor) const;
360
virtual QVariant decoration(const App::Property*) const;
361
virtual QVariant toString(const QVariant&) const;
362
virtual QVariant value(const App::Property*) const;
363
virtual void setValue(const QVariant&);
371
* \author Werner Mayer
373
class GuiExport PropertyFileItem: public PropertyItem
378
virtual QVariant value(const App::Property*) const;
379
virtual void setValue(const QVariant&);
383
virtual QVariant toolTip(const App::Property*) const;
388
* \author Werner Mayer
390
class GuiExport PropertyPathItem: public PropertyItem
395
virtual QVariant value(const App::Property*) const;
396
virtual void setValue(const QVariant&);
402
class PropertyItemEditorFactory : public QItemEditorFactory
405
PropertyItemEditorFactory();
406
virtual ~PropertyItemEditorFactory();
408
virtual QWidget * createEditor ( QVariant::Type type, QWidget * parent ) const;
409
virtual QByteArray valuePropertyName ( QVariant::Type type ) const;
412
} // namespace PropertyEditor
415
#endif // PROPERTYEDITORITEM_H