1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
/****************************************************************************
**
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the Qt Designer of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia. For licensing terms and
** conditions see http://qt.digia.com/licensing. For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights. These rights are described in the Digia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3.0 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file. Please review the following information to
** ensure the GNU General Public License version 3.0 requirements will be
** met: http://www.gnu.org/copyleft/gpl.html.
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
//
// W A R N I N G
// -------------
//
// This file is not part of the Qt API. It exists for the convenience
// of Qt Designer. This header
// file may change from version to version without notice, or even be removed.
//
// We mean it.
//
#ifndef WIDGETFACTORY_H
#define WIDGETFACTORY_H
#include "shared_global_p.h"
#include "pluginmanager_p.h"
#include <QtDesigner/QDesignerWidgetFactoryInterface>
#include <QtCore/QMap>
#include <QtCore/QHash>
#include <QtCore/QVariant>
#include <QtCore/QPointer>
QT_BEGIN_NAMESPACE
class QObject;
class QWidget;
class QLayout;
class QDesignerFormEditorInterface;
class QDesignerCustomWidgetInterface;
class QDesignerFormWindowInterface;
class QStyle;
namespace qdesigner_internal {
class QDESIGNER_SHARED_EXPORT WidgetFactory: public QDesignerWidgetFactoryInterface
{
Q_OBJECT
public:
explicit WidgetFactory(QDesignerFormEditorInterface *core, QObject *parent = 0);
~WidgetFactory();
virtual QWidget* containerOfWidget(QWidget *widget) const;
virtual QWidget* widgetOfContainer(QWidget *widget) const;
QObject* createObject(const QString &className, QObject* parent) const;
virtual QWidget *createWidget(const QString &className, QWidget *parentWidget) const;
virtual QLayout *createLayout(QWidget *widget, QLayout *layout, int type) const;
virtual bool isPassiveInteractor(QWidget *widget);
virtual void initialize(QObject *object) const;
void initializeCommon(QWidget *object) const;
void initializePreview(QWidget *object) const;
virtual QDesignerFormEditorInterface *core() const;
static QString classNameOf(QDesignerFormEditorInterface *core, const QObject* o);
QDesignerFormWindowInterface *currentFormWindow(QDesignerFormWindowInterface *fw);
static QLayout *createUnmanagedLayout(QWidget *parentWidget, int type);
// The widget factory maintains a cache of styles which it owns.
QString styleName() const;
void setStyleName(const QString &styleName);
/* Return a cached style matching the name or QApplication's style if
* it is the default. */
QStyle *getStyle(const QString &styleName);
// Return the current style used by the factory. This either a cached one
// or QApplication's style */
QStyle *style() const;
// Apply one of the cached styles or QApplication's style to a toplevel widget.
void applyStyleTopLevel(const QString &styleName, QWidget *w);
static void applyStyleToTopLevel(QStyle *style, QWidget *widget);
// Return whether object was created by the factory for the form editor.
static bool isFormEditorObject(const QObject *o);
// Boolean dynamic property to set on widgets to prevent custom
// styles from interfering
static const char *disableStyleCustomPaintingPropertyC;
public slots:
void loadPlugins();
private slots:
void activeFormWindowChanged(QDesignerFormWindowInterface *formWindow);
void formWindowAdded(QDesignerFormWindowInterface *formWindow);
private:
struct Strings { // Reduce string allocations by storing predefined strings
Strings();
const QString m_alignment;
const QString m_bottomMargin;
const QString m_geometry;
const QString m_leftMargin;
const QString m_line;
const QString m_objectName;
const QString m_spacerName;
const QString m_orientation;
const QString m_q3WidgetStack;
const QString m_qAction;
const QString m_qButtonGroup;
const QString m_qAxWidget;
const QString m_qDialog;
const QString m_qDockWidget;
const QString m_qLayoutWidget;
const QString m_qMenu;
const QString m_qMenuBar;
const QString m_qWidget;
const QString m_rightMargin;
const QString m_sizeHint;
const QString m_spacer;
const QString m_text;
const QString m_title;
const QString m_topMargin;
const QString m_windowIcon;
const QString m_windowTitle;
};
QWidget* createCustomWidget(const QString &className, QWidget *parentWidget, bool *creationError) const;
QDesignerFormWindowInterface *findFormWindow(QWidget *parentWidget) const;
void setFormWindowStyle(QDesignerFormWindowInterface *formWindow);
const Strings m_strings;
QDesignerFormEditorInterface *m_core;
typedef QMap<QString, QDesignerCustomWidgetInterface*> CustomWidgetFactoryMap;
CustomWidgetFactoryMap m_customFactory;
QDesignerFormWindowInterface *m_formWindow;
// Points to the cached style or 0 if the default (qApp) is active
QStyle *m_currentStyle;
typedef QHash<QString, QStyle *> StyleCache;
StyleCache m_styleCache;
static QPointer<QWidget> *m_lastPassiveInteractor;
static bool m_lastWasAPassiveInteractor;
};
} // namespace qdesigner_internal
QT_END_NAMESPACE
#endif // WIDGETFACTORY_H
|