1 | // Copyright (C) 2018 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 PYTHONWRITEIMPORTS_H |
5 | #define PYTHONWRITEIMPORTS_H |
6 | |
7 | #include <writeincludesbase.h> |
8 | |
9 | #include <QtCore/qhash.h> |
10 | #include <QtCore/qmap.h> |
11 | #include <QtCore/qstringlist.h> |
12 | |
13 | QT_BEGIN_NAMESPACE |
14 | |
15 | namespace Python { |
16 | |
17 | class WriteImports : public WriteIncludesBase |
18 | { |
19 | public: |
20 | using ClassesPerModule = QMap<QString, QStringList>; |
21 | |
22 | explicit WriteImports(Uic *uic); |
23 | |
24 | void acceptUI(DomUI *node) override; |
25 | void acceptProperty(DomProperty *node) override; |
26 | |
27 | protected: |
28 | void doAdd(const QString &className, const DomCustomWidget *dcw = nullptr) override; |
29 | |
30 | private: |
31 | void addPythonCustomWidget(const QString &className, const DomCustomWidget *dcw); |
32 | bool addQtClass(const QString &className); |
33 | void addEnumBaseClass(const QString &v); |
34 | void writeResourceImport(const QString &module); |
35 | QString resourceAbsolutePath(QString resource) const; |
36 | |
37 | QHash<QString, QString> m_classToModule; |
38 | // Module->class (modules sorted) |
39 | |
40 | ClassesPerModule m_qtClasses; |
41 | ClassesPerModule m_customWidgets; |
42 | QStringList m_plainCustomWidgets; // Custom widgets without any module |
43 | }; |
44 | |
45 | } // namespace Python |
46 | |
47 | QT_END_NAMESPACE |
48 | |
49 | #endif // PYTHONWRITEIMPORTS_H |
50 | |