comparison tools/duic/driver.h @ 1:e78566595089

initial import
author mandel
date Mon, 11 May 2009 16:01:50 +0000
parents
children
comparison
equal deleted inserted replaced
0:36fb74dc547d 1:e78566595089
1 /****************************************************************************
2 **
3 ** Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: Qt Software Information (qt-info@nokia.com)
5 **
6 ** This file is part of the tools applications of the Qt Toolkit.
7 **
8 ** Commercial Usage
9 ** Licensees holding valid Qt Commercial licenses may use this file in
10 ** accordance with the Qt Commercial License Agreement provided with the
11 ** Software or, alternatively, in accordance with the terms contained in
12 ** a written agreement between you and Nokia.
13 **
14 **
15 ** GNU General Public License Usage
16 ** Alternatively, this file may be used under the terms of the GNU
17 ** General Public License versions 2.0 or 3.0 as published by the Free
18 ** Software Foundation and appearing in the file LICENSE.GPL included in
19 ** the packaging of this file. Please review the following information
20 ** to ensure GNU General Public Licensing requirements will be met:
21 ** http://www.fsf.org/licensing/licenses/info/GPLv2.html and
22 ** http://www.gnu.org/copyleft/gpl.html. In addition, as a special
23 ** exception, Nokia gives you certain additional rights. These rights
24 ** are described in the Nokia Qt GPL Exception version 1.3, included in
25 ** the file GPL_EXCEPTION.txt in this package.
26 **
27 ** Qt for Windows(R) Licensees
28 ** As a special exception, Nokia, as the sole copyright holder for Qt
29 ** Designer, grants users of the Qt/Eclipse Integration plug-in the
30 ** right for the Qt/Eclipse Integration to link to functionality
31 ** provided by Qt Designer and its related libraries.
32 **
33 ** If you are unsure which license is appropriate for your use, please
34 ** contact the sales department at qt-sales@nokia.com.
35 **
36 ****************************************************************************/
37
38 #ifndef DRIVER_H
39 #define DRIVER_H
40
41 #include "option.h"
42 #include <QtCore/QHash>
43 #include <QtCore/QString>
44 #include <QtCore/QStringList>
45 #include <QtCore/QTextStream>
46
47 QT_BEGIN_NAMESPACE
48
49 class QTextStream;
50 class DomUI;
51 class DomWidget;
52 class DomSpacer;
53 class DomLayout;
54 class DomLayoutItem;
55 class DomActionGroup;
56 class DomAction;
57
58 class Driver
59 {
60 public:
61 Driver();
62 virtual ~Driver();
63
64 // tools
65 bool printDependencies(const QString &fileName);
66 bool uic(const QString &fileName, QTextStream *output = 0);
67 bool uic(const QString &fileName, DomUI *ui, QTextStream *output = 0);
68
69 // configuration
70 inline QTextStream &output() const { return *m_output; }
71 inline Option &option() { return m_option; }
72
73 // initialization
74 void reset();
75
76 // error
77 inline QStringList problems() { return m_problems; }
78 inline void addProblem(const QString &problem) { m_problems.append(problem); }
79
80 // utils
81 static QString headerFileName(const QString &fileName);
82 QString headerFileName() const;
83
84 static QString normalizedName(const QString &name);
85 static QString qtify(const QString &name);
86 QString unique(const QString &instanceName=QString(),
87 const QString &className=QString());
88
89 // symbol table
90 QString findOrInsertWidget(DomWidget *ui_widget);
91 QString findOrInsertSpacer(DomSpacer *ui_spacer);
92 QString findOrInsertLayout(DomLayout *ui_layout);
93 QString findOrInsertLayoutItem(DomLayoutItem *ui_layoutItem);
94 QString findOrInsertName(const QString &name);
95 QString findOrInsertActionGroup(DomActionGroup *ui_group);
96 QString findOrInsertAction(DomAction *ui_action);
97
98 inline bool hasName(const QString &name) const
99 { return m_nameRepository.contains(name); }
100
101 DomWidget *widgetByName(const QString &name) const;
102 DomSpacer *spacerByName(const QString &name) const;
103 DomLayout *layoutByName(const QString &name) const;
104 DomActionGroup *actionGroupByName(const QString &name) const;
105 DomAction *actionByName(const QString &name) const;
106
107 // pixmap
108 void insertPixmap(const QString &pixmap);
109 bool containsPixmap(const QString &pixmap) const;
110
111 private:
112 Option m_option;
113 QTextStream m_stdout;
114 QTextStream *m_output;
115
116 QStringList m_problems;
117
118 // symbol tables
119 QHash<DomWidget*, QString> m_widgets;
120 QHash<DomSpacer*, QString> m_spacers;
121 QHash<DomLayout*, QString> m_layouts;
122 QHash<DomActionGroup*, QString> m_actionGroups;
123 QHash<DomAction*, QString> m_actions;
124 QHash<QString, bool> m_nameRepository;
125 QHash<QString, bool> m_pixmaps;
126 };
127
128 QT_END_NAMESPACE
129
130 #endif // DRIVER_H