BornAgain  1.19.0
Simulate and fit neutron and x-ray scattering at grazing incidence
qsimpleresource_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_QSIMPLERESOURCE_P_H
54 #define BORNAGAIN_GUI_COREGUI_VIEWS_WIDGETBOX_QSIMPLERESOURCE_P_H
55 
57 #include <QtCore/QStringList>
58 #include <QtDesigner/abstractformbuilder.h>
59 
60 QT_BEGIN_NAMESPACE
61 
62 class DomScript;
63 class DomCustomWidgets;
64 class DomCustomWidget;
65 class DomSlots;
66 
67 class QDesignerFormEditorInterface;
68 
69 namespace qdesigner_internal {
70 
71 class WidgetDataBaseItem;
72 
73 class QDESIGNER_SHARED_EXPORT QSimpleResource : public QAbstractFormBuilder {
74 public:
75  explicit QSimpleResource(QDesignerFormEditorInterface* core);
76  virtual ~QSimpleResource();
77 
78  QBrush setupBrush(DomBrush* brush);
79  DomBrush* saveBrush(const QBrush& brush);
80 
81  inline QDesignerFormEditorInterface* core() const { return m_core; }
82 
83  // Query extensions for additional data
84  static void addExtensionDataToDOM(QAbstractFormBuilder* afb, QDesignerFormEditorInterface* core,
85  DomWidget* ui_widget, QWidget* widget);
86  static void applyExtensionDataFromDOM(QAbstractFormBuilder* afb,
87  QDesignerFormEditorInterface* core, DomWidget* ui_widget,
88  QWidget* widget);
89  // Return the script returned by the CustomWidget codeTemplate API
90  static QString customWidgetScript(QDesignerFormEditorInterface* core, QObject* object);
91  static QString customWidgetScript(QDesignerFormEditorInterface* core, const QString& className);
92  static bool hasCustomWidgetScript(QDesignerFormEditorInterface* core, QObject* object);
93 
94  // Implementation for FormBuilder::createDomCustomWidgets() that adds
95  // the custom widgets to the widget database
96  static void handleDomCustomWidgets(const QDesignerFormEditorInterface* core,
97  const DomCustomWidgets* dom_custom_widgets);
98 
99 protected:
100  enum ScriptSource { ScriptDesigner, ScriptExtension, ScriptCustomWidgetPlugin };
101  static DomScript* createScript(const QString& script, ScriptSource source);
102  typedef QList<DomScript*> DomScripts;
103  static void addScript(const QString& script, ScriptSource source, DomScripts& domScripts);
104 
105  static bool addFakeMethods(const DomSlots* domSlots, QStringList& fakeSlots,
106  QStringList& fakeSignals);
107 
108 private:
109  static void addCustomWidgetsToWidgetDatabase(const QDesignerFormEditorInterface* core,
110  QList<DomCustomWidget*>& custom_widget_list);
111  static void addFakeMethodsToWidgetDataBase(const DomCustomWidget* domCustomWidget,
112  WidgetDataBaseItem* item);
113 
114  static bool m_warningsEnabled;
115  QDesignerFormEditorInterface* m_core;
116 };
117 
118 // Contents of clipboard for formbuilder copy and paste operations
119 // (Actions and widgets)
121  typedef QList<QAction*> ActionList;
122 
124  FormBuilderClipboard(QWidget* w);
125 
126  bool empty() const;
127 
128  QWidgetList m_widgets;
130 };
131 
132 // Base class for a form builder used in the editor that
133 // provides copy and paste.(move into base interface)
135 public:
136  explicit QEditorFormBuilder(QDesignerFormEditorInterface* core) : QSimpleResource(core) {}
137 
138  virtual bool copy(QIODevice* dev, const FormBuilderClipboard& selection) = 0;
139  virtual DomUI* copy(const FormBuilderClipboard& selection) = 0;
140 
141  // A widget parent needs to be specified, otherwise, the widget factory cannot locate the form
142  // window via parent and thus is not able to construct special widgets (QLayoutWidget).
143  virtual FormBuilderClipboard paste(DomUI* ui, QWidget* widgetParent,
144  QObject* actionParent = 0) = 0;
145  virtual FormBuilderClipboard paste(QIODevice* dev, QWidget* widgetParent,
146  QObject* actionParent = 0) = 0;
147 };
148 
149 } // namespace qdesigner_internal
150 
151 QT_END_NAMESPACE
152 
153 #endif // BORNAGAIN_GUI_COREGUI_VIEWS_WIDGETBOX_QSIMPLERESOURCE_P_H
Definition: ui4_p.h:160
virtual bool copy(QIODevice *dev, const FormBuilderClipboard &selection)=0
QEditorFormBuilder(QDesignerFormEditorInterface *core)
virtual FormBuilderClipboard paste(DomUI *ui, QWidget *widgetParent, QObject *actionParent=0)=0
virtual FormBuilderClipboard paste(QIODevice *dev, QWidget *widgetParent, QObject *actionParent=0)=0
virtual DomUI * copy(const FormBuilderClipboard &selection)=0
static void addCustomWidgetsToWidgetDatabase(const QDesignerFormEditorInterface *core, QList< DomCustomWidget * > &custom_widget_list)
DomBrush * saveBrush(const QBrush &brush)
static bool hasCustomWidgetScript(QDesignerFormEditorInterface *core, QObject *object)
static void addExtensionDataToDOM(QAbstractFormBuilder *afb, QDesignerFormEditorInterface *core, DomWidget *ui_widget, QWidget *widget)
static void addFakeMethodsToWidgetDataBase(const DomCustomWidget *domCustomWidget, WidgetDataBaseItem *item)
static void addScript(const QString &script, ScriptSource source, DomScripts &domScripts)
static void applyExtensionDataFromDOM(QAbstractFormBuilder *afb, QDesignerFormEditorInterface *core, DomWidget *ui_widget, QWidget *widget)
QBrush setupBrush(DomBrush *brush)
static bool addFakeMethods(const DomSlots *domSlots, QStringList &fakeSlots, QStringList &fakeSignals)
static QString customWidgetScript(QDesignerFormEditorInterface *core, QObject *object)
QSimpleResource(QDesignerFormEditorInterface *core)
static QString customWidgetScript(QDesignerFormEditorInterface *core, const QString &className)
QDesignerFormEditorInterface * core() const
static void handleDomCustomWidgets(const QDesignerFormEditorInterface *core, const DomCustomWidgets *dom_custom_widgets)
QDesignerFormEditorInterface * m_core
static DomScript * createScript(const QString &script, ScriptSource source)
#define QDESIGNER_SHARED_EXPORT