1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2011 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 <QtDesigner/extension.h>
|
---|
43 |
|
---|
44 | QT_BEGIN_NAMESPACE
|
---|
45 |
|
---|
46 | /*!
|
---|
47 | \class QAbstractExtensionFactory
|
---|
48 |
|
---|
49 | \brief The QAbstractExtensionFactory class provides an interface
|
---|
50 | for extension factories in Qt Designer.
|
---|
51 |
|
---|
52 | \inmodule QtDesigner
|
---|
53 |
|
---|
54 | QAbstractExtensionFactory is not intended to be instantiated
|
---|
55 | directly; use the QExtensionFactory instead.
|
---|
56 |
|
---|
57 | In \QD, extension factories are used to look up and create named
|
---|
58 | extensions as they are required. For that reason, when
|
---|
59 | implementing a custom extension, you must also create a
|
---|
60 | QExtensionFactory, i.e a class that is able to make an instance of
|
---|
61 | your extension, and register it using \QD's \l
|
---|
62 | {QExtensionManager}{extension manager}.
|
---|
63 |
|
---|
64 | When an extension is required, \QD's \l
|
---|
65 | {QExtensionManager}{extension manager} will run through all its
|
---|
66 | registered factories calling QExtensionFactory::createExtension()
|
---|
67 | for each until the first one that is able to create the requested
|
---|
68 | extension for the selected object, is found. This factory will
|
---|
69 | then make an instance of the extension.
|
---|
70 |
|
---|
71 | \sa QExtensionFactory, QExtensionManager
|
---|
72 | */
|
---|
73 |
|
---|
74 | /*!
|
---|
75 | \fn QAbstractExtensionFactory::~QAbstractExtensionFactory()
|
---|
76 |
|
---|
77 | Destroys the extension factory.
|
---|
78 | */
|
---|
79 |
|
---|
80 | /*!
|
---|
81 | \fn QObject *QAbstractExtensionFactory::extension(QObject *object, const QString &iid) const
|
---|
82 |
|
---|
83 | Returns the extension specified by \a iid for the given \a object.
|
---|
84 | */
|
---|
85 |
|
---|
86 |
|
---|
87 | /*!
|
---|
88 | \class QAbstractExtensionManager
|
---|
89 |
|
---|
90 | \brief The QAbstractExtensionManager class provides an interface
|
---|
91 | for extension managers in Qt Designer.
|
---|
92 |
|
---|
93 | \inmodule QtDesigner
|
---|
94 |
|
---|
95 | QAbstractExtensionManager is not intended to be instantiated
|
---|
96 | directly; use the QExtensionManager instead.
|
---|
97 |
|
---|
98 | In \QD, extension are not created until they are required. For
|
---|
99 | that reason, when implementing a custom extension, you must also
|
---|
100 | create a QExtensionFactory, i.e a class that is able to make an
|
---|
101 | instance of your extension, and register it using \QD's \l
|
---|
102 | {QExtensionManager}{extension manager}.
|
---|
103 |
|
---|
104 | When an extension is required, \QD's \l
|
---|
105 | {QExtensionManager}{extension manager} will run through all its
|
---|
106 | registered factories calling QExtensionFactory::createExtension()
|
---|
107 | for each until the first one that is able to create the requested
|
---|
108 | extension for the selected object, is found. This factory will
|
---|
109 | then make an instance of the extension.
|
---|
110 |
|
---|
111 | \sa QExtensionManager, QExtensionFactory
|
---|
112 | */
|
---|
113 |
|
---|
114 | /*!
|
---|
115 | \fn QAbstractExtensionManager::~QAbstractExtensionManager()
|
---|
116 |
|
---|
117 | Destroys the extension manager.
|
---|
118 | */
|
---|
119 |
|
---|
120 | /*!
|
---|
121 | \fn void QAbstractExtensionManager::registerExtensions(QAbstractExtensionFactory *factory, const QString &iid)
|
---|
122 |
|
---|
123 | Register the given extension \a factory with the extension
|
---|
124 | specified by \a iid.
|
---|
125 | */
|
---|
126 |
|
---|
127 | /*!
|
---|
128 | \fn void QAbstractExtensionManager::unregisterExtensions(QAbstractExtensionFactory *factory, const QString &iid)
|
---|
129 |
|
---|
130 | Unregister the given \a factory with the extension specified by \a
|
---|
131 | iid.
|
---|
132 | */
|
---|
133 |
|
---|
134 | /*!
|
---|
135 | \fn QObject *QAbstractExtensionManager::extension(QObject *object, const QString &iid) const
|
---|
136 |
|
---|
137 | Returns the extension, specified by \a iid, for the given \a
|
---|
138 | object.
|
---|
139 | */
|
---|
140 |
|
---|
141 | /*!
|
---|
142 | \fn T qt_extension(QAbstractExtensionManager* manager, QObject *object)
|
---|
143 |
|
---|
144 | \relates QExtensionManager
|
---|
145 |
|
---|
146 | Returns the extension of the given \a object cast to type T if the
|
---|
147 | object is of type T (or of a subclass); otherwise returns 0. The
|
---|
148 | extension is retrieved using the given extension \a manager.
|
---|
149 |
|
---|
150 | \snippet doc/src/snippets/code/tools_designer_src_lib_extension_extension.cpp 0
|
---|
151 |
|
---|
152 | When implementing a custom widget plugin, a pointer to \QD's
|
---|
153 | current QDesignerFormEditorInterface object (\c formEditor) is
|
---|
154 | provided by the QDesignerCustomWidgetInterface::initialize()
|
---|
155 | function's parameter.
|
---|
156 |
|
---|
157 | If the widget in the example above doesn't have a defined
|
---|
158 | QDesignerPropertySheetExtension, \c propertySheet will be a null
|
---|
159 | pointer.
|
---|
160 |
|
---|
161 | */
|
---|
162 |
|
---|
163 | /*!
|
---|
164 | \macro Q_DECLARE_EXTENSION_INTERFACE(ExtensionName, Identifier)
|
---|
165 |
|
---|
166 | \relates QExtensionManager
|
---|
167 |
|
---|
168 | Associates the given \a Identifier (a string literal) to the
|
---|
169 | extension class called \a ExtensionName. The \a Identifier must be
|
---|
170 | unique. For example:
|
---|
171 |
|
---|
172 | \snippet doc/src/snippets/code/tools_designer_src_lib_extension_extension.cpp 1
|
---|
173 |
|
---|
174 | Using the company and product names is a good way to ensure
|
---|
175 | uniqueness of the identifier.
|
---|
176 |
|
---|
177 | When implementing a custom extension class, you must use
|
---|
178 | Q_DECLARE_EXTENSION_INTERFACE() to enable usage of the
|
---|
179 | qt_extension() function. The macro is normally located right after the
|
---|
180 | class definition for \a ExtensionName, in the associated header
|
---|
181 | file.
|
---|
182 |
|
---|
183 | \sa Q_DECLARE_INTERFACE()
|
---|
184 | */
|
---|
185 |
|
---|
186 | QT_END_NAMESPACE
|
---|