summaryrefslogtreecommitdiffstats
path: root/tools/designer/src/lib/sdk/abstractwidgetbox.cpp
blob: c8607d7b0ad690de73bf1a414774efd6c8d90eba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
/****************************************************************************
**
** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the Qt Designer of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** GNU Lesser General Public License Usage
** This file may be used under the terms of the GNU Lesser General Public
** License version 2.1 as published by the Free Software Foundation and
** appearing in the file LICENSE.LGPL included in the packaging of this
** file. Please review the following information to ensure the GNU Lesser
** General Public License version 2.1 requirements will be met:
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU General
** Public License version 3.0 as published by the Free Software Foundation
** and appearing in the file LICENSE.GPL included in the packaging of this
** file. Please review the following information to ensure the GNU General
** Public License version 3.0 requirements will be met:
** http://www.gnu.org/copyleft/gpl.html.
**
** Other Usage
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/

#include "abstractwidgetbox.h"

QT_BEGIN_NAMESPACE

/*!
    \class QDesignerWidgetBoxInterface

    \brief The QDesignerWidgetBoxInterface class allows you to control
    the contents of Qt Designer's widget box.

    \inmodule QtDesigner

    QDesignerWidgetBoxInterface contains a collection of functions
    that is typically used to manipulate the contents of \QD's widget
    box.

    \QD uses an XML file to populate its widget box. The name of that
    file is one of the widget box's properties, and you can retrieve
    it using the fileName() function.

    QDesignerWidgetBoxInterface also provides the save() function that
    saves the contents of the widget box in the file specified by the
    widget box's file name property. If you have made changes to the
    widget box, for example by dropping a widget into the widget box,
    without calling the save() function, the original content can be
    restored by a simple invocation of the load() function:

    \snippet doc/src/snippets/code/tools_designer_src_lib_sdk_abstractwidgetbox.cpp 0

    The QDesignerWidgetBoxInterface class is not intended to be
    instantiated directly. You can retrieve an interface to Qt
    Designer's widget box using the
    QDesignerFormEditorInterface::widgetBox() function. A pointer to
    \QD's current QDesignerFormEditorInterface object (\c formEditor
    in the example above) is provided by the
    QDesignerCustomWidgetInterface::initialize() function's
    parameter. When implementing a custom widget plugin, you must
    subclass the QDesignerCustomWidgetInterface to expose your plugin
    to \QD.

    If you want to save your changes, and at the same time preserve
    the original contents, you can use the save() function combined
    with the setFileName() function to save your changes into another
    file. Remember to store the name of the original file first:

    \snippet doc/src/snippets/code/tools_designer_src_lib_sdk_abstractwidgetbox.cpp 1

    Then you can restore the original contents of the widget box by
    resetting the file name to the original file and calling load():

    \snippet doc/src/snippets/code/tools_designer_src_lib_sdk_abstractwidgetbox.cpp 2

    In a similar way, you can later use your customized XML file:

    \snippet doc/src/snippets/code/tools_designer_src_lib_sdk_abstractwidgetbox.cpp 3


    \sa QDesignerFormEditorInterface
*/

/*!
    Constructs a widget box interface with the given \a parent and
    the specified window \a flags.
*/
QDesignerWidgetBoxInterface::QDesignerWidgetBoxInterface(QWidget *parent, Qt::WindowFlags flags)
    : QWidget(parent, flags)
{
}

/*!
    Destroys the widget box interface.
*/
QDesignerWidgetBoxInterface::~QDesignerWidgetBoxInterface()
{
}

/*!
    \internal
*/
int QDesignerWidgetBoxInterface::findOrInsertCategory(const QString &categoryName)
{
    int count = categoryCount();
    for (int index=0; index<count; ++index) {
        Category c = category(index);
        if (c.name() == categoryName)
            return index;
    }

    addCategory(Category(categoryName));
    return count;
}

/*!
    \internal
    \fn int QDesignerWidgetBoxInterface::categoryCount() const
*/

/*!
    \internal
    \fn Category QDesignerWidgetBoxInterface::category(int cat_idx) const
*/

/*!
    \internal
    \fn void QDesignerWidgetBoxInterface::addCategory(const Category &cat)
*/

/*!
    \internal
    \fn void QDesignerWidgetBoxInterface::removeCategory(int cat_idx)
*/

/*!
    \internal
    \fn int QDesignerWidgetBoxInterface::widgetCount(int cat_idx) const
*/

/*!
    \internal
    \fn Widget QDesignerWidgetBoxInterface::widget(int cat_idx, int wgt_idx) const
*/

/*!
    \internal
    \fn void QDesignerWidgetBoxInterface::addWidget(int cat_idx, const Widget &wgt)
*/

/*!
    \internal
    \fn void QDesignerWidgetBoxInterface::removeWidget(int cat_idx, int wgt_idx)
*/

/*!
    \internal
    \fn void QDesignerWidgetBoxInterface::dropWidgets(const QList<QDesignerDnDItemInterface*> &item_list, const QPoint &global_mouse_pos)

*/

/*!
    \fn void QDesignerWidgetBoxInterface::setFileName(const QString &fileName)

    Sets the XML file that \QD will use to populate its widget box, to
    \a fileName. You must call load() to update the widget box with
    the new XML file.

    \sa fileName(), load()
*/

/*!
    \fn QString QDesignerWidgetBoxInterface::fileName() const

    Returns the name of the XML file \QD is currently using to
    populate its widget box.

    \sa setFileName()
*/

/*!
    \fn bool QDesignerWidgetBoxInterface::load()

    Populates \QD's widget box by loading (or reloading) the currently
    specified XML file. Returns true if the file is successfully
    loaded; otherwise false.

    \sa setFileName()
*/

/*!
    \fn bool QDesignerWidgetBoxInterface::save()

    Saves the contents of \QD's widget box in the file specified by
    the fileName() function. Returns true if the content is
    successfully saved; otherwise false.

    \sa fileName(), setFileName()
*/


/*!
    \internal

    \class QDesignerWidgetBoxInterface::Widget

    \brief The Widget class specified a widget in Qt Designer's widget
    box component.
*/

/*!
    \enum QDesignerWidgetBoxInterface::Widget::Type

    \value Default
    \value Custom
*/

/*!
    \fn QDesignerWidgetBoxInterface::Widget::Widget(const QString &aname, const QString &xml, const QString &icon_name, Type atype)
*/

/*!
    \fn QString QDesignerWidgetBoxInterface::Widget::name() const
*/

/*!
    \fn void QDesignerWidgetBoxInterface::Widget::setName(const QString &aname)
*/

/*!
    \fn QString QDesignerWidgetBoxInterface::Widget::domXml() const
*/

/*!
    \fn void QDesignerWidgetBoxInterface::Widget::setDomXml(const QString &xml)
*/

/*!
    \fn QString QDesignerWidgetBoxInterface::Widget::iconName() const
*/

/*!
    \fn void QDesignerWidgetBoxInterface::Widget::setIconName(const QString &icon_name)
*/

/*!
    \fn Type QDesignerWidgetBoxInterface::Widget::type() const
*/

/*!
    \fn void QDesignerWidgetBoxInterface::Widget::setType(Type atype)
*/

/*!
    \fn bool QDesignerWidgetBoxInterface::Widget::isNull() const
*/


/*!
    \class QDesignerWidgetBoxInterface::Category
    \brief The Category class specifies a category in Qt Designer's widget box component.
    \internal
*/

/*!
    \enum QDesignerWidgetBoxInterface::Category::Type

    \value Default
    \value Scratchpad
*/

/*!
    \fn QDesignerWidgetBoxInterface::Category::Category(const QString &aname, Type atype)
*/

/*!
    \fn QString QDesignerWidgetBoxInterface::Category::name() const
*/

/*!
    \fn void QDesignerWidgetBoxInterface::Category::setName(const QString &aname)
*/

/*!
    \fn int QDesignerWidgetBoxInterface::Category::widgetCount() const
*/

/*!
    \fn Widget QDesignerWidgetBoxInterface::Category::widget(int idx) const
*/

/*!
    \fn void QDesignerWidgetBoxInterface::Category::removeWidget(int idx)
*/

/*!
    \fn void QDesignerWidgetBoxInterface::Category::addWidget(const Widget &awidget)
*/

/*!
    \fn Type QDesignerWidgetBoxInterface::Category::type() const
*/

/*!
    \fn void QDesignerWidgetBoxInterface::Category::setType(Type atype)
*/

/*!
    \fn bool QDesignerWidgetBoxInterface::Category::isNull() const
*/

/*!
    \typedef QDesignerWidgetBoxInterface::CategoryList
    \internal
*/

/*!
    \typedef QDesignerWidgetBoxInterface::WidgetList
    \internal
*/

QT_END_NAMESPACE