1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef CPPWRITEINCLUDES_H
5#define CPPWRITEINCLUDES_H
6
7#include <writeincludesbase.h>
8
9#include <QtCore/qmap.h>
10
11#include <set>
12
13QT_BEGIN_NAMESPACE
14
15class QTextStream;
16
17namespace CPP {
18
19class WriteIncludes : public WriteIncludesBase
20{
21public:
22 WriteIncludes(Uic *uic);
23
24 void acceptUI(DomUI *node) override;
25 void acceptInclude(DomInclude *node) override;
26
27protected:
28 QTextStream &output() const { return m_output; }
29 void doAdd(const QString &className, const DomCustomWidget *dcw = nullptr) override;
30
31private:
32 using OrderedSet = std::set<QString>;
33 void addCppCustomWidget(const QString &className, const DomCustomWidget *dcw);
34 void insertIncludeForClass(const QString &className, QString header = QString(), bool global = false);
35 void insertInclude(const QString &header, bool global);
36 void writeHeaders(const OrderedSet &headers, bool global);
37 QString headerForClassName(const QString &className) const;
38
39 QTextStream &m_output;
40
41 OrderedSet m_localIncludes;
42 OrderedSet m_globalIncludes;
43 QSet<QString> m_includeBaseNames;
44 using StringMap = QMap<QString, QString>;
45 StringMap m_classToHeader;
46 StringMap m_oldHeaderToNewHeader;
47};
48
49} // namespace CPP
50
51QT_END_NAMESPACE
52
53#endif // CPPWRITEINCLUDES_H
54

source code of qtbase/src/tools/uic/cpp/cppwriteincludes.h