source: trunk/tools/designer/src/lib/shared/widgetdatabase.cpp@ 5

Last change on this file since 5 was 2, checked in by Dmitry A. Kuminov, 17 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 31.5 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the Qt Designer of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** 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 are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#include "widgetdatabase_p.h"
43#include "widgetfactory_p.h"
44#include "spacer_widget_p.h"
45#include "abstractlanguage.h"
46#include "pluginmanager_p.h"
47#include "qdesigner_widgetbox_p.h"
48#include "qdesigner_utils_p.h"
49#include <ui4_p.h>
50
51#include <QtDesigner/customwidget.h>
52#include <QtDesigner/propertysheet.h>
53#include <QtDesigner/QExtensionManager>
54#include <QtDesigner/QDesignerFormEditorInterface>
55
56#include <QtXml/QXmlStreamWriter>
57#include <QtCore/QtAlgorithms>
58#include <QtCore/qdebug.h>
59#include <QtCore/QMetaProperty>
60#include <QtCore/QTextStream>
61#include <QtCore/QRegExp>
62#include <QtCore/QCoreApplication>
63
64QT_BEGIN_NAMESPACE
65
66namespace {
67 enum { debugWidgetDataBase = 0 };
68}
69
70namespace qdesigner_internal {
71
72// ----------------------------------------------------------
73WidgetDataBaseItem::WidgetDataBaseItem(const QString &name, const QString &group)
74 : m_name(name),
75 m_group(group),
76 m_compat(0),
77 m_container(0),
78 m_form(0),
79 m_custom(0),
80 m_promoted(0)
81{
82}
83
84QString WidgetDataBaseItem::name() const
85{
86 return m_name;
87}
88
89void WidgetDataBaseItem::setName(const QString &name)
90{
91 m_name = name;
92}
93
94QString WidgetDataBaseItem::group() const
95{
96 return m_group;
97}
98
99void WidgetDataBaseItem::setGroup(const QString &group)
100{
101 m_group = group;
102}
103
104QString WidgetDataBaseItem::toolTip() const
105{
106 return m_toolTip;
107}
108
109void WidgetDataBaseItem::setToolTip(const QString &toolTip)
110{
111 m_toolTip = toolTip;
112}
113
114QString WidgetDataBaseItem::whatsThis() const
115{
116 return m_whatsThis;
117}
118
119void WidgetDataBaseItem::setWhatsThis(const QString &whatsThis)
120{
121 m_whatsThis = whatsThis;
122}
123
124QString WidgetDataBaseItem::includeFile() const
125{
126 return m_includeFile;
127}
128
129void WidgetDataBaseItem::setIncludeFile(const QString &includeFile)
130{
131 m_includeFile = includeFile;
132}
133
134QIcon WidgetDataBaseItem::icon() const
135{
136 return m_icon;
137}
138
139void WidgetDataBaseItem::setIcon(const QIcon &icon)
140{
141 m_icon = icon;
142}
143
144bool WidgetDataBaseItem::isCompat() const
145{
146 return m_compat;
147}
148
149void WidgetDataBaseItem::setCompat(bool b)
150{
151 m_compat = b;
152}
153
154bool WidgetDataBaseItem::isContainer() const
155{
156 return m_container;
157}
158
159void WidgetDataBaseItem::setContainer(bool b)
160{
161 m_container = b;
162}
163
164bool WidgetDataBaseItem::isCustom() const
165{
166 return m_custom;
167}
168
169void WidgetDataBaseItem::setCustom(bool b)
170{
171 m_custom = b;
172}
173
174QString WidgetDataBaseItem::pluginPath() const
175{
176 return m_pluginPath;
177}
178
179void WidgetDataBaseItem::setPluginPath(const QString &path)
180{
181 m_pluginPath = path;
182}
183
184bool WidgetDataBaseItem::isPromoted() const
185{
186 return m_promoted;
187}
188
189void WidgetDataBaseItem::setPromoted(bool b)
190{
191 m_promoted = b;
192}
193
194QString WidgetDataBaseItem::extends() const
195{
196 return m_extends;
197}
198
199void WidgetDataBaseItem::setExtends(const QString &s)
200{
201 m_extends = s;
202}
203
204void WidgetDataBaseItem::setDefaultPropertyValues(const QList<QVariant> &list)
205{
206 m_defaultPropertyValues = list;
207}
208
209QList<QVariant> WidgetDataBaseItem::defaultPropertyValues() const
210{
211 return m_defaultPropertyValues;
212}
213
214QStringList WidgetDataBaseItem::fakeSlots() const
215{
216 return m_fakeSlots;
217}
218
219void WidgetDataBaseItem::setFakeSlots(const QStringList &fs)
220{
221 m_fakeSlots = fs;
222}
223
224QStringList WidgetDataBaseItem::fakeSignals() const
225{
226 return m_fakeSignals;
227}
228
229void WidgetDataBaseItem::setFakeSignals(const QStringList &fs)
230{
231 m_fakeSignals = fs;
232}
233
234QString WidgetDataBaseItem::addPageMethod() const
235{
236 return m_addPageMethod;
237}
238
239void WidgetDataBaseItem::setAddPageMethod(const QString &m)
240{
241 m_addPageMethod = m;
242}
243
244WidgetDataBaseItem *WidgetDataBaseItem::clone(const QDesignerWidgetDataBaseItemInterface *item)
245{
246 WidgetDataBaseItem *rc = new WidgetDataBaseItem(item->name(), item->group());
247
248 rc->setToolTip(item->toolTip());
249 rc->setWhatsThis(item->whatsThis());
250 rc->setIncludeFile(item->includeFile());
251 rc->setIcon(item->icon());
252 rc->setCompat(item->isCompat());
253 rc->setContainer(item->isContainer());
254 rc->setCustom(item->isCustom() );
255 rc->setPluginPath(item->pluginPath());
256 rc->setPromoted(item->isPromoted());
257 rc->setExtends(item->extends());
258 rc->setDefaultPropertyValues(item->defaultPropertyValues());
259 // container page method, fake slots and signals ignored here.y
260 return rc;
261}
262
263// ----------------------------------------------------------
264WidgetDataBase::WidgetDataBase(QDesignerFormEditorInterface *core, QObject *parent)
265 : QDesignerWidgetDataBaseInterface(parent),
266 m_core(core)
267{
268#define DECLARE_LAYOUT(L, C)
269#define DECLARE_COMPAT_WIDGET(W, C) DECLARE_WIDGET(W, C)
270#define DECLARE_WIDGET(W, C) append(new WidgetDataBaseItem(QString::fromUtf8(#W)));
271
272#include "widgets.table"
273
274#undef DECLARE_COMPAT_WIDGET
275#undef DECLARE_LAYOUT
276#undef DECLARE_WIDGET
277#undef DECLARE_WIDGET_1
278
279 append(new WidgetDataBaseItem(QString::fromUtf8("Line")));
280 append(new WidgetDataBaseItem(QString::fromUtf8("Spacer")));
281 append(new WidgetDataBaseItem(QString::fromUtf8("QSplitter")));
282 append(new WidgetDataBaseItem(QString::fromUtf8("QLayoutWidget")));
283 // QDesignerWidget is used as central widget and as container for tab widgets, etc.
284 WidgetDataBaseItem *designerWidgetItem = new WidgetDataBaseItem(QString::fromUtf8("QDesignerWidget"));
285 designerWidgetItem->setContainer(true);