itom  4.1.0
Property.h
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 Lesser General Public License as published by the Free Software
12 // Foundation; either version 2 of the License, or (at your option) any later
13 // version.
14 //
15 // This program is distributed in the hope that it will be useful, but WITHOUT
16 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public License along with
20 // this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21 // Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22 // http://www.gnu.org/copyleft/lesser.txt.
23 //
24 // *************************************************************************************************
25 
26 #ifndef PROPERTY_H_
27 #define PROPERTY_H_
28 
29 #include "defines.h"
30 #include <qwidget.h>
31 #include <qstyleoption.h>
32 #include <qvariant.h>
33 #include <qfont.h>
34 
40 class QPROPERTYEDITOR_EXPORT Property : public QObject
41 {
42  Q_OBJECT
43 
44 public:
45 
53  Property(const QString& name = QString(), QObject* propertyObject = 0, QObject* parent = 0);
54 
59  virtual QVariant value(int role = Qt::UserRole) const;
60 
65  virtual QString displayValue(int role = Qt::UserRole) const;
66 
71  virtual void setValue(const QVariant& value);
72 
77  QObject* propertyObject() {return m_propertyObject;}
78 
83  bool isRoot() {return m_propertyObject == 0;}
84 
89  bool isReadOnly();
90 
95  int row() {return parent()->children().indexOf(this);}
96 
101  QString editorHints() {return m_hints;}
102 
107  virtual void setEditorHints(const QString& hints) {m_hints = hints;}
108 
109  QString info() { return m_info; }
110  virtual void setInfo(const QString& info) {m_info = info;}
111 
112  bool enabled() { return m_enabled; }
113  virtual void setEnabled(bool enabled);
114 
121  virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option);
122 
127  virtual QVariant editorData(QWidget *editor);
128 
135  virtual bool setEditorData(QWidget *editor, const QVariant& data);
136 
142  Property* findPropertyObject(QObject* propertyObject);
143 
144 private slots:
150  void setValue(double value);
156  void setValue(int value);
157 
158  void setValue(QColor value);
159 
160  void setValue(bool value);
161 
162  void setValue(QFont value);
163 
164  void setValue(QStringList value);
165 
166 protected:
167  QObject* m_propertyObject;
168  QString m_hints;
169  QString m_info;
170  bool m_enabled;
171 
172 };
173 
174 #endif
int row()
Definition: Property.h:95
bool isRoot()
Definition: Property.h:83
QString editorHints()
Definition: Property.h:101
Definition: Property.h:40
QObject * propertyObject()
Definition: Property.h:77
virtual void setEditorHints(const QString &hints)
Definition: Property.h:107