1 /****************************************************************************
2 **
3 ** Copyright (C) 2015 The Qt Company Ltd.
4 ** Contact: http://www.qt.io/licensing/
5 **
6 ** This file is part of the Qt Designer of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see http://www.qt.io/terms-conditions. For further
15 ** information use the contact form at http://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 or version 3 as published by the Free
20 ** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21 ** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22 ** following information to ensure the GNU Lesser General Public License
23 ** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25 **
26 ** As a special exception, The Qt Company gives you certain additional
27 ** rights. These rights are described in The Qt Company LGPL Exception
28 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29 **
30 ** GNU General Public License Usage
31 ** Alternatively, this file may be used under the terms of the GNU
32 ** General Public License version 3.0 as published by the Free Software
33 ** Foundation and appearing in the file LICENSE.GPL included in the
34 ** packaging of this file.  Please review the following information to
35 ** ensure the GNU General Public License version 3.0 requirements will be
36 ** met: http://www.gnu.org/copyleft/gpl.html.
37 **
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 */
QDesignerPropertyEditorInterface(QWidget * parent,Qt::WindowFlags flags)106 QDesignerPropertyEditorInterface::QDesignerPropertyEditorInterface(QWidget *parent, Qt::WindowFlags flags)
107     : QWidget(parent, flags)
108 {
109 }
110 
111 /*!
112     Destroys the property editor interface.
113 */
~QDesignerPropertyEditorInterface()114 QDesignerPropertyEditorInterface::~QDesignerPropertyEditorInterface()
115 {
116 }
117 
118 /*!
119     Returns a pointer to \QD's current QDesignerFormEditorInterface
120     object.
121 */
core() const122 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
194