1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the tools applications of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21 ** included in the packaging of this file. Please review the following
22 ** information to ensure the GNU General Public License requirements will
23 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24 **
25 ** $QT_END_LICENSE$
26 **
27 ****************************************************************************/
28 
29 #ifndef UIC_H
30 #define UIC_H
31 
32 #include "databaseinfo.h"
33 #include "customwidgetsinfo.h"
34 #include <qstring.h>
35 #include <qstringlist.h>
36 #include <qstack.h>
37 #include <qxmlstream.h>
38 
39 QT_BEGIN_NAMESPACE
40 
41 class QTextStream;
42 class QIODevice;
43 
44 class Driver;
45 class DomUI;
46 class DomWidget;
47 class DomSpacer;
48 class DomLayout;
49 class DomLayoutItem;
50 class DomItem;
51 
52 struct Option;
53 
54 class Uic
55 {
56     Q_DISABLE_COPY_MOVE(Uic)
57 public:
58     Uic(Driver *driver);
59     ~Uic();
60 
61     bool printDependencies();
62 
driver()63     inline Driver *driver() const
64     { return drv; }
65 
output()66     inline QTextStream &output()
67     { return out; }
68 
option()69     inline const Option &option() const
70     { return opt; }
71 
pixmapFunction()72     inline QString pixmapFunction() const
73     { return pixFunction; }
74 
setPixmapFunction(const QString & f)75     inline void setPixmapFunction(const QString &f)
76     { pixFunction = f; }
77 
databaseInfo()78     inline const DatabaseInfo *databaseInfo() const
79     { return &info; }
80 
customWidgetsInfo()81     inline const CustomWidgetsInfo *customWidgetsInfo() const
82     { return &cWidgetsInfo; }
83 
84     bool write(QIODevice *in);
85 
86     bool write(DomUI *ui);
87 
88     bool isButton(const QString &className) const;
89     bool isContainer(const QString &className) const;
90     bool isMenu(const QString &className) const;
91 
92 private:
93     // copyright header
94     void writeCopyrightHeaderCpp(const DomUI *ui) const;
95     void writeCopyrightHeaderPython(const DomUI *ui) const;
96     DomUI *parseUiFile(QXmlStreamReader &reader);
97 
98     // header protection
99     void writeHeaderProtectionStart();
100     void writeHeaderProtectionEnd();
101 
102 private:
103     Driver *drv;
104     QTextStream &out;
105     Option &opt;
106     DatabaseInfo info;
107     CustomWidgetsInfo cWidgetsInfo;
108     QString pixFunction;
109 };
110 
111 QT_END_NAMESPACE
112 
113 #endif // UIC_H
114