itom
Loading...
Searching...
No Matches
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 <qfont.h>
31#include <qstyleoption.h>
32#include <qvariant.h>
33#include <qwidget.h>
34
40class QPROPERTYEDITOR_EXPORT Property : public QObject
41{
42 Q_OBJECT
43
44public:
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()
78 {
79 return m_propertyObject;
80 }
81
87 bool isRoot()
88 {
89 return m_propertyObject == 0;
90 }
91
96 bool isReadOnly();
97
102 int row()
103 {
104 return parent()->children().indexOf(this);
105 }
106
113 QString editorHints()
114 {
115 return m_hints;
116 }
117
124 virtual void setEditorHints(const QString& hints)
125 {
126 m_hints = hints;
127 }
128
129 QString info()
130 {
131 return m_info;
132 }
133 virtual void setInfo(const QString& info)
134 {
135 m_info = info;
136 }
137
138 bool enabled()
139 {
140 return m_enabled;
141 }
142 virtual void setEnabled(bool enabled);
143
150 virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option);
151
156 virtual QVariant editorData(QWidget* editor);
157
165 virtual bool setEditorData(QWidget* editor, const QVariant& data);
166
172 Property* findPropertyObject(QObject* propertyObject);
173
174private slots:
180 void setValue(double value);
186 void setValue(int value);
187
188 void setValue(QColor value);
189
190 void setValue(bool value);
191
192 void setValue(QFont value);
193
194 void setValue(QStringList value);
195
196protected:
197 QObject* m_propertyObject;
198 QString m_hints;
199 QString m_info;
200 bool m_enabled;
201};
202
203#endif
Definition Property.h:41
int row()
Definition Property.h:102
QObject * propertyObject()
Definition Property.h:77
QString editorHints()
Definition Property.h:113
virtual void setEditorHints(const QString &hints)
Definition Property.h:124
bool isRoot()
Definition Property.h:87