author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Thu, 02 Sep 2010 21:20:32 +0300 | |
changeset 34 | a33bf25e6f72 |
parent 33 | 3e2da88830cd |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
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 documentation of the Qt Toolkit. |
|
8 |
** |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
9 |
** $QT_BEGIN_LICENSE:FDL$ |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
10 |
** Commercial Usage |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
11 |
** Licensees holding valid Qt Commercial licenses may use this file in |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
12 |
** accordance with the Qt Commercial License Agreement provided with the |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
13 |
** Software or, alternatively, in accordance with the terms contained in a |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
14 |
** written agreement between you and Nokia. |
0 | 15 |
** |
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
16 |
** GNU Free Documentation License |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
17 |
** Alternatively, this file may be used under the terms of the GNU Free |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
18 |
** Documentation License version 1.3 as published by the Free Software |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
19 |
** Foundation and appearing in the file included in the packaging of this |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
20 |
** file. |
0 | 21 |
** |
22 |
** If you have questions regarding the use of this file, please contact |
|
23 |
** Nokia at qt-info@nokia.com. |
|
24 |
** $QT_END_LICENSE$ |
|
25 |
** |
|
26 |
****************************************************************************/ |
|
27 |
||
28 |
/*! |
|
29 |
\class QDesignerContainerExtension |
|
30 |
\brief The QDesignerContainerExtension class allows you to add pages to |
|
31 |
a custom multi-page container in Qt Designer's workspace. |
|
32 |
\inmodule QtDesigner |
|
33 |
||
34 |
QDesignerContainerExtension provide an interface for creating |
|
35 |
custom container extensions. A container extension consists of a |
|
36 |
collection of functions that \QD needs to manage a multi-page |
|
37 |
container plugin, and a list of the container's pages. |
|
38 |
||
39 |
\image containerextension-example.png |
|
40 |
||
41 |
\warning This is \e not an extension for container plugins in |
|
42 |
general, only custom \e multi-page containers. |
|
43 |
||
44 |
To create a container extension, your extension class must inherit |
|
45 |
from both QObject and QDesignerContainerExtension. For example: |
|
46 |
||
47 |
\snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 6 |
|
48 |
||
49 |
Since we are implementing an interface, we must ensure that it's |
|
50 |
made known to the meta object system using the Q_INTERFACES() |
|
51 |
macro. This enables \QD to use the qobject_cast() function to |
|
52 |
query for supported interfaces using nothing but a QObject |
|
53 |
pointer. |
|
54 |
||
55 |
You must reimplement several functions to enable \QD to manage a |
|
56 |
custom multi-page container widget: \QD uses count() to keep track |
|
57 |
of the number pages in your container, widget() to return the page |
|
58 |
at a given index in the list of the container's pages, and |
|
59 |
currentIndex() to return the list index of the selected page. \QD |
|
60 |
uses the addWidget() function to add a given page to the |
|
61 |
container, expecting it to be appended to the list of pages, while |
|
62 |
it expects the insertWidget() function to add a given page to the |
|
63 |
container by inserting it at a given index. |
|
64 |
||
65 |
In \QD the extensions are not created until they are |
|
66 |
required. For that reason you must also create a |
|
67 |
QExtensionFactory, i.e a class that is able to make an instance of |
|
68 |
your extension, and register it using \QD's \l |
|
69 |
{QExtensionManager}{extension manager}. |
|
70 |
||
71 |
When a container extension is required, \QD's \l |
|
72 |
{QExtensionManager}{extension manager} will run through all its |
|
73 |
registered factories calling QExtensionFactory::createExtension() |
|
74 |
for each until the first one that is able to create a container |
|
75 |
extension, is found. This factory will then create the extension |
|
76 |
for the plugin. |
|
77 |
||
78 |
There are four available types of extensions in \QD: |
|
79 |
QDesignerContainerExtension , QDesignerMemberSheetExtension, |
|
80 |
QDesignerPropertySheetExtension and QDesignerTaskMenuExtension. |
|
81 |
\QD's behavior is the same whether the requested extension is |
|
82 |
associated with a multi page container, a member sheet, a property |
|
83 |
sheet or a task menu. |
|
84 |
||
85 |
The QExtensionFactory class provides a standard extension factory, |
|
86 |
and can also be used as an interface for custom extension |
|
87 |
factories. You can either create a new QExtensionFactory and |
|
88 |
reimplement the QExtensionFactory::createExtension() function. For |
|
89 |
example: |
|
90 |
||
91 |
\snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 7 |
|
92 |
||
93 |
Or you can use an existing factory, expanding the |
|
94 |
QExtensionFactory::createExtension() function to make the factory |
|
95 |
able to create a container extension as well. For example: |
|
96 |
||
97 |
\snippet doc/src/snippets/code/doc_src_qtdesigner.qdoc 8 |
|
98 |
||
99 |
For a complete example using the QDesignerContainerExtension |
|
100 |
class, see the \l {designer/containerextension}{Container |
|
101 |
Extension example}. The example shows how to create a custom |
|
102 |
multi-page plugin for \QD. |
|
103 |
||
104 |
\sa QExtensionFactory, QExtensionManager, {Creating Custom Widget |
|
105 |
Extensions} |
|
106 |
*/ |
|
107 |
||
108 |
/*! |
|
109 |
\fn QDesignerContainerExtension::~QDesignerContainerExtension() |
|
110 |
||
111 |
Destroys the extension. |
|
112 |
*/ |
|
113 |
||
114 |
/*! |
|
115 |
\fn int QDesignerContainerExtension::count() const |
|
116 |
||
117 |
Returns the number of pages in the container. |
|
118 |
*/ |
|
119 |
||
120 |
/*! |
|
121 |
\fn QWidget *QDesignerContainerExtension::widget(int index) const |
|
122 |
||
123 |
Returns the page at the given \a index in the extension's list of |
|
124 |
pages. |
|
125 |
||
126 |
\sa addWidget(), insertWidget() |
|
127 |
*/ |
|
128 |
||
129 |
/*! |
|
130 |
\fn int QDesignerContainerExtension::currentIndex() const |
|
131 |
||
132 |
Returns the index of the currently selected page in the |
|
133 |
container. |
|
134 |
||
135 |
\sa setCurrentIndex() |
|
136 |
*/ |
|
137 |
||
138 |
/*! |
|
139 |
\fn void QDesignerContainerExtension::setCurrentIndex(int index) |
|
140 |
||
141 |
Sets the currently selected page in the container to be the |
|
142 |
page at the given \a index in the extension's list of pages. |
|
143 |
||
144 |
\sa currentIndex() |
|
145 |
*/ |
|
146 |
||
147 |
/*! |
|
148 |
\fn void QDesignerContainerExtension::addWidget(QWidget *page) |
|
149 |
||
150 |
Adds the given \a page to the container by appending it to the |
|
151 |
extension's list of pages. |
|
152 |
||
153 |
\sa insertWidget(), remove(), widget() |
|
154 |
*/ |
|
155 |
||
156 |
/*! |
|
157 |
\fn void QDesignerContainerExtension::insertWidget(int index, QWidget *page) |
|
158 |
||
159 |
Adds the given \a page to the container by inserting it at the |
|
160 |
given \a index in the extension's list of pages. |
|
161 |
||
162 |
\sa addWidget(), remove(), widget() |
|
163 |
*/ |
|
164 |
||
165 |
/*! |
|
166 |
\fn void QDesignerContainerExtension::remove(int index) |
|
167 |
||
168 |
Removes the page at the given \a index from the extension's list |
|
169 |
of pages. |
|
170 |
||
171 |
\sa addWidget(), insertWidget() |
|
172 |
*/ |