0
|
1 |
/****************************************************************************
|
|
2 |
**
|
|
3 |
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
4 |
** All rights reserved.
|
|
5 |
** Contact: Nokia Corporation (qt-info@nokia.com)
|
|
6 |
**
|
|
7 |
** This file is part of the tools applications of the Qt Toolkit.
|
|
8 |
**
|
|
9 |
** $QT_BEGIN_LICENSE:LGPL$
|
|
10 |
** No Commercial Usage
|
|
11 |
** This file contains pre-release code and may not be distributed.
|
|
12 |
** You may use this file in accordance with the terms and conditions
|
|
13 |
** contained in the Technology Preview License Agreement accompanying
|
|
14 |
** this package.
|
|
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 |
** If you have questions regarding the use of this file, please contact
|
|
29 |
** Nokia at qt-info@nokia.com.
|
|
30 |
**
|
|
31 |
**
|
|
32 |
**
|
|
33 |
**
|
|
34 |
**
|
|
35 |
**
|
|
36 |
**
|
|
37 |
**
|
|
38 |
** $QT_END_LICENSE$
|
|
39 |
**
|
|
40 |
****************************************************************************/
|
|
41 |
|
|
42 |
#ifndef DRIVER_H
|
|
43 |
#define DRIVER_H
|
|
44 |
|
|
45 |
#include "option.h"
|
|
46 |
#include <QtCore/QHash>
|
|
47 |
#include <QtCore/QString>
|
|
48 |
#include <QtCore/QStringList>
|
|
49 |
#include <QtCore/QTextStream>
|
|
50 |
|
|
51 |
QT_BEGIN_NAMESPACE
|
|
52 |
|
|
53 |
class QTextStream;
|
|
54 |
class DomUI;
|
|
55 |
class DomWidget;
|
|
56 |
class DomSpacer;
|
|
57 |
class DomLayout;
|
|
58 |
class DomLayoutItem;
|
|
59 |
class DomActionGroup;
|
|
60 |
class DomAction;
|
|
61 |
class DomButtonGroup;
|
|
62 |
|
|
63 |
class Driver
|
|
64 |
{
|
|
65 |
public:
|
|
66 |
Driver();
|
|
67 |
virtual ~Driver();
|
|
68 |
|
|
69 |
// tools
|
|
70 |
bool printDependencies(const QString &fileName);
|
|
71 |
bool uic(const QString &fileName, QTextStream *output = 0);
|
|
72 |
bool uic(const QString &fileName, DomUI *ui, QTextStream *output = 0);
|
|
73 |
|
|
74 |
// configuration
|
|
75 |
inline QTextStream &output() const { return *m_output; }
|
|
76 |
inline Option &option() { return m_option; }
|
|
77 |
|
|
78 |
// initialization
|
|
79 |
void reset();
|
|
80 |
|
|
81 |
// error
|
|
82 |
inline QStringList problems() { return m_problems; }
|
|
83 |
inline void addProblem(const QString &problem) { m_problems.append(problem); }
|
|
84 |
|
|
85 |
// utils
|
|
86 |
static QString headerFileName(const QString &fileName);
|
|
87 |
QString headerFileName() const;
|
|
88 |
|
|
89 |
static QString normalizedName(const QString &name);
|
|
90 |
static QString qtify(const QString &name);
|
|
91 |
QString unique(const QString &instanceName=QString(),
|
|
92 |
const QString &className=QString());
|
|
93 |
|
|
94 |
// symbol table
|
|
95 |
QString findOrInsertWidget(DomWidget *ui_widget);
|
|
96 |
QString findOrInsertSpacer(DomSpacer *ui_spacer);
|
|
97 |
QString findOrInsertLayout(DomLayout *ui_layout);
|
|
98 |
QString findOrInsertLayoutItem(DomLayoutItem *ui_layoutItem);
|
|
99 |
QString findOrInsertName(const QString &name);
|
|
100 |
QString findOrInsertActionGroup(DomActionGroup *ui_group);
|
|
101 |
QString findOrInsertAction(DomAction *ui_action);
|
|
102 |
QString findOrInsertButtonGroup(const DomButtonGroup *ui_group);
|
|
103 |
// Find a group by its non-uniqified name
|
|
104 |
const DomButtonGroup *findButtonGroup(const QString &attributeName) const;
|
|
105 |
|
|
106 |
inline bool hasName(const QString &name) const
|
|
107 |
{ return m_nameRepository.contains(name); }
|
|
108 |
|
|
109 |
DomWidget *widgetByName(const QString &name) const;
|
|
110 |
DomSpacer *spacerByName(const QString &name) const;
|
|
111 |
DomLayout *layoutByName(const QString &name) const;
|
|
112 |
DomActionGroup *actionGroupByName(const QString &name) const;
|
|
113 |
DomAction *actionByName(const QString &name) const;
|
|
114 |
|
|
115 |
// pixmap
|
|
116 |
void insertPixmap(const QString &pixmap);
|
|
117 |
bool containsPixmap(const QString &pixmap) const;
|
|
118 |
|
|
119 |
private:
|
|
120 |
Option m_option;
|
|
121 |
QTextStream m_stdout;
|
|
122 |
QTextStream *m_output;
|
|
123 |
|
|
124 |
QStringList m_problems;
|
|
125 |
|
|
126 |
// symbol tables
|
|
127 |
QHash<DomWidget*, QString> m_widgets;
|
|
128 |
QHash<DomSpacer*, QString> m_spacers;
|
|
129 |
QHash<DomLayout*, QString> m_layouts;
|
|
130 |
QHash<DomActionGroup*, QString> m_actionGroups;
|
|
131 |
typedef QHash<const DomButtonGroup*, QString> ButtonGroupNameHash;
|
|
132 |
ButtonGroupNameHash m_buttonGroups;
|
|
133 |
QHash<DomAction*, QString> m_actions;
|
|
134 |
QHash<QString, bool> m_nameRepository;
|
|
135 |
QHash<QString, bool> m_pixmaps;
|
|
136 |
};
|
|
137 |
|
|
138 |
QT_END_NAMESPACE
|
|
139 |
|
|
140 |
#endif // DRIVER_H
|