BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
qdesigner_formbuilder_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the Qt Designer of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
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 Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
38 ** $QT_END_LICENSE$
39 **
40 ****************************************************************************/
41 
42 //
43 // W A R N I N G
44 // -------------
45 //
46 // This file is not part of the Qt API. It exists for the convenience
47 // of Qt Designer. This header
48 // file may change from version to version without notice, or even be removed.
49 //
50 // We mean it.
51 //
52 
53 #ifndef BORNAGAIN_GUI_COREGUI_VIEWS_WIDGETBOX_QDESIGNER_FORMBUILDER_P_H
54 #define BORNAGAIN_GUI_COREGUI_VIEWS_WIDGETBOX_QDESIGNER_FORMBUILDER_P_H
55 
57 
58 #include <QtDesigner/formbuilder.h>
59 
60 #include <QtCore/QMap>
61 #include <QtCore/QSet>
62 
63 QT_BEGIN_NAMESPACE
64 
65 class QDesignerFormEditorInterface;
66 class QDesignerFormWindowInterface;
67 
68 class QPixmap;
69 class QtResourceSet;
70 
71 namespace qdesigner_internal {
72 
73 class DesignerPixmapCache;
74 class DesignerIconCache;
75 
76 /* Form builder used for previewing forms and widget box.
77  * It applies the system settings to its toplevel window. */
78 
79 class QDESIGNER_SHARED_EXPORT QDesignerFormBuilder : public QFormBuilder {
80 public:
81  QDesignerFormBuilder(QDesignerFormEditorInterface* core,
82  const DeviceProfile& deviceProfile = DeviceProfile());
83 
84  // XXX Gena's hack
85  enum Mode { DisableScripts, EnableScripts };
86  QDesignerFormBuilder(QDesignerFormEditorInterface* core, Mode mode,
87  const DeviceProfile& deviceProfile = DeviceProfile());
88 
89  virtual QWidget* createWidget(DomWidget* ui_widget, QWidget* parentWidget = 0)
90  {
91  return QFormBuilder::createItemPtr(ui_widget, parentWidget);
92  }
93 
94  inline QDesignerFormEditorInterface* core() const { return m_core; }
95 
96  QString systemStyle() const;
97 
98  // Create a preview widget (for integrations) or return 0. The widget has to be embedded into a
99  // main window. Experimental, depending on script support.
100  static QWidget* createPreview(const QDesignerFormWindowInterface* fw,
101  const QString& styleName /* ="" */,
102  const QString& appStyleSheet /* ="" */,
103  const DeviceProfile& deviceProfile, QString* errorMessage);
104  // Convenience that pops up message boxes in case of failures.
105  static QWidget* createPreview(const QDesignerFormWindowInterface* fw,
106  const QString& styleName = "");
107  // Create a preview widget (for integrations) or return 0. The widget has to be embedded into a
108  // main window.
109  static QWidget* createPreview(const QDesignerFormWindowInterface* fw, const QString& styleName,
110  const QString& appStyleSheet, QString* errorMessage);
111  // Convenience that pops up message boxes in case of failures.
112  static QWidget* createPreview(const QDesignerFormWindowInterface* fw, const QString& styleName,
113  const QString& appStyleSheet);
114 
115  // Create a preview image
116  static QPixmap createPreviewPixmap(const QDesignerFormWindowInterface* fw,
117  const QString& styleName = "",
118  const QString& appStyleSheet = "");
119 
120 protected:
121  using QFormBuilder::create;
122  using QFormBuilder::createDom;
123 
124  virtual QWidget* createItemPtr(DomUI* ui, QWidget* parentWidget);
125  virtual DomWidget* createDom(QWidget* widget, DomWidget* ui_parentWidget,
126  bool recursive = true);
127  virtual QWidget* createItemPtr(DomWidget* ui_widget, QWidget* parentWidget);
128  virtual QLayout* createItemPtr(DomLayout* ui_layout, QLayout* layout, QWidget* parentWidget);
129  virtual void createResources(DomResources* resources);
130 
131  virtual QWidget* createWidget(const QString& widgetName, QWidget* parentWidget,
132  const QString& name);
133  virtual bool addItem(DomWidget* ui_widget, QWidget* widget, QWidget* parentWidget);
134  virtual bool addItem(DomLayoutItem* ui_item, QLayoutItem* item, QLayout* layout);
135 
136  virtual QIcon nameToIcon(const QString& filePath, const QString& qrcPath);
137  virtual QPixmap nameToPixmap(const QString& filePath, const QString& qrcPath);
138 
139  virtual void applyProperties(QObject* o, const QList<DomProperty*>& properties);
140 
141  virtual void loadExtraInfo(DomWidget* ui_widget, QWidget* widget, QWidget* parentWidget);
142 
143  QtResourceSet* internalResourceSet() const { return m_tempResourceSet; }
144 
145  DeviceProfile deviceProfile() const { return m_deviceProfile; }
146 
147 private:
148  QDesignerFormEditorInterface* m_core;
149 
150  typedef QSet<QWidget*> WidgetSet;
152 
154 
158  QtResourceSet* m_tempResourceSet;
160 };
161 
162 // Form builder for a new form widget (preview). To allow for promoted
163 // widgets in the template, it implements the handling of custom widgets
164 // (adding of them to the widget database).
165 
167 public:
168  NewFormWidgetFormBuilder(QDesignerFormEditorInterface* core,
169  const DeviceProfile& deviceProfile = DeviceProfile());
170 
171 protected:
173 };
174 
175 } // namespace qdesigner_internal
176 
177 QT_END_NAMESPACE
178 
179 #endif // BORNAGAIN_GUI_COREGUI_VIEWS_WIDGETBOX_QDESIGNER_FORMBUILDER_P_H
Definition: ui4_p.h:160
NewFormWidgetFormBuilder(QDesignerFormEditorInterface *core, const DeviceProfile &deviceProfile=DeviceProfile())
virtual void createCustomWidgets(DomCustomWidgets *)
QDesignerFormBuilder(QDesignerFormEditorInterface *core, Mode mode, const DeviceProfile &deviceProfile=DeviceProfile())
virtual void createResources(DomResources *resources)
static QWidget * createPreview(const QDesignerFormWindowInterface *fw, const QString &styleName, const QString &appStyleSheet, const DeviceProfile &deviceProfile, QString *errorMessage)
virtual QIcon nameToIcon(const QString &filePath, const QString &qrcPath)
virtual void applyProperties(QObject *o, const QList< DomProperty * > &properties)
virtual QPixmap nameToPixmap(const QString &filePath, const QString &qrcPath)
virtual void loadExtraInfo(DomWidget *ui_widget, QWidget *widget, QWidget *parentWidget)
static QWidget * createPreview(const QDesignerFormWindowInterface *fw, const QString &styleName, const QString &appStyleSheet)
virtual QWidget * createItemPtr(DomWidget *ui_widget, QWidget *parentWidget)
virtual bool addItem(DomWidget *ui_widget, QWidget *widget, QWidget *parentWidget)
static QWidget * createPreview(const QDesignerFormWindowInterface *fw, const QString &styleName, const QString &appStyleSheet, QString *errorMessage)
virtual QLayout * createItemPtr(DomLayout *ui_layout, QLayout *layout, QWidget *parentWidget)
virtual QWidget * createItemPtr(DomUI *ui, QWidget *parentWidget)
static QWidget * createPreview(const QDesignerFormWindowInterface *fw, const QString &styleName="")
QDesignerFormBuilder(QDesignerFormEditorInterface *core, const DeviceProfile &deviceProfile=DeviceProfile())
virtual DomWidget * createDom(QWidget *widget, DomWidget *ui_parentWidget, bool recursive=true)
virtual QWidget * createWidget(const QString &widgetName, QWidget *parentWidget, const QString &name)
virtual bool addItem(DomLayoutItem *ui_item, QLayoutItem *item, QLayout *layout)
QDesignerFormEditorInterface * core() const
virtual QWidget * createWidget(DomWidget *ui_widget, QWidget *parentWidget=0)
static QPixmap createPreviewPixmap(const QDesignerFormWindowInterface *fw, const QString &styleName="", const QString &appStyleSheet="")
QString const & name(EShape k)
Definition: particles.cpp:21
#define QDESIGNER_SHARED_EXPORT