| 1 | /* |
| 2 | * Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com) |
| 3 | * |
| 4 | * This program is free software: you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation, either version 3 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 16 | */ |
| 17 | #ifndef PROJECTTEMPLATE_H |
| 18 | #define PROJECTTEMPLATE_H |
| 19 | |
| 20 | #include <QObject> |
| 21 | #include "utils.h" |
| 22 | #include "projectoptions.h" |
| 23 | |
| 24 | struct TemplateUnit { |
| 25 | QString CName; |
| 26 | QString CppName; |
| 27 | QString CText; |
| 28 | QString CppText; |
| 29 | QString Source; |
| 30 | QString Target; |
| 31 | }; |
| 32 | |
| 33 | using PTemplateUnit = std::shared_ptr<TemplateUnit>; |
| 34 | |
| 35 | class ProjectTemplate : public QObject |
| 36 | { |
| 37 | Q_OBJECT |
| 38 | public: |
| 39 | explicit ProjectTemplate(QObject *parent = nullptr); |
| 40 | int unitCount(); |
| 41 | PTemplateUnit unit(int index); |
| 42 | void readTemplateFile(const QString& fileName); |
| 43 | bool save(); |
| 44 | const QString &category() const; |
| 45 | void setCategory(const QString &newCategory); |
| 46 | |
| 47 | const QString &description() const; |
| 48 | void setDescription(const QString &newDescription); |
| 49 | |
| 50 | const QString &fileName() const; |
| 51 | void setFileName(const QString &newFileName); |
| 52 | |
| 53 | const QString folder() const; |
| 54 | |
| 55 | const QString &icon() const; |
| 56 | void setIcon(const QString &newIcon); |
| 57 | |
| 58 | const QString &name() const; |
| 59 | void setName(const QString &newName); |
| 60 | |
| 61 | const ProjectOptions &options() const; |
| 62 | void setOptions(const ProjectOptions &newOptions); |
| 63 | |
| 64 | int version() const; |
| 65 | |
| 66 | void setVersion(int newVersion); |
| 67 | |
| 68 | private: |
| 69 | QString mFileName; |
| 70 | ProjectOptions mOptions; |
| 71 | QString mDescription; |
| 72 | QString mCategory; |
| 73 | QString mName; |
| 74 | QString mIcon; // icon in project form |
| 75 | PSimpleIni mIni; |
| 76 | int mVersion; |
| 77 | }; |
| 78 | using PProjectTemplate = std::shared_ptr<ProjectTemplate>; |
| 79 | |
| 80 | #endif // PROJECTTEMPLATE_H |
| 81 | |