1 | /****************************************************************************
|
---|
2 | **
|
---|
3 | ** Copyright (C) 2009 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 |
|
---|
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 |
|
---|
|
---|