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 <qwidget.h>
30#include <qstyleoption.h>
31#include <qvariant.h>
32
38class Property : public QObject
39{
40 Q_OBJECT
41
42public:
43
51 Property(const QString& name = QString(), QObject* propertyObject = 0, QObject* parent = 0);
52
57 virtual QVariant value(int role = Qt::UserRole) const;
62 virtual void setValue(const QVariant& value);
63
68 QObject* propertyObject() {return m_propertyObject;}
69
74 bool isRoot() {return m_propertyObject == 0;}
75
80 bool isReadOnly();
81
86 int row() {return parent()->children().indexOf(this);}
87
92 QString editorHints() {return m_hints;}
93
98 virtual void setEditorHints(const QString& hints) {m_hints = hints;}
99
106 virtual QWidget* createEditor(QWidget* parent, const QStyleOptionViewItem& option);
107
112 virtual QVariant editorData(QWidget *editor);
113
120 virtual bool setEditorData(QWidget *editor, const QVariant& data);
121
128
129private slots:
135 void setValue(double value);
141 void setValue(int value);
142
143 void setValue(QColor value);
144
145 void setValue(bool value);
146
147protected:
148 QObject* m_propertyObject;
149 QString m_hints;
150
151};
152
153#endif
Definition Property.h:41
int row()
Definition Property.h:86
virtual void setValue(const QVariant &value)
QObject * propertyObject()
Definition Property.h:77
void setValue(int value)
bool isReadOnly()
virtual QVariant value(int role=Qt::UserRole) const
QString editorHints()
Definition Property.h:92
virtual QVariant editorData(QWidget *editor)
virtual void setEditorHints(const QString &hints)
Definition Property.h:98
virtual QVariant value(int role=Qt::UserRole) const
Definition Property.cpp:50
Property * findPropertyObject(QObject *propertyObject)
virtual QWidget * createEditor(QWidget *parent, const QStyleOptionViewItem &option)
virtual bool setEditorData(QWidget *editor, const QVariant &data)
bool isRoot()
Definition Property.h:74
Property(const QString &name=QString(), QObject *propertyObject=0, QObject *parent=0)
virtual void setValue(const QVariant &value)
Definition Property.cpp:102
void setValue(double value)