RioEngine  0.1
My first attempt to create a 3D WYSIWYG Game Engine
property.h
Go to the documentation of this file.
1 // *************************************************************************************************
2 //
3 // QPropertyEditor v 0.3
4 //
5 // --------------------------------------
6 // Copyright (C) 2007 Volker Wiendl
7 // Acknowledgements to Roman alias banal from qt-apps.org for the Enum enhancement
8 //
9 //
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
13 //
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.
18 //
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/>.
21 //
22 // *************************************************************************************************
23 
24 #ifndef PROPERTY_H_
25 #define PROPERTY_H_
26 
27 #include <QtWidgets/QWidget>
28 #include <QtWidgets/QStyleOption>
29 #include <QtCore/QVariant>
30 
36 class Property : public QObject
37 {
38  Q_OBJECT
39 
40 public:
41 
49  Property(const QString& name = QString(), QObject* propertyObject = 0, QObject* parent = 0);
50 
55  virtual QVariant value(int role = Qt::UserRole) const;
60  virtual void setValue(const QVariant& value);
61 
66  QObject* propertyObject() {return m_propertyObject;}
67 
72  bool isRoot() {return m_propertyObject == 0;}
73 
78  bool isReadOnly();
79 
84  int row() {return parent()->children().indexOf(this);}
85 
90  QString editorHints() {return m_hints;}
91 
96  virtual void setEditorHints(const QString& hints) {m_hints = hints;}
97 
104  virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option);
105 
110  virtual QVariant editorData(QWidget *editor);
111 
118  virtual bool setEditorData(QWidget *editor, const QVariant& data);
119 
126 
127 private slots:
133  void setValue(double value);
139  void setValue(int value);
140 
141 protected:
143  QString m_hints;
144 
145 Q_SIGNALS:
146  void propertyChanged(QObject*, QString, QVariant, QVariant);
147 };
148 
149 #endif
void propertyChanged(QObject *, QString, QVariant, QVariant)
Property(const QString &name=QString(), QObject *propertyObject=0, QObject *parent=0)
Definition: property.cpp:31
int row()
Definition: property.h:84
virtual void setValue(const QVariant &value)
Definition: property.cpp:51
QObject * m_propertyObject
Definition: property.h:142
virtual QVariant editorData(QWidget *editor)
Definition: property.cpp:122
bool isRoot()
Definition: property.h:72
virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option)
Definition: property.cpp:71
QString editorHints()
Definition: property.h:90
QString m_hints
Definition: property.h:143
virtual bool setEditorData(QWidget *editor, const QVariant &data)
Definition: property.cpp:98
virtual QVariant value(int role=Qt::UserRole) const
Definition: property.cpp:43
bool isReadOnly()
Definition: property.cpp:61
QObject * propertyObject()
Definition: property.h:66
Property * findPropertyObject(QObject *propertyObject)
Definition: property.cpp:139
virtual void setEditorHints(const QString &hints)
Definition: property.h:96