1
// *************************************************************************************************
3
// QPropertyEditor v 0.3
5
// --------------------------------------
6
// Copyright (C) 2007 Volker Wiendl
7
// Acknowledgements to Roman alias banal from qt-apps.org for the Enum enhancement
10
// The QPropertyEditor Library is free software; you can redistribute it and/or modify
11
// it under the terms of the GNU General Public License as published by
12
// the Free Software Foundation version 3 of the License
14
// The Horde3D Scene Editor is distributed in the hope that it will be useful,
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
// GNU General Public License for more details.
19
// You should have received a copy of the GNU General Public License
20
// along with this program. If not, see <http://www.gnu.org/licenses/>.
22
// *************************************************************************************************
23
/***************************************************************************
24
* Modified 2012 by santiago González *
25
* santigoro@gmail.com *
27
***************************************************************************/
32
//#include <QtGui/QWidget>
33
#include <QStyleOption>
36
//#include <QScriptEngine>
39
* The Property class is the base class for all properties in the QPropertyEditor
40
* You can implement custom properties inherited from this class to further enhence the
41
* functionality of the QPropertyEditor
43
class Property : public QObject
52
* @param name the name of the property within the propertyObject (will be used in the QPropertyEditorWidget view too)
53
* @param propertyObject the object that contains the property
54
* @param parent optional parent object
56
Property(const QString& name = QString(), QObject* propertyObject = 0, QObject* parent = 0);
59
* The value stored by this property
60
* @return QVariant the data converted to a QVariant
62
virtual QVariant value(int role = Qt::UserRole) const;
64
* Sets the value stored by this property
65
* @param value the data converted to a QVariant
67
virtual void setValue(const QVariant& value);
70
* Returns the QObject which contains the property managed by this instance
71
* @return QObject* pointer to the QObject that contains user defined properties
73
QObject* propertyObject() {return m_propertyObject;}
76
* Flag if property is used for indicating a group or really manages a property
77
* @return bool true if this property is only used to display a category in the QPropertyEditorWidget
79
bool isRoot() {return m_propertyObject == 0;}
82
* Flag if the property can be set
83
* @return bool true if this property has no set method
88
* Returns the row of this instance within the QPropertyModel
89
* @return int row within the QPropertyModel
91
int row() {return parent()->children().indexOf(this);}
94
* returns optional settings for the editor widget that is used to manipulate the properties value
95
* @return QString a string that contains property settings for the editor widget (e.g. "minimum=1.0;maximum=10.0;")
97
QString editorHints() {return m_hints;}
100
* Sets properties for the editor widget that is used to manipulate the data value managed by this instance
101
* @param hints a string containing property settings for the editor widget that manipulates this property
103
virtual void setEditorHints(const QString& hints) {m_hints = hints;}
106
* Creates an editor for the data managed by this instance
107
* @param parent widget the newly created editor widget will be child of
108
* @param option currently not used
109
* @return QWidget* pointer to the editor widget
111
virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option);
114
* Returns the data of the editor widget used to manipulate this instance
115
* @return QVariant the data converted to a QVariant
117
virtual QVariant editorData(QWidget *editor);
120
* Changes the editor widget's data to a specific value
121
* @param editor the editor widget
122
* @param data the data to set in the editor widget
123
* @return bool true if editor widget was set to the given data successfully, false if the data can not be set in the editor (e.g. wrong datatype)
125
virtual bool setEditorData(QWidget *editor, const QVariant& data);
128
* Tries to find the first property that manages the given propertyObject
129
* @param propertyObject
132
Property* findPropertyObject(QObject* propertyObject);
138
* This slot is used to immediately set the properties when the editor widget's value of a double or double
139
* property has changed
140
* @param value the new value
142
void setValue(double value);
144
* This slot is used to immediately set the properties when the editor widget's value of an integer
145
* property has changed
146
* @param value the new value
148
void setValue(int value);
151
QObject* m_propertyObject;
157
//======================================================================
159
/*class SpinBox : public QSpinBox
164
SpinBox( QWidget *parent );
166
int valueFromText(const QString &text) const override;
167
QString textFromValue(int value) const override;
170
QScriptEngine m_sEngine;