1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
---|
4 | ** All rights reserved.
|
---|
5 | ** Contact: Nokia Corporation ([email protected])
|
---|
6 | **
|
---|
7 | ** This file is part of the Qt Designer of the Qt Toolkit.
|
---|
8 | **
|
---|
9 | ** $QT_BEGIN_LICENSE:LGPL$
|
---|
10 | ** Commercial Usage
|
---|
11 | ** Licensees holding valid Qt Commercial licenses may use this file in
|
---|
12 | ** accordance with the Qt Commercial License Agreement provided with the
|
---|
13 | ** Software or, alternatively, in accordance with the terms contained in
|
---|
14 | ** a written agreement between you and Nokia.
|
---|
15 | **
|
---|
16 | ** GNU Lesser General Public License Usage
|
---|
17 | ** Alternatively, this file may be used under the terms of the GNU Lesser
|
---|
18 | ** General Public License version 2.1 as published by the Free Software
|
---|
19 | ** Foundation and appearing in the file LICENSE.LGPL included in the
|
---|
20 | ** packaging of this file. Please review the following information to
|
---|
21 | ** ensure the GNU Lesser General Public License version 2.1 requirements
|
---|
22 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
---|
23 | **
|
---|
24 | ** In addition, as a special exception, Nokia gives you certain additional
|
---|
25 | ** rights. These rights are described in the Nokia Qt LGPL Exception
|
---|
26 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
---|
27 | **
|
---|
28 | ** GNU General Public License Usage
|
---|
29 | ** Alternatively, this file may be used under the terms of the GNU
|
---|
30 | ** General Public License version 3.0 as published by the Free Software
|
---|
31 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
32 | ** packaging of this file. Please review the following information to
|
---|
33 | ** ensure the GNU General Public License version 3.0 requirements will be
|
---|
34 | ** met: http://www.gnu.org/copyleft/gpl.html.
|
---|
35 | **
|
---|
36 | ** If you have questions regarding the use of this file, please contact
|
---|
37 | ** Nokia at [email protected].
|
---|
38 | ** $QT_END_LICENSE$
|
---|
39 | **
|
---|
40 | ****************************************************************************/
|
---|
41 |
|
---|
42 | #include "abstractpropertyeditor.h"
|
---|
43 |
|
---|
44 | QT_BEGIN_NAMESPACE
|
---|
45 |
|
---|
46 | /*!
|
---|
47 | \class QDesignerPropertyEditorInterface
|
---|
48 |
|
---|
49 | \brief The QDesignerPropertyEditorInterface class allows you to
|
---|
50 | query and manipulate the current state of Qt Designer's property
|
---|
51 | editor.
|
---|
52 |
|
---|
53 | \inmodule QtDesigner
|
---|
54 |
|
---|
55 | QDesignerPropertyEditorInterface contains a collection of
|
---|
56 | functions that is typically used to query the property editor for
|
---|
57 | its current state, and several slots manipulating it's state. The
|
---|
58 | interface also provide a signal, propertyChanged(), which is
|
---|
59 | emitted whenever a property changes in the property editor. The
|
---|
60 | signal's arguments are the property that changed and its new
|
---|
61 | value.
|
---|
62 |
|
---|
63 | For example, when implementing a custom widget plugin, you can
|
---|
64 | connect the signal to a custom slot:
|
---|
65 |
|
---|
66 | \snippet doc/src/snippets/code/tools_designer_src_lib_sdk_abstractpropertyeditor.cpp 0
|
---|
67 |
|
---|
68 | Then the custom slot can check if the new value is within the
|
---|
69 | range we want when a specified property, belonging to a particular
|
---|
70 | widget, changes:
|
---|
71 |
|
---|
72 | \snippet doc/src/snippets/code/tools_designer_src_lib_sdk_abstractpropertyeditor.cpp 1
|
---|
73 |
|
---|
74 | The QDesignerPropertyEditorInterface class is not intended to be
|
---|
75 | instantiated directly. You can retrieve an interface to \QD's
|
---|
76 | property editor using the
|
---|
77 | QDesignerFormEditorInterface::propertyEditor() function. A pointer
|
---|
78 | to \QD's current QDesignerFormEditorInterface object (\c
|
---|
79 | formEditor in the examples above) is provided by the
|
---|
80 | QDesignerCustomWidgetInterface::initialize() function's
|
---|
81 | parameter. When implementing a custom widget plugin, you must
|
---|
82 | subclass the QDesignerCustomWidgetInterface to expose your plugin
|
---|
83 | to \QD.
|
---|
84 |
|
---|
85 | The functions accessing the property editor are the core()
|
---|
86 | function that you can use to retrieve an interface to the form
|
---|
87 | editor, the currentPropertyName() function that returns the name
|
---|
88 | of the currently selected property in the property editor, the
|
---|
89 | object() function that returns the currently selected object in
|
---|
90 | \QD's workspace, and the isReadOnly() function that returns true
|
---|
91 | if the property editor is write proteced (otherwise false).
|
---|
92 |
|
---|
93 | The slots manipulating the property editor's state are the
|
---|
94 | setObject() slot that you can use to change the currently selected
|
---|
95 | object in \QD's workspace, the setPropertyValue() slot that
|
---|
96 | changes the value of a given property and the setReadOnly() slot
|
---|
97 | that control the write protection of the property editor.
|
---|
98 |
|
---|
99 | \sa QDesignerFormEditorInterface
|
---|
100 | */
|
---|
101 |
|
---|
102 | /*!
|
---|
103 | Constructs a property editor interface with the given \a parent and
|
---|
104 | the specified window \a flags.
|
---|
105 | */
|
---|
106 | QDesignerPropertyEditorInterface::QDesignerPropertyEditorInterface(QWidget *parent, Qt::WindowFlags flags)
|
---|
107 | : QWidget(parent, flags)
|
---|
108 | {
|
---|
109 | }
|
---|
110 |
|
---|
111 | /*!
|
---|
112 | Destroys the property editor interface.
|
---|
113 | */
|
---|
114 | QDesignerPropertyEditorInterface::~QDesignerPropertyEditorInterface()
|
---|
115 | {
|
---|
116 | }
|
---|
117 |
|
---|
118 | /*!
|
---|
119 | Returns a pointer to \QD's current QDesignerFormEditorInterface
|
---|
120 | object.
|
---|
121 | */
|
---|
122 | QDesignerFormEditorInterface *QDesignerPropertyEditorInterface::core() const
|
---|
123 | {
|
---|
124 | return 0;
|
---|
125 | }
|
---|
126 |
|
---|
127 | /*!
|
---|
128 | \fn bool QDesignerPropertyEditorInterface::isReadOnly() const
|
---|
129 |
|
---|
130 | Returns true if the property editor is write protected; otherwise
|
---|
131 | false.
|
---|
132 |
|
---|
133 | \sa setReadOnly()
|
---|
134 | */
|
---|
135 |
|
---|
136 | /*!
|
---|
137 | \fn QObject *QDesignerPropertyEditorInterface::object() const
|
---|
138 |
|
---|
139 | Returns the currently selected object in \QD's workspace.
|
---|
140 |
|
---|
141 | \sa setObject()
|
---|
142 | */
|
---|
143 |
|
---|
144 | /*!
|
---|
145 | \fn QString QDesignerPropertyEditorInterface::currentPropertyName() const
|
---|
146 |
|
---|
147 | Returns the name of the currently selected property in the
|
---|
148 | property editor.
|
---|
149 |
|
---|
150 | \sa setPropertyValue()
|
---|
151 | */
|
---|
152 |
|
---|
153 | /*!
|
---|
154 | \fn void QDesignerPropertyEditorInterface::propertyChanged(const QString &name, const QVariant &value)
|
---|
155 |
|
---|
156 | This signal is emitted whenever a property changes in the property
|
---|
157 | editor. The property that changed and its new value are specified
|
---|
158 | by \a name and \a value respectively.
|
---|
159 |
|
---|
160 | \sa setPropertyValue()
|
---|
161 | */
|
---|
162 |
|
---|
163 | /*!
|
---|
164 | \fn void QDesignerPropertyEditorInterface::setObject(QObject *object)
|
---|
165 |
|
---|
166 | Changes the currently selected object in \QD's workspace, to \a
|
---|
167 | object.
|
---|
168 |
|
---|
169 | \sa object()
|
---|
170 | */
|
---|
171 |
|
---|
172 | /*!
|
---|
173 | \fn void QDesignerPropertyEditorInterface::setPropertyValue(const QString &name, const QVariant &value, bool changed = true)
|
---|
174 |
|
---|
175 | Sets the value of the property specified by \a name to \a
|
---|
176 | value.
|
---|
177 |
|
---|
178 | In addition, the property is marked as \a changed in the property
|
---|
179 | editor, i.e. its value is different from the default value.
|
---|
180 |
|
---|
181 | \sa currentPropertyName(), propertyChanged()
|
---|
182 | */
|
---|
183 |
|
---|
184 | /*!
|
---|
185 | \fn void QDesignerPropertyEditorInterface::setReadOnly(bool readOnly)
|
---|
186 |
|
---|
187 | If \a readOnly is true, the property editor is made write
|
---|
188 | protected; otherwise the write protection is removed.
|
---|
189 |
|
---|
190 | \sa isReadOnly()
|
---|
191 | */
|
---|
192 |
|
---|
193 | QT_END_NAMESPACE
|
---|