source: trunk/tools/designer/src/lib/shared/qsimpleresource_p.h@ 846

Last change on this file since 846 was 846, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 6.5 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the Qt Designer of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this 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 have questions regarding the use of this file, please contact
37** Nokia at [email protected].
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 QSIMPLERESOURCE_H
54#define QSIMPLERESOURCE_H
55
56#include "shared_global_p.h"
57#include "abstractformbuilder.h"
58#include <QtCore/QStringList>
59
60QT_BEGIN_NAMESPACE
61
62class DomScript;
63class DomCustomWidgets;
64class DomCustomWidget;
65class DomSlots;
66
67class QDesignerFormEditorInterface;
68
69namespace qdesigner_internal {
70
71class WidgetDataBaseItem;
72
73class QDESIGNER_SHARED_EXPORT QSimpleResource : public QAbstractFormBuilder
74{
75public:
76 explicit QSimpleResource(QDesignerFormEditorInterface *core);
77 virtual ~QSimpleResource();
78
79 QBrush setupBrush(DomBrush *brush);
80 DomBrush *saveBrush(const QBrush &brush);
81
82 inline QDesignerFormEditorInterface *core() const
83 { return m_core; }
84
85 // Query extensions for additional data
86 static void addExtensionDataToDOM(QAbstractFormBuilder *afb,
87 QDesignerFormEditorInterface *core,
88 DomWidget *ui_widget, QWidget *widget);
89 static void applyExtensionDataFromDOM(QAbstractFormBuilder *afb,
90 QDesignerFormEditorInterface *core,
91 DomWidget *ui_widget, QWidget *widget,
92 bool applyState);
93 // Enable warnings while saving. Turn off for backups.
94 static bool setWarningsEnabled(bool warningsEnabled);
95 static bool warningsEnabled();
96 // Return the script returned by the CustomWidget codeTemplate API
97 static QString customWidgetScript(QDesignerFormEditorInterface *core, QObject *object);
98 static QString customWidgetScript(QDesignerFormEditorInterface *core, const QString &className);
99 static bool hasCustomWidgetScript(QDesignerFormEditorInterface *core, QObject *object);
100
101 // Implementation for FormBuilder::createDomCustomWidgets() that adds
102 // the custom widgets to the widget database
103 static void handleDomCustomWidgets(const QDesignerFormEditorInterface *core,
104 const DomCustomWidgets *dom_custom_widgets);
105
106protected:
107 virtual QIcon nameToIcon(const QString &filePath, const QString &qrcPath);
108 virtual QString iconToFilePath(const QIcon &pm) const;
109 virtual QString iconToQrcPath(const QIcon &pm) const;
110 virtual QPixmap nameToPixmap(const QString &filePath, const QString &qrcPath);
111 virtual QString pixmapToFilePath(const QPixmap &pm) const;
112 virtual QString pixmapToQrcPath(const QPixmap &pm) const;
113
114 enum ScriptSource { ScriptDesigner, ScriptExtension, ScriptCustomWidgetPlugin };
115 static DomScript*createScript(const QString &script, ScriptSource source);
116 typedef QList<DomScript*> DomScripts;
117 static void addScript(const QString &script, ScriptSource source, DomScripts &domScripts);
118
119 static bool addFakeMethods(const DomSlots *domSlots, QStringList &fakeSlots, QStringList &fakeSignals);
120
121private:
122 static void addCustomWidgetsToWidgetDatabase(const QDesignerFormEditorInterface *core,
123 QList<DomCustomWidget*>& custom_widget_list);
124 static void addFakeMethodsToWidgetDataBase(const DomCustomWidget *domCustomWidget, WidgetDataBaseItem *item);
125
126 static bool m_warningsEnabled;
127 QDesignerFormEditorInterface *m_core;
128};
129
130// Contents of clipboard for formbuilder copy and paste operations
131// (Actions and widgets)
132struct QDESIGNER_SHARED_EXPORT FormBuilderClipboard {
133 typedef QList<QAction*> ActionList;
134
135 FormBuilderClipboard() {}
136 FormBuilderClipboard(QWidget *w);
137
138 bool empty() const;
139
140 QWidgetList m_widgets;
141 ActionList m_actions;
142};
143
144// Base class for a form builder used in the editor that
145// provides copy and paste.(move into base interface)
146class QDESIGNER_SHARED_EXPORT QEditorFormBuilder : public QSimpleResource
147{
148public:
149 explicit QEditorFormBuilder(QDesignerFormEditorInterface *core) : QSimpleResource(core) {}
150
151 virtual bool copy(QIODevice *dev, const FormBuilderClipboard &selection) = 0;
152 virtual DomUI *copy(const FormBuilderClipboard &selection) = 0;
153
154 // A widget parent needs to be specified, otherwise, the widget factory cannot locate the form window via parent
155 // and thus is not able to construct special widgets (QLayoutWidget).
156 virtual FormBuilderClipboard paste(DomUI *ui, QWidget *widgetParent, QObject *actionParent = 0) = 0;
157 virtual FormBuilderClipboard paste(QIODevice *dev, QWidget *widgetParent, QObject *actionParent = 0) = 0;
158};
159
160} // namespace qdesigner_internal
161
162QT_END_NAMESPACE
163
164#endif
Note: See TracBrowser for help on using the repository browser.