1 | // SPDX-FileCopyrightText: 2023 UnionTech Software Technology Co., Ltd. |
---|---|
2 | // |
3 | // SPDX-License-Identifier: GPL-3.0-or-later |
4 | |
5 | #ifndef TEMPLATEPARSER_H |
6 | #define TEMPLATEPARSER_H |
7 | |
8 | #include <QObject> |
9 | #include <QVector> |
10 | #include <QMap> |
11 | |
12 | namespace templateMgr { |
13 | |
14 | struct TemplateDetail{ |
15 | QString name; |
16 | QString path; |
17 | bool leafNode; |
18 | }; |
19 | |
20 | struct TemplateCategory { |
21 | QString type; |
22 | QVector<TemplateDetail> templateVec; |
23 | }; |
24 | |
25 | struct Template { |
26 | QString category; |
27 | QVector<TemplateCategory> templateVec; |
28 | }; |
29 | |
30 | using TemplateVector = QVector<Template>; |
31 | |
32 | |
33 | struct EditItem { |
34 | QString key; |
35 | QString displayName; |
36 | QString type; |
37 | QStringList defaultValues; |
38 | bool browse; |
39 | }; |
40 | |
41 | struct FileOperator { |
42 | QString sourceFile; |
43 | QStringList replaceKeys; |
44 | }; |
45 | |
46 | struct FileGenerator { |
47 | QString rootFolder; |
48 | QString destPath; |
49 | QString templateFile; |
50 | QString newfileName; |
51 | QVector<FileOperator> operations; |
52 | }; |
53 | |
54 | struct WizardInfo { |
55 | QString type; |
56 | QString kit; |
57 | QString language; |
58 | QString trDisplayName; |
59 | QString trDescription; |
60 | QVector<EditItem> configures; |
61 | FileGenerator generator; |
62 | }; |
63 | |
64 | class TemplateParser : public QObject |
65 | { |
66 | Q_OBJECT |
67 | public: |
68 | static bool readTemplateConfig(TemplateVector &templateVec); |
69 | static bool readWizardConfig(const QString &projectPath, WizardInfo &wizardInfo); |
70 | |
71 | signals: |
72 | |
73 | private slots: |
74 | |
75 | private: |
76 | explicit TemplateParser(QObject *parent = nullptr); |
77 | ~TemplateParser(); |
78 | |
79 | }; |
80 | |
81 | } //namespace templateMgr |
82 | |
83 | Q_DECLARE_METATYPE(templateMgr::TemplateDetail) |
84 | |
85 | #endif // TEMPLATEPARSER_H |
86 |