author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 12 Mar 2010 15:46:37 +0200 | |
branch | RCL_3 |
changeset 5 | d3bac044e0f0 |
parent 4 | 3b1da2848fc7 |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
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 examples 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 <QtDesigner/QExtensionFactory> |
|
43 |
#include <QtDesigner/QExtensionManager> |
|
44 |
#include <QtDesigner/QDesignerFormEditorInterface> |
|
45 |
#include <QtDesigner/QDesignerFormWindowInterface> |
|
46 |
#include <QtDesigner/QDesignerContainerExtension> |
|
47 |
#include <QtDesigner/QDesignerPropertySheetExtension> |
|
48 |
||
49 |
#include <QIcon> |
|
50 |
#include <QtPlugin> |
|
51 |
||
52 |
#include "multipagewidget.h" |
|
53 |
#include "multipagewidgetplugin.h" |
|
54 |
#include "multipagewidgetextensionfactory.h" |
|
55 |
||
56 |
//! [0] |
|
57 |
MultiPageWidgetPlugin::MultiPageWidgetPlugin(QObject *parent) |
|
58 |
:QObject(parent) |
|
59 |
{ |
|
60 |
initialized = false; |
|
61 |
} |
|
62 |
||
63 |
QString MultiPageWidgetPlugin::name() const |
|
64 |
{ |
|
65 |
return QLatin1String("MultiPageWidget"); |
|
66 |
} |
|
67 |
||
68 |
QString MultiPageWidgetPlugin::group() const |
|
69 |
{ |
|
70 |
return QLatin1String("Display Widgets [Examples]"); |
|
71 |
} |
|
72 |
||
73 |
QString MultiPageWidgetPlugin::toolTip() const |
|
74 |
{ |
|
75 |
return QString(); |
|
76 |
} |
|
77 |
||
78 |
QString MultiPageWidgetPlugin::whatsThis() const |
|
79 |
{ |
|
80 |
return QString(); |
|
81 |
} |
|
82 |
||
83 |
QString MultiPageWidgetPlugin::includeFile() const |
|
84 |
{ |
|
85 |
return QLatin1String("multipagewidget.h"); |
|
86 |
} |
|
87 |
||
88 |
QIcon MultiPageWidgetPlugin::icon() const |
|
89 |
{ |
|
90 |
return QIcon(); |
|
91 |
} |
|
92 |
||
93 |
//! [0] //! [1] |
|
94 |
bool MultiPageWidgetPlugin::isContainer() const |
|
95 |
{ |
|
96 |
return true; |
|
97 |
} |
|
98 |
||
99 |
//! [1] //! [2] |
|
100 |
QWidget *MultiPageWidgetPlugin::createWidget(QWidget *parent) |
|
101 |
{ |
|
102 |
MultiPageWidget *widget = new MultiPageWidget(parent); |
|
103 |
connect(widget, SIGNAL(currentIndexChanged(int)), |
|
104 |
this, SLOT(currentIndexChanged(int))); |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
105 |
connect(widget, SIGNAL(pageTitleChanged(QString)), |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
106 |
this, SLOT(pageTitleChanged(QString))); |
0 | 107 |
return widget; |
108 |
} |
|
109 |
||
110 |
//! [2] //! [3] |
|
111 |
bool MultiPageWidgetPlugin::isInitialized() const |
|
112 |
{ |
|
113 |
return initialized; |
|
114 |
} |
|
115 |
//! [3] |
|
116 |
||
117 |
//! [4] |
|
118 |
void MultiPageWidgetPlugin::initialize(QDesignerFormEditorInterface *formEditor) |
|
119 |
{ |
|
120 |
if (initialized) |
|
121 |
return; |
|
122 |
//! [4] |
|
123 |
||
124 |
//! [5] |
|
125 |
QExtensionManager *manager = formEditor->extensionManager(); |
|
126 |
//! [5] //! [6] |
|
127 |
QExtensionFactory *factory = new MultiPageWidgetExtensionFactory(manager); |
|
128 |
||
129 |
Q_ASSERT(manager != 0); |
|
130 |
manager->registerExtensions(factory, Q_TYPEID(QDesignerContainerExtension)); |
|
131 |
||
132 |
initialized = true; |
|
133 |
} |
|
134 |
//! [6] |
|
135 |
||
136 |
//! [7] |
|
137 |
QString MultiPageWidgetPlugin::domXml() const |
|
138 |
{ |
|
139 |
return QLatin1String("\ |
|
140 |
<ui language=\"c++\">\ |
|
141 |
<widget class=\"MultiPageWidget\" name=\"multipagewidget\">\ |
|
142 |
<widget class=\"QWidget\" name=\"page\" />\ |
|
143 |
</widget>\ |
|
144 |
<customwidgets>\ |
|
145 |
<customwidget>\ |
|
146 |
<class>MultiPageWidget</class>\ |
|
147 |
<extends>QWidget</extends>\ |
|
148 |
<addpagemethod>addPage</addpagemethod>\ |
|
149 |
</customwidget>\ |
|
150 |
</customwidgets>\ |
|
151 |
</ui>"); |
|
152 |
} |
|
153 |
//! [7] |
|
154 |
||
155 |
//! [8] |
|
156 |
void MultiPageWidgetPlugin::currentIndexChanged(int index) |
|
157 |
{ |
|
158 |
Q_UNUSED(index); |
|
159 |
MultiPageWidget *widget = qobject_cast<MultiPageWidget*>(sender()); |
|
160 |
//! [8] //! [9] |
|
161 |
if (widget) { |
|
162 |
QDesignerFormWindowInterface *form = QDesignerFormWindowInterface::findFormWindow(widget); |
|
163 |
if (form) |
|
164 |
form->emitSelectionChanged(); |
|
165 |
} |
|
166 |
} |
|
167 |
//! [9] |
|
168 |
||
169 |
//! [10] |
|
170 |
void MultiPageWidgetPlugin::pageTitleChanged(const QString &title) |
|
171 |
{ |
|
172 |
Q_UNUSED(title); |
|
173 |
MultiPageWidget *widget = qobject_cast<MultiPageWidget*>(sender()); |
|
174 |
//! [10] //! [11] |
|
175 |
if (widget) { |
|
176 |
QWidget *page = widget->widget(widget->currentIndex()); |
|
177 |
QDesignerFormWindowInterface *form; |
|
178 |
form = QDesignerFormWindowInterface::findFormWindow(widget); |
|
179 |
//! [11] |
|
180 |
if (form) { |
|
181 |
//! [12] |
|
182 |
QDesignerFormEditorInterface *editor = form->core(); |
|
183 |
QExtensionManager *manager = editor->extensionManager(); |
|
184 |
//! [12] //! [13] |
|
185 |
QDesignerPropertySheetExtension *sheet; |
|
186 |
sheet = qt_extension<QDesignerPropertySheetExtension*>(manager, page); |
|
187 |
const int propertyIndex = sheet->indexOf(QLatin1String("windowTitle")); |
|
188 |
sheet->setChanged(propertyIndex, true); |
|
189 |
} |
|
190 |
} |
|
191 |
} |
|
192 |
||
193 |
//! [13] |
|
194 |
||
195 |
//! [14] |
|
196 |
Q_EXPORT_PLUGIN2(containerextension, MultiPageWidgetPlugin) |
|
197 |
//! [14] |