| 1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
| 2 | // |
| 3 | // SPDX-License-Identifier: GPL-3.0-or-later |
| 4 | |
| 5 | #ifndef PROJECTGENERATE_H |
| 6 | #define PROJECTGENERATE_H |
| 7 | |
| 8 | #include "templateparser.h" |
| 9 | |
| 10 | #include <QObject> |
| 11 | #include <QVector> |
| 12 | #include <QMap> |
| 13 | |
| 14 | namespace templateMgr { |
| 15 | |
| 16 | using SettingParamMap = QMap<QString, QString>; |
| 17 | |
| 18 | enum GenType { |
| 19 | Unknown = 0, |
| 20 | Project, |
| 21 | File |
| 22 | }; |
| 23 | |
| 24 | struct PojectGenParam { |
| 25 | GenType type = Unknown; |
| 26 | QString kit; |
| 27 | QString language; |
| 28 | QString templatePath; |
| 29 | SettingParamMap settingParamMap; |
| 30 | FileGenerator generator; |
| 31 | }; |
| 32 | |
| 33 | struct PojectGenResult { |
| 34 | QString message; |
| 35 | QString kit; |
| 36 | QString language; |
| 37 | QString projectPath; |
| 38 | QString filePath; |
| 39 | }; |
| 40 | |
| 41 | class ProjectGeneratePrivate; |
| 42 | class ProjectGenerate : public QObject |
| 43 | { |
| 44 | Q_OBJECT |
| 45 | public: |
| 46 | explicit ProjectGenerate(QObject *parent = nullptr); |
| 47 | ~ProjectGenerate(); |
| 48 | |
| 49 | bool create(PojectGenResult &retResult, const PojectGenParam &genParam); |
| 50 | signals: |
| 51 | |
| 52 | private slots: |
| 53 | |
| 54 | private: |
| 55 | bool genProject(PojectGenResult &retResult, const PojectGenParam &genParam); |
| 56 | bool copyDir(QString &retMsg, const QString &srcPath, const QString &dstPath, bool cover); |
| 57 | bool transform(QString &retMsg, const PojectGenParam &genParam, const QString &projectPath); |
| 58 | |
| 59 | bool genFile(PojectGenResult &retResult, const PojectGenParam &genParam); |
| 60 | bool copyFile(QString &retMsg, const QString &srcPath, const QString &dstPath, bool cover); |
| 61 | |
| 62 | ProjectGeneratePrivate *const d; |
| 63 | }; |
| 64 | |
| 65 | } //namespace templateMgr |
| 66 | |
| 67 | #endif // PROJECTGENERATE_H |
| 68 | |