summaryrefslogtreecommitdiff
path: root/src/tools/uic/cpp/cppwriteincludes.h
blob: 1ec10f39b26b77050b6ee80f46b45d244bb0d333 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#ifndef CPPWRITEINCLUDES_H
#define CPPWRITEINCLUDES_H

#include <writeincludesbase.h>

#include <QtCore/qmap.h>

#include <set>

QT_BEGIN_NAMESPACE

class QTextStream;

namespace CPP {

class  WriteIncludes : public WriteIncludesBase
{
public:
    WriteIncludes(Uic *uic);

    void acceptUI(DomUI *node) override;
    void acceptInclude(DomInclude *node) override;

protected:
     QTextStream &output() const { return m_output; }
     void doAdd(const QString &className, const DomCustomWidget *dcw = nullptr) override;

private:
    using OrderedSet = std::set<QString>;
    void addCppCustomWidget(const QString &className, const DomCustomWidget *dcw);
    void insertIncludeForClass(const QString &className, QString header = QString(), bool global = false);
    void insertInclude(const QString &header, bool global);
    void writeHeaders(const OrderedSet &headers, bool global);
    QString headerForClassName(const QString &className) const;

    QTextStream &m_output;

    OrderedSet m_localIncludes;
    OrderedSet m_globalIncludes;
    QSet<QString> m_includeBaseNames;
    using StringMap = QMap<QString, QString>;
    StringMap m_classToHeader;
    StringMap m_oldHeaderToNewHeader;
};

} // namespace CPP

QT_END_NAMESPACE

#endif // CPPWRITEINCLUDES_H