source: trunk/src/tools/uic3/ui3reader.h@ 67

Last change on this file since 67 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 8.5 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the tools applications of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** 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 are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef UI3READER_H
43#define UI3READER_H
44
45#include <QDomDocument>
46#include <QString>
47#include <QStringList>
48#include <QMap>
49#include <QTextStream>
50#include <QVariant>
51#include <QByteArray>
52#include <QPair>
53
54QT_BEGIN_NAMESPACE
55
56class DomUI;
57class DomFont;
58class DomWidget;
59class DomProperty;
60class DomLayout;
61class DomLayoutItem;
62class DomActionGroup;
63class Porting;
64struct Color;
65
66typedef QList<QPair<int, Color> > ColorGroup;
67
68class Ui3Reader
69{
70public:
71 Ui3Reader(QTextStream &stream);
72 ~Ui3Reader();
73
74 void computeDeps(const QDomElement &e, QStringList &globalIncludes, QStringList &localIncludes, bool impl = false);
75 void generateUi4(const QString &fn, const QString &outputFn, QDomDocument doc, bool implicitIncludes);
76
77 void generate(const QString &fn, const QString &outputFn,
78 QDomDocument doc, bool decl, bool subcl, const QString &trm,
79 const QString& subclname, bool omitForwardDecls, bool implicitIncludes, const QString &convertedUiFile);
80
81 void embed(const char *project, const QStringList &images);
82
83 void setTrMacro(const QString &trmacro);
84 void setForwardDeclarationsEnabled(bool b);
85 void setOutputFileName(const QString &fileName);
86
87 void createFormDecl(const QDomElement &e, bool implicitIncludes);
88 void createFormImpl(const QDomElement &e);
89
90 void createWrapperDecl(const QDomElement &e, const QString &convertedUiFile);
91
92 void createSubDecl(const QDomElement &e, const QString& subclname);
93 void createSubImpl(const QDomElement &e, const QString& subclname);
94
95 void createColorGroupImpl(const QString& cg, const QDomElement& e);
96 ColorGroup loadColorGroup(const QDomElement &e);
97
98 QDomElement getObjectProperty(const QDomElement& e, const QString& name);
99 QString getPixmapLoaderFunction(const QDomElement& e);
100 QString getFormClassName(const QDomElement& e);
101 QString getClassName(const QDomElement& e);
102 QString getObjectName(const QDomElement& e);
103 QString getLayoutName(const QDomElement& e);
104
105 QString registerObject(const QString& name);
106 QString registeredName(const QString& name);
107 bool isObjectRegistered(const QString& name);
108 QStringList unique(const QStringList&);
109
110 QString trcall(const QString& sourceText, const QString& comment = QString());
111
112 QDomElement parse(const QDomDocument &doc);
113
114 void setExtractImages(bool extract, const QString &qrcOutputFile);
115
116private:
117 void init();
118
119 void createWrapperDeclContents(const QDomElement &e);
120
121 void errorInvalidProperty(const QString &propertyName, const QString &widgetName, const QString &widgetClass,
122 int line, int col);
123 void errorInvalidSignal(const QString &signal, const QString &widgetName, const QString &widgetClass,
124 int line, int col);
125 void errorInvalidSlot(const QString &slot, const QString &widgetName, const QString &widgetClass,
126 int line, int col);
127
128 DomUI *generateUi4(const QDomElement &e, bool implicitIncludes);
129 DomWidget *createWidget(const QDomElement &w, const QString &widgetClass = QString());
130 void createProperties(const QDomElement &e, QList<DomProperty*> *properties, const QString &className);
131 void createAttributes(const QDomElement &e, QList<DomProperty*> *properties, const QString &className);
132 DomLayout *createLayout(const QDomElement &e);
133 DomLayoutItem *createLayoutItem(const QDomElement &e);
134 DomProperty *readProperty(const QDomElement &e);
135 void fixActionGroup(DomActionGroup *g);
136 QString fixActionProperties(QList<DomProperty*> &properties, bool isActionGroup = false);
137
138 QString fixHeaderName(const QString &headerName) const;
139 QString fixClassName(const QString &className) const;
140 QString fixDeclaration(const QString &declaration) const;
141 QString fixType(const QString &type) const;
142 QString fixMethod(const QString &method) const;
143
144 QDomElement findDerivedFontProperties(const QDomElement &n) const;
145
146 void fixLayoutMargin(DomLayout *ui_layout);
147
148 QTextStream &out;
149 QTextOStream trout;
150 QString languageChangeBody;
151 QString outputFileName;
152 QStringList objectNames;
153 QMap<QString,QString> objectMapper;
154 QString indent;
155 QStringList tags;
156 QStringList layouts;
157 QString formName;
158 QString lastItem;
159 QString trmacro;
160 bool nofwd;
161
162 struct Buddy
163 {
164 Buddy(const QString& k, const QString& b)
165 : key(k), buddy(b) {}
166 Buddy(){} // for valuelist
167 QString key;
168 QString buddy;
169 bool operator==(const Buddy& other) const
170 { return (key == other.key); }
171 };
172 struct CustomInclude
173 {
174 QString header;
175 QString location;
176 Q_DUMMY_COMPARISON_OPERATOR(CustomInclude)
177 };
178 QList<Buddy> buddies;
179
180 QStringList layoutObjects;
181 bool isLayout(const QString& name) const;
182
183 uint item_used : 1;
184 uint cg_used : 1;
185 uint pal_used : 1;
186 uint stdsetdef : 1;
187 uint externPixmaps : 1;
188
189 QString uiFileVersion;
190 QString nameOfClass;
191 QStringList namespaces;
192 QString bareNameOfClass;
193 QString pixmapLoaderFunction;
194
195 void registerDatabases(const QDomElement& e);
196 bool isWidgetInTable(const QDomElement& e, const QString& connection, const QString& table);
197 bool isFrameworkCodeGenerated(const QDomElement& e);
198 QString getDatabaseInfo(const QDomElement& e, const QString& tag);
199 void createFormImpl(const QDomElement& e, const QString& form, const QString& connection, const QString& table);
200 void writeFunctionsDecl(const QStringList &fuLst, const QStringList &typLst, const QStringList &specLst);
201 void writeFunctionsSubDecl(const QStringList &fuLst, const QStringList &typLst, const QStringList &specLst);
202 void writeFunctionsSubImpl(const QStringList &fuLst, const QStringList &typLst, const QStringList &specLst,
203 const QString &subClass, const QString &descr);
204 QStringList dbConnections;
205 QMap<QString, QStringList> dbCursors;
206 QMap<QString, QStringList> dbForms;
207
208 static bool isMainWindow;
209 static QString mkBool(bool b);
210 static QString mkBool(const QString& s);
211 bool toBool(const QString& s);
212 static QString fixString(const QString &str, bool encode = false);
213 static bool onlyAscii;
214 static QString mkStdSet(const QString& prop);
215 static QString getComment(const QDomNode& n);
216 QVariant defSpacing, defMargin;
217 QString fileName;
218 bool writeFunctImpl;
219
220 QDomElement root;
221 QDomElement widget;
222
223 QMap<QString, bool> candidateCustomWidgets;
224 Porting *m_porting;
225
226 bool m_extractImages;
227 QString m_qrcOutputFile;
228 QMap<QString, QString> m_imageMap;
229};
230
231QT_END_NAMESPACE
232
233#endif // UI3READER_H
Note: See TracBrowser for help on using the repository browser.