diff options
Diffstat (limited to 'utils/wpseditor/gui/src/QPropertyEditor/QPropertyEditorWidget.h')
-rw-r--r-- | utils/wpseditor/gui/src/QPropertyEditor/QPropertyEditorWidget.h | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/utils/wpseditor/gui/src/QPropertyEditor/QPropertyEditorWidget.h b/utils/wpseditor/gui/src/QPropertyEditor/QPropertyEditorWidget.h new file mode 100644 index 0000000000..2dab87722a --- /dev/null +++ b/utils/wpseditor/gui/src/QPropertyEditor/QPropertyEditorWidget.h | |||
@@ -0,0 +1,113 @@ | |||
1 | // ************************************************************************************************* | ||
2 | // | ||
3 | // QPropertyEditor v 0.1 | ||
4 | // | ||
5 | // -------------------------------------- | ||
6 | // Copyright (C) 2007 Volker Wiendl | ||
7 | // | ||
8 | // | ||
9 | // This library is free software; you can redistribute it and/or | ||
10 | // modify it under the terms of the GNU Lesser General Public | ||
11 | // License as published by the Free Software Foundation; either | ||
12 | // version 2.1 of the License, or any later version. | ||
13 | // | ||
14 | // This library 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 GNU | ||
17 | // Lesser General Public License for more details. | ||
18 | // | ||
19 | // You should have received a copy of the GNU Lesser General Public | ||
20 | // License along with this library; if not, write to the Free Software | ||
21 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA | ||
22 | // | ||
23 | // ************************************************************************************************* | ||
24 | |||
25 | #ifndef QPROPERTYEDITORWIDGET_H_ | ||
26 | #define QPROPERTYEDITORWIDGET_H_ | ||
27 | |||
28 | #include <Qt/qtreeview.h> | ||
29 | |||
30 | class QPropertyModel; | ||
31 | class Property; | ||
32 | |||
33 | /** | ||
34 | * \mainpage QPropertyEditor | ||
35 | * | ||
36 | * \section intro_sec Introduction | ||
37 | * | ||
38 | * The main purpose for the QPropertyEditor is the visualization and manipulation of properties defined via the Q_PROPERTY macro in | ||
39 | * QObject based classes. | ||
40 | */ | ||
41 | |||
42 | /** | ||
43 | * \brief The QPropertyEditorWidget offers an easy to use mechanism to visualize properties of a class inherited from QObject. | ||
44 | * | ||
45 | * Qt provides a nice way to define class properties by using the Q_PROPERTY macro. The purpose of the QPropertyEditor | ||
46 | * is to visualize these properties in an easy way. | ||
47 | * | ||
48 | * To use the property editor, all you have to do is to create a class that defines it's properties by using Q_PROPERTY | ||
49 | * and to add this class by using the addObject() method of this QPropertyEditorWidget class. | ||
50 | * The QPropertyEditorWidget is inherited from QTreeView and will display the properties in a tree with two columns: Name and Value | ||
51 | * | ||
52 | * For basic data types the build in editor widgets of Qt will be used. The QPropertyEditor itself only defines an additional | ||
53 | * editor for QColor (based on the Color Editor Factory Example from Trolltech). But it can easily be extended by yourself | ||
54 | * either within the library or for special datatypes also outside of the library in your application. | ||
55 | */ | ||
56 | class QPropertyEditorWidget : public QTreeView { | ||
57 | Q_OBJECT | ||
58 | public: | ||
59 | |||
60 | /** | ||
61 | * A typedef for a callback used to create user defined properties for custom datatypes | ||
62 | */ | ||
63 | typedef Property* (*UserTypeCB)(const QString& name, QObject* propertyObject, Property* parent); | ||
64 | |||
65 | /** | ||
66 | * \brief Constructor | ||
67 | * | ||
68 | * Creates a new editor widget based on QTreeView | ||
69 | * @param parent optional parent widget | ||
70 | */ | ||
71 | QPropertyEditorWidget(QWidget* parent = 0); | ||
72 | |||
73 | /// Destructor | ||
74 | virtual ~QPropertyEditorWidget(); | ||
75 | |||
76 | /** | ||
77 | * Adds the user properties of the given class to the QPropertyModel associated with this view | ||
78 | * | ||
79 | * @param propertyObject the class inherited from QObject that contains user properties that should be | ||
80 | * managed by the QPropertyModel associated with this view | ||
81 | */ | ||
82 | void addObject(QObject* propertyObject); | ||
83 | |||
84 | /** | ||
85 | * Similar to the addObject() method this method adds the properties of the given class to the QPropertyModel | ||
86 | * associated with this view. But in contrast to addObject() it will clear the model before, removing all | ||
87 | * previously added objects. | ||
88 | * | ||
89 | * @param propertyObject the class inherited from QObject that contains user properties that should be | ||
90 | * managed by the QPropertyModel associated with this view | ||
91 | */ | ||
92 | void setObject(QObject* propertyObject); | ||
93 | |||
94 | /** | ||
95 | * Updates the view for the given object. This can be usefull if a property was changed programmatically instead | ||
96 | * of using the view. In this case the view normally will display the new property values only after the user clicked | ||
97 | * on it. To overcome this problem you can call updateObject with the object whose property was changed. | ||
98 | */ | ||
99 | void updateObject(QObject* propertyObject); | ||
100 | |||
101 | /** | ||
102 | * If you define custom datatypes outside of this library the QPropertyModel will check if you | ||
103 | * also defined a callback that is responsible to create custom property classes inherited from Property to handle | ||
104 | * these datatypes. With this method you can set such a callback that will create custom properties for custom datatypes. | ||
105 | */ | ||
106 | void setCustomPropertyCB(UserTypeCB callback); | ||
107 | |||
108 | private: | ||
109 | /// The Model for this view | ||
110 | QPropertyModel* m_model; | ||
111 | |||
112 | }; | ||
113 | #endif | ||