~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/tools/uic3/ui3reader.h

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/****************************************************************************
 
2
**
 
3
** Copyright (C) 1992-2005 Trolltech AS. All rights reserved.
 
4
**
 
5
** This file is part of the tools applications of the Qt Toolkit.
 
6
**
 
7
** This file may be distributed under the terms of the Q Public License
 
8
** as defined by Trolltech AS of Norway and appearing in the file
 
9
** LICENSE.QPL included in the packaging of this file.
 
10
**
 
11
** This file may be distributed and/or modified under the terms of the
 
12
** GNU General Public License version 2 as published by the Free Software
 
13
** Foundation and appearing in the file LICENSE.GPL included in the
 
14
** packaging of this file.
 
15
**
 
16
** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
 
17
**   information about Qt Commercial License Agreements.
 
18
** See http://www.trolltech.com/qpl/ for QPL licensing information.
 
19
** See http://www.trolltech.com/gpl/ for GPL licensing information.
 
20
**
 
21
** Contact info@trolltech.com if any conditions of this licensing are
 
22
** not clear to you.
 
23
**
 
24
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 
25
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
 
26
**
 
27
****************************************************************************/
 
28
 
 
29
#ifndef UI3READER_H
 
30
#define UI3READER_H
 
31
 
 
32
#include <qnamespace.h>
 
33
#include <qdom.h>
 
34
#include <qstring.h>
 
35
#include <qstringlist.h>
 
36
#include <qmap.h>
 
37
#include <qtextstream.h>
 
38
#include <qvariant.h>
 
39
#include <qbytearray.h>
 
40
#include <qpair.h>
 
41
 
 
42
class DomUI;
 
43
class DomWidget;
 
44
class DomProperty;
 
45
class DomLayout;
 
46
class DomLayoutItem;
 
47
class DomActionGroup;
 
48
class Porting;
 
49
struct Color;
 
50
 
 
51
typedef QList<QPair<int, Color> > ColorGroup;
 
52
 
 
53
class Ui3Reader
 
54
{
 
55
public:
 
56
    Ui3Reader(QTextStream &stream);
 
57
    ~Ui3Reader();
 
58
 
 
59
    void generateUi4(const QString &fn, const QString &outputFn, QDomDocument doc);
 
60
 
 
61
    void generate(const QString &fn, const QString &outputFn,
 
62
         QDomDocument doc, bool decl, bool subcl, const QString &trm,
 
63
         const QString& subclname, bool omitForwardDecls);
 
64
 
 
65
    void embed(const char *project, const QStringList &images);
 
66
 
 
67
    void setTrMacro(const QString &trmacro);
 
68
    void setForwardDeclarationsEnabled(bool b);
 
69
    void setOutputFileName(const QString &fileName);
 
70
 
 
71
    void createFormDecl(const QDomElement &e);
 
72
    void createFormImpl(const QDomElement &e);
 
73
 
 
74
    void createSubDecl(const QDomElement &e, const QString& subclname);
 
75
    void createSubImpl(const QDomElement &e, const QString& subclname);
 
76
 
 
77
    void createColorGroupImpl(const QString& cg, const QDomElement& e);
 
78
    ColorGroup loadColorGroup(const QDomElement &e);
 
79
 
 
80
    QDomElement getObjectProperty(const QDomElement& e, const QString& name);
 
81
    QString getPixmapLoaderFunction(const QDomElement& e);
 
82
    QString getFormClassName(const QDomElement& e);
 
83
    QString getClassName(const QDomElement& e);
 
84
    QString getObjectName(const QDomElement& e);
 
85
    QString getLayoutName(const QDomElement& e);
 
86
 
 
87
    QString registerObject(const QString& name);
 
88
    QString registeredName(const QString& name);
 
89
    bool isObjectRegistered(const QString& name);
 
90
    QStringList unique(const QStringList&);
 
91
 
 
92
    QString trcall(const QString& sourceText, const QString& comment = QString());
 
93
 
 
94
    QDomElement parse(const QDomDocument &doc);
 
95
 
 
96
private:
 
97
    void init();
 
98
 
 
99
    void errorInvalidProperty(const QString &propertyName, const QString &widgetName, const QString &widgetClass);
 
100
 
 
101
    DomUI *generateUi4(const QDomElement &e);
 
102
    DomWidget *createWidget(const QDomElement &w, const QString &widgetClass = QString());
 
103
    void createProperties(const QDomElement &e, QList<DomProperty*> *properties, const QString &className);
 
104
    void createAttributes(const QDomElement &e, QList<DomProperty*> *properties, const QString &className);
 
105
    DomLayout *createLayout(const QDomElement &e);
 
106
    DomLayoutItem *createLayoutItem(const QDomElement &e);
 
107
    DomProperty *readProperty(const QDomElement &e);
 
108
    void fixActionGroup(DomActionGroup *g);
 
109
    QString fixActionProperties(QList<DomProperty*> &properties, bool isActionGroup = false);
 
110
 
 
111
    QString fixHeaderName(const QString &headerName) const;
 
112
    QString fixClassName(const QString &className) const;
 
113
    QString fixDeclaration(const QString &declaration) const;
 
114
    QString fixType(const QString &type) const;
 
115
 
 
116
    QTextStream &out;
 
117
    QTextOStream trout;
 
118
    QString languageChangeBody;
 
119
    QString outputFileName;
 
120
    QStringList objectNames;
 
121
    QMap<QString,QString> objectMapper;
 
122
    QString indent;
 
123
    QStringList tags;
 
124
    QStringList layouts;
 
125
    QString formName;
 
126
    QString lastItem;
 
127
    QString trmacro;
 
128
    bool nofwd;
 
129
 
 
130
    struct Buddy
 
131
    {
 
132
        Buddy(const QString& k, const QString& b)
 
133
            : key(k), buddy(b) {}
 
134
        Buddy(){} // for valuelist
 
135
        QString key;
 
136
        QString buddy;
 
137
        bool operator==(const Buddy& other) const
 
138
            { return (key == other.key); }
 
139
    };
 
140
    struct CustomInclude
 
141
    {
 
142
        QString header;
 
143
        QString location;
 
144
        Q_DUMMY_COMPARISON_OPERATOR(CustomInclude)
 
145
    };
 
146
    QList<Buddy> buddies;
 
147
 
 
148
    QStringList layoutObjects;
 
149
    bool isLayout(const QString& name) const;
 
150
 
 
151
    uint item_used : 1;
 
152
    uint cg_used : 1;
 
153
    uint pal_used : 1;
 
154
    uint stdsetdef : 1;
 
155
    uint externPixmaps : 1;
 
156
 
 
157
    QString uiFileVersion;
 
158
    QString nameOfClass;
 
159
    QStringList namespaces;
 
160
    QString bareNameOfClass;
 
161
    QString pixmapLoaderFunction;
 
162
 
 
163
    void registerDatabases(const QDomElement& e);
 
164
    bool isWidgetInTable(const QDomElement& e, const QString& connection, const QString& table);
 
165
    bool isFrameworkCodeGenerated(const QDomElement& e);
 
166
    QString getDatabaseInfo(const QDomElement& e, const QString& tag);
 
167
    void createFormImpl(const QDomElement& e, const QString& form, const QString& connection, const QString& table);
 
168
    void writeFunctionsDecl(const QStringList &fuLst, const QStringList &typLst, const QStringList &specLst);
 
169
    void writeFunctionsSubDecl(const QStringList &fuLst, const QStringList &typLst, const QStringList &specLst);
 
170
    void writeFunctionsSubImpl(const QStringList &fuLst, const QStringList &typLst, const QStringList &specLst,
 
171
                                const QString &subClass, const QString &descr);
 
172
    QStringList dbConnections;
 
173
    QMap<QString, QStringList> dbCursors;
 
174
    QMap<QString, QStringList> dbForms;
 
175
 
 
176
    static bool isMainWindow;
 
177
    static QString mkBool(bool b);
 
178
    static QString mkBool(const QString& s);
 
179
    bool toBool(const QString& s);
 
180
    static QString fixString(const QString &str, bool encode = false);
 
181
    static bool onlyAscii;
 
182
    static QString mkStdSet(const QString& prop);
 
183
    static QString getComment(const QDomNode& n);
 
184
    QVariant defSpacing, defMargin;
 
185
    QString fileName;
 
186
    bool writeFunctImpl;
 
187
 
 
188
    QDomElement root;
 
189
    QDomElement widget;
 
190
 
 
191
    QMap<QString, bool> candidateCustomWidgets;
 
192
    Porting *m_porting;
 
193
};
 
194
 
 
195
#endif