author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 19 Feb 2010 23:40:16 +0200 | |
branch | RCL_3 |
changeset 4 | 3b1da2848fc7 |
parent 0 | 1918ee327afb |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the Qt Designer of the Qt Toolkit. |
|
8 |
** |
|
9 |
** $QT_BEGIN_LICENSE:LGPL$ |
|
10 |
** No Commercial Usage |
|
11 |
** This file contains pre-release code and may not be distributed. |
|
12 |
** You may use this file in accordance with the terms and conditions |
|
13 |
** contained in the Technology Preview License Agreement accompanying |
|
14 |
** this package. |
|
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 |
** If you have questions regarding the use of this file, please contact |
|
29 |
** Nokia at qt-info@nokia.com. |
|
30 |
** |
|
31 |
** |
|
32 |
** |
|
33 |
** |
|
34 |
** |
|
35 |
** |
|
36 |
** |
|
37 |
** |
|
38 |
** $QT_END_LICENSE$ |
|
39 |
** |
|
40 |
****************************************************************************/ |
|
41 |
||
42 |
#include "abstractwidgetbox.h" |
|
43 |
||
44 |
QT_BEGIN_NAMESPACE |
|
45 |
||
46 |
/*! |
|
47 |
\class QDesignerWidgetBoxInterface |
|
48 |
||
49 |
\brief The QDesignerWidgetBoxInterface class allows you to control |
|
50 |
the contents of Qt Designer's widget box. |
|
51 |
||
52 |
\inmodule QtDesigner |
|
53 |
||
54 |
QDesignerWidgetBoxInterface contains a collection of functions |
|
55 |
that is typically used to manipulate the contents of \QD's widget |
|
56 |
box. |
|
57 |
||
58 |
\QD uses an XML file to populate its widget box. The name of that |
|
59 |
file is one of the widget box's properties, and you can retrieve |
|
60 |
it using the fileName() function. |
|
61 |
||
62 |
QDesignerWidgetBoxInterface also provides the save() function that |
|
63 |
saves the contents of the widget box in the file specified by the |
|
64 |
widget box's file name property. If you have made changes to the |
|
65 |
widget box, for example by dropping a widget into the widget box, |
|
66 |
without calling the save() function, the original content can be |
|
67 |
restored by a simple invocation of the load() function: |
|
68 |
||
69 |
\snippet doc/src/snippets/code/tools_designer_src_lib_sdk_abstractwidgetbox.cpp 0 |
|
70 |
||
71 |
The QDesignerWidgetBoxInterface class is not intended to be |
|
72 |
instantiated directly. You can retrieve an interface to Qt |
|
73 |
Designer's widget box using the |
|
74 |
QDesignerFormEditorInterface::widgetBox() function. A pointer to |
|
75 |
\QD's current QDesignerFormEditorInterface object (\c formEditor |
|
76 |
in the example above) is provided by the |
|
77 |
QDesignerCustomWidgetInterface::initialize() function's |
|
78 |
parameter. When implementing a custom widget plugin, you must |
|
79 |
subclass the QDesignerCustomWidgetInterface to expose your plugin |
|
80 |
to \QD. |
|
81 |
||
82 |
If you want to save your changes, and at the same time preserve |
|
83 |
the original contents, you can use the save() function combined |
|
84 |
with the setFileName() function to save your changes into another |
|
85 |
file. Remember to store the name of the original file first: |
|
86 |
||
87 |
\snippet doc/src/snippets/code/tools_designer_src_lib_sdk_abstractwidgetbox.cpp 1 |
|
88 |
||
89 |
Then you can restore the original contents of the widget box by |
|
90 |
resetting the file name to the original file and calling load(): |
|
91 |
||
92 |
\snippet doc/src/snippets/code/tools_designer_src_lib_sdk_abstractwidgetbox.cpp 2 |
|
93 |
||
94 |
In a similar way, you can later use your customized XML file: |
|
95 |
||
96 |
\snippet doc/src/snippets/code/tools_designer_src_lib_sdk_abstractwidgetbox.cpp 3 |
|
97 |
||
98 |
||
99 |
\sa QDesignerFormEditorInterface |
|
100 |
*/ |
|
101 |
||
102 |
/*! |
|
103 |
Constructs a widget box interface with the given \a parent and |
|
104 |
the specified window \a flags. |
|
105 |
*/ |
|
106 |
QDesignerWidgetBoxInterface::QDesignerWidgetBoxInterface(QWidget *parent, Qt::WindowFlags flags) |
|
107 |
: QWidget(parent, flags) |
|
108 |
{ |
|
109 |
} |
|
110 |
||
111 |
/*! |
|
112 |
Destroys the widget box interface. |
|
113 |
*/ |
|
114 |
QDesignerWidgetBoxInterface::~QDesignerWidgetBoxInterface() |
|
115 |
{ |
|
116 |
} |
|
117 |
||
118 |
/*! |
|
119 |
\internal |
|
120 |
*/ |
|
121 |
int QDesignerWidgetBoxInterface::findOrInsertCategory(const QString &categoryName) |
|
122 |
{ |
|
123 |
int count = categoryCount(); |
|
124 |
for (int index=0; index<count; ++index) { |
|
125 |
Category c = category(index); |
|
126 |
if (c.name() == categoryName) |
|
127 |
return index; |
|
128 |
} |
|
129 |
||
130 |
addCategory(Category(categoryName)); |
|
131 |
return count; |
|
132 |
} |
|
133 |
||
134 |
/*! |
|
135 |
\internal |
|
136 |
\fn int QDesignerWidgetBoxInterface::categoryCount() const |
|
137 |
*/ |
|
138 |
||
139 |
/*! |
|
140 |
\internal |
|
141 |
\fn Category QDesignerWidgetBoxInterface::category(int cat_idx) const |
|
142 |
*/ |
|
143 |
||
144 |
/*! |
|
145 |
\internal |
|
146 |
\fn void QDesignerWidgetBoxInterface::addCategory(const Category &cat) |
|
147 |
*/ |
|
148 |
||
149 |
/*! |
|
150 |
\internal |
|
151 |
\fn void QDesignerWidgetBoxInterface::removeCategory(int cat_idx) |
|
152 |
*/ |
|
153 |
||
154 |
/*! |
|
155 |
\internal |
|
156 |
\fn int QDesignerWidgetBoxInterface::widgetCount(int cat_idx) const |
|
157 |
*/ |
|
158 |
||
159 |
/*! |
|
160 |
\internal |
|
161 |
\fn Widget QDesignerWidgetBoxInterface::widget(int cat_idx, int wgt_idx) const |
|
162 |
*/ |
|
163 |
||
164 |
/*! |
|
165 |
\internal |
|
166 |
\fn void QDesignerWidgetBoxInterface::addWidget(int cat_idx, const Widget &wgt) |
|
167 |
*/ |
|
168 |
||
169 |
/*! |
|
170 |
\internal |
|
171 |
\fn void QDesignerWidgetBoxInterface::removeWidget(int cat_idx, int wgt_idx) |
|
172 |
*/ |
|
173 |
||
174 |
/*! |
|
175 |
\internal |
|
176 |
\fn void QDesignerWidgetBoxInterface::dropWidgets(const QList<QDesignerDnDItemInterface*> &item_list, const QPoint &global_mouse_pos) |
|
177 |
||
178 |
*/ |
|
179 |
||
180 |
/*! |
|
181 |
\fn void QDesignerWidgetBoxInterface::setFileName(const QString &fileName) |
|
182 |
||
183 |
Sets the XML file that \QD will use to populate its widget box, to |
|
184 |
\a fileName. You must call load() to update the widget box with |
|
185 |
the new XML file. |
|
186 |
||
187 |
\sa fileName(), load() |
|
188 |
*/ |
|
189 |
||
190 |
/*! |
|
191 |
\fn QString QDesignerWidgetBoxInterface::fileName() const |
|
192 |
||
193 |
Returns the name of the XML file \QD is currently using to |
|
194 |
populate its widget box. |
|
195 |
||
196 |
\sa setFileName() |
|
197 |
*/ |
|
198 |
||
199 |
/*! |
|
200 |
\fn bool QDesignerWidgetBoxInterface::load() |
|
201 |
||
202 |
Populates \QD's widget box by loading (or reloading) the currently |
|
203 |
specified XML file. Returns true if the file is successfully |
|
204 |
loaded; otherwise false. |
|
205 |
||
206 |
\sa setFileName() |
|
207 |
*/ |
|
208 |
||
209 |
/*! |
|
210 |
\fn bool QDesignerWidgetBoxInterface::save() |
|
211 |
||
212 |
Saves the contents of \QD's widget box in the file specified by |
|
213 |
the fileName() function. Returns true if the content is |
|
214 |
successfully saved; otherwise false. |
|
215 |
||
216 |
\sa fileName(), setFileName() |
|
217 |
*/ |
|
218 |
||
219 |
||
220 |
/*! |
|
221 |
\internal |
|
222 |
||
223 |
\class QDesignerWidgetBoxInterface::Widget |
|
224 |
||
225 |
\brief The Widget class specified a widget in Qt Designer's widget |
|
226 |
box component. |
|
227 |
*/ |
|
228 |
||
229 |
/*! |
|
230 |
\enum QDesignerWidgetBoxInterface::Widget::Type |
|
231 |
||
232 |
\value Default |
|
233 |
\value Custom |
|
234 |
*/ |
|
235 |
||
236 |
/*! |
|
237 |
\fn QDesignerWidgetBoxInterface::Widget::Widget(const QString &aname, const QString &xml, const QString &icon_name, Type atype) |
|
238 |
*/ |
|
239 |
||
240 |
/*! |
|
241 |
\fn QString QDesignerWidgetBoxInterface::Widget::name() const |
|
242 |
*/ |
|
243 |
||
244 |
/*! |
|
245 |
\fn void QDesignerWidgetBoxInterface::Widget::setName(const QString &aname) |
|
246 |
*/ |
|
247 |
||
248 |
/*! |
|
249 |
\fn QString QDesignerWidgetBoxInterface::Widget::domXml() const |
|
250 |
*/ |
|
251 |
||
252 |
/*! |
|
253 |
\fn void QDesignerWidgetBoxInterface::Widget::setDomXml(const QString &xml) |
|
254 |
*/ |
|
255 |
||
256 |
/*! |
|
257 |
\fn QString QDesignerWidgetBoxInterface::Widget::iconName() const |
|
258 |
*/ |
|
259 |
||
260 |
/*! |
|
261 |
\fn void QDesignerWidgetBoxInterface::Widget::setIconName(const QString &icon_name) |
|
262 |
*/ |
|
263 |
||
264 |
/*! |
|
265 |
\fn Type QDesignerWidgetBoxInterface::Widget::type() const |
|
266 |
*/ |
|
267 |
||
268 |
/*! |
|
269 |
\fn void QDesignerWidgetBoxInterface::Widget::setType(Type atype) |
|
270 |
*/ |
|
271 |
||
272 |
/*! |
|
273 |
\fn bool QDesignerWidgetBoxInterface::Widget::isNull() const |
|
274 |
*/ |
|
275 |
||
276 |
||
277 |
/*! |
|
278 |
\class QDesignerWidgetBoxInterface::Category |
|
279 |
\brief The Category class specifies a category in Qt Designer's widget box component. |
|
280 |
\internal |
|
281 |
*/ |
|
282 |
||
283 |
/*! |
|
284 |
\enum QDesignerWidgetBoxInterface::Category::Type |
|
285 |
||
286 |
\value Default |
|
287 |
\value Scratchpad |
|
288 |
*/ |
|
289 |
||
290 |
/*! |
|
291 |
\fn QDesignerWidgetBoxInterface::Category::Category(const QString &aname, Type atype) |
|
292 |
*/ |
|
293 |
||
294 |
/*! |
|
295 |
\fn QString QDesignerWidgetBoxInterface::Category::name() const |
|
296 |
*/ |
|
297 |
||
298 |
/*! |
|
299 |
\fn void QDesignerWidgetBoxInterface::Category::setName(const QString &aname) |
|
300 |
*/ |
|
301 |
||
302 |
/*! |
|
303 |
\fn int QDesignerWidgetBoxInterface::Category::widgetCount() const |
|
304 |
*/ |
|
305 |
||
306 |
/*! |
|
307 |
\fn Widget QDesignerWidgetBoxInterface::Category::widget(int idx) const |
|
308 |
*/ |
|
309 |
||
310 |
/*! |
|
311 |
\fn void QDesignerWidgetBoxInterface::Category::removeWidget(int idx) |
|
312 |
*/ |
|
313 |
||
314 |
/*! |
|
315 |
\fn void QDesignerWidgetBoxInterface::Category::addWidget(const Widget &awidget) |
|
316 |
*/ |
|
317 |
||
318 |
/*! |
|
319 |
\fn Type QDesignerWidgetBoxInterface::Category::type() const |
|
320 |
*/ |
|
321 |
||
322 |
/*! |
|
323 |
\fn void QDesignerWidgetBoxInterface::Category::setType(Type atype) |
|
324 |
*/ |
|
325 |
||
326 |
/*! |
|
327 |
\fn bool QDesignerWidgetBoxInterface::Category::isNull() const |
|
328 |
*/ |
|
329 |
||
330 |
/*! |
|
331 |
\typedef QDesignerWidgetBoxInterface::CategoryList |
|
332 |
\internal |
|
333 |
*/ |
|
334 |
||
335 |
/*! |
|
336 |
\typedef QDesignerWidgetBoxInterface::WidgetList |
|
337 |
\internal |
|
338 |
*/ |
|
339 |
||
340 |
QT_END_NAMESPACE |