1/****************************************************************************
2**
3** Copyright (C) 2016 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of the Qt Designer of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see https://www.qt.io/terms-conditions. For further
15** information use the contact form at https://www.qt.io/contact-us.
16**
17** GNU General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU
19** General Public License version 3 as published by the Free Software
20** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21** included in the packaging of this file. Please review the following
22** information to ensure the GNU General Public License requirements will
23** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24**
25** $QT_END_LICENSE$
26**
27****************************************************************************/
28
29//
30// W A R N I N G
31// -------------
32//
33// This file is not part of the Qt API. It exists for the convenience
34// of Qt Designer. This header
35// file may change from version to version without notice, or even be removed.
36//
37// We mean it.
38//
39
40
41#ifndef WIDGETDATABASE_H
42#define WIDGETDATABASE_H
43
44#include "shared_global_p.h"
45
46#include <QtDesigner/abstractwidgetdatabase.h>
47
48#include <QtGui/qicon.h>
49#include <QtCore/qstring.h>
50#include <QtCore/qvariant.h>
51#include <QtCore/qpair.h>
52#include <QtCore/qstringlist.h>
53
54QT_BEGIN_NAMESPACE
55
56class QObject;
57class QDesignerCustomWidgetInterface;
58
59namespace qdesigner_internal {
60
61class QDESIGNER_SHARED_EXPORT WidgetDataBaseItem: public QDesignerWidgetDataBaseItemInterface
62{
63public:
64 explicit WidgetDataBaseItem(const QString &name = QString(),
65 const QString &group = QString());
66
67 QString name() const override;
68 void setName(const QString &name) override;
69
70 QString group() const override;
71 void setGroup(const QString &group) override;
72
73 QString toolTip() const override;
74 void setToolTip(const QString &toolTip) override;
75
76 QString whatsThis() const override;
77 void setWhatsThis(const QString &whatsThis) override;
78
79 QString includeFile() const override;
80 void setIncludeFile(const QString &includeFile) override;
81
82
83 QIcon icon() const override;
84 void setIcon(const QIcon &icon) override;
85
86 bool isCompat() const override;
87 void setCompat(bool compat) override;
88
89 bool isContainer() const override;
90 void setContainer(bool b) override;
91
92 bool isCustom() const override;
93 void setCustom(bool b) override;
94
95 QString pluginPath() const override;
96 void setPluginPath(const QString &path) override;
97
98 bool isPromoted() const override;
99 void setPromoted(bool b) override;
100
101 QString extends() const override;
102 void setExtends(const QString &s) override;
103
104 void setDefaultPropertyValues(const QList<QVariant> &list) override;
105 QList<QVariant> defaultPropertyValues() const override;
106
107 static WidgetDataBaseItem *clone(const QDesignerWidgetDataBaseItemInterface *item);
108
109 QStringList fakeSlots() const;
110 void setFakeSlots(const QStringList &);
111
112 QStringList fakeSignals() const;
113 void setFakeSignals(const QStringList &);
114
115 QString addPageMethod() const;
116 void setAddPageMethod(const QString &m);
117
118private:
119 QString m_name;
120 QString m_group;
121 QString m_toolTip;
122 QString m_whatsThis;
123 QString m_includeFile;
124 QString m_pluginPath;
125 QString m_extends;
126 QString m_addPageMethod;
127 QIcon m_icon;
128 uint m_compat: 1;
129 uint m_container: 1;
130 uint m_custom: 1;
131 uint m_promoted: 1;
132 QList<QVariant> m_defaultPropertyValues;
133 QStringList m_fakeSlots;
134 QStringList m_fakeSignals;
135};
136
137enum IncludeType { IncludeLocal, IncludeGlobal };
138
139using IncludeSpecification = QPair<QString, IncludeType>;
140
141QDESIGNER_SHARED_EXPORT IncludeSpecification includeSpecification(QString includeFile);
142QDESIGNER_SHARED_EXPORT QString buildIncludeFile(QString includeFile, IncludeType includeType);
143
144class QDESIGNER_SHARED_EXPORT WidgetDataBase: public QDesignerWidgetDataBaseInterface
145{
146 Q_OBJECT
147public:
148 explicit WidgetDataBase(QDesignerFormEditorInterface *core, QObject *parent = nullptr);
149 ~WidgetDataBase() override;
150
151 QDesignerFormEditorInterface *core() const override;
152
153 int indexOfObject(QObject *o, bool resolveName = true) const override;
154
155 void remove(int index);
156
157
158 void grabDefaultPropertyValues();
159 void grabStandardWidgetBoxIcons();
160
161 // Helpers for 'New Form' wizards in integrations. Obtain a list of suitable classes and generate XML for them.
162 static QStringList formWidgetClasses(const QDesignerFormEditorInterface *core);
163 static QStringList customFormWidgetClasses(const QDesignerFormEditorInterface *core);
164 static QString formTemplate(const QDesignerFormEditorInterface *core, const QString &className, const QString &objectName);
165
166 // Helpers for 'New Form' wizards: Set a fixed size on a XML form template
167 static QString scaleFormTemplate(const QString &xml, const QSize &size, bool fixed);
168
169public slots:
170 void loadPlugins();
171
172private:
173 QList<QVariant> defaultPropertyValues(const QString &name);
174
175 QDesignerFormEditorInterface *m_core;
176};
177
178QDESIGNER_SHARED_EXPORT QDesignerWidgetDataBaseItemInterface
179 *appendDerived(QDesignerWidgetDataBaseInterface *db,
180 const QString &className,
181 const QString &group,
182 const QString &baseClassName,
183 const QString &includeFile,
184 bool promoted,
185 bool custom);
186
187using WidgetDataBaseItemList = QList<QDesignerWidgetDataBaseItemInterface *>;
188
189QDESIGNER_SHARED_EXPORT WidgetDataBaseItemList
190 promotionCandidates(const QDesignerWidgetDataBaseInterface *db,
191 const QString &baseClassName);
192} // namespace qdesigner_internal
193
194QT_END_NAMESPACE
195
196#endif // WIDGETDATABASE_H
197

source code of qttools/src/designer/src/lib/shared/widgetdatabase_p.h