source: trunk/tools/designer/src/lib/sdk/abstractwidgetbox.cpp@ 846

Last change on this file since 846 was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 9.1 KB
Line 
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 "abstractwidgetbox.h"
43
44QT_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*/
106QDesignerWidgetBoxInterface::QDesignerWidgetBoxInterface(QWidget *parent, Qt::WindowFlags flags)
107 : QWidget(parent, flags)
108{
109}
110
111/*!
112 Destroys the widget box interface.
113*/
114QDesignerWidgetBoxInterface::~QDesignerWidgetBoxInterface()
115{
116}
117
118/*!
119 \internal
120*/
121int 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
340QT_END_NAMESPACE
Note: See TracBrowser for help on using the repository browser.