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 CPPWRITEINCLUDES_H |
30 | #define CPPWRITEINCLUDES_H |
31 | |
32 | #include "treewalker.h" |
33 | |
34 | #include <qmap.h> |
35 | #include <qset.h> |
36 | #include <qstring.h> |
37 | |
38 | #include <set> |
39 | |
40 | QT_BEGIN_NAMESPACE |
41 | |
42 | class QTextStream; |
43 | class CustomWidgetsInfo; |
44 | class Driver; |
45 | class Uic; |
46 | |
47 | namespace CPP { |
48 | |
49 | struct WriteIncludes : public TreeWalker |
50 | { |
51 | WriteIncludes(Uic *uic); |
52 | |
53 | void acceptUI(DomUI *node) override; |
54 | void acceptWidget(DomWidget *node) override; |
55 | void acceptLayout(DomLayout *node) override; |
56 | void acceptSpacer(DomSpacer *node) override; |
57 | void acceptProperty(DomProperty *node) override; |
58 | |
59 | // |
60 | // actions |
61 | // |
62 | void acceptActionGroup(DomActionGroup *node) override; |
63 | void acceptAction(DomAction *node) override; |
64 | void acceptActionRef(DomActionRef *node) override; |
65 | |
66 | // |
67 | // custom widgets |
68 | // |
69 | void acceptCustomWidgets(DomCustomWidgets *node) override; |
70 | void acceptCustomWidget(DomCustomWidget *node) override; |
71 | |
72 | // |
73 | // include hints |
74 | // |
75 | void acceptIncludes(DomIncludes *node) override; |
76 | void acceptInclude(DomInclude *node) override; |
77 | |
78 | protected: |
79 | QTextStream &output() const { return m_output; } |
80 | |
81 | private: |
82 | void add(const QString &className, bool = true, const QString & = QString(), bool global = false); |
83 | |
84 | private: |
85 | using OrderedSet = std::set<QString>; |
86 | void insertIncludeForClass(const QString &className, QString = QString(), bool global = false); |
87 | void insertInclude(const QString &, bool global); |
88 | void (const OrderedSet &, bool global); |
89 | QString (const QString &className) const; |
90 | |
91 | const Uic *m_uic; |
92 | QTextStream &m_output; |
93 | |
94 | OrderedSet m_localIncludes; |
95 | OrderedSet m_globalIncludes; |
96 | QSet<QString> m_includeBaseNames; |
97 | |
98 | QSet<QString> m_knownClasses; |
99 | |
100 | using StringMap = QMap<QString, QString>; |
101 | StringMap ; |
102 | StringMap ; |
103 | |
104 | bool m_laidOut = false; |
105 | }; |
106 | |
107 | } // namespace CPP |
108 | |
109 | QT_END_NAMESPACE |
110 | |
111 | #endif // CPPWRITEINCLUDES_H |
112 | |