2021-12-26 23:18:28 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2020-2022 Roy Qu (royqh1979@gmail.com)
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
2021-09-15 22:19:59 +08:00
|
|
|
#ifndef PROJECTTEMPLATE_H
|
|
|
|
#define PROJECTTEMPLATE_H
|
|
|
|
|
|
|
|
#include <QObject>
|
2021-09-16 12:03:10 +08:00
|
|
|
#include "utils.h"
|
|
|
|
#include "projectoptions.h"
|
2021-09-15 22:19:59 +08:00
|
|
|
|
|
|
|
struct TemplateUnit {
|
|
|
|
QString CName;
|
|
|
|
QString CppName;
|
|
|
|
QString CText;
|
|
|
|
QString CppText;
|
2022-01-10 10:53:16 +08:00
|
|
|
QString Source;
|
|
|
|
QString Target;
|
2021-09-15 22:19:59 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
using PTemplateUnit = std::shared_ptr<TemplateUnit>;
|
|
|
|
|
|
|
|
class ProjectTemplate : public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
public:
|
|
|
|
explicit ProjectTemplate(QObject *parent = nullptr);
|
|
|
|
int unitCount();
|
|
|
|
PTemplateUnit unit(int index);
|
2021-09-16 12:03:10 +08:00
|
|
|
void readTemplateFile(const QString& fileName);
|
|
|
|
bool save();
|
|
|
|
const QString &category() const;
|
|
|
|
void setCategory(const QString &newCategory);
|
|
|
|
|
|
|
|
const QString &description() const;
|
|
|
|
void setDescription(const QString &newDescription);
|
|
|
|
|
|
|
|
const QString &fileName() const;
|
|
|
|
void setFileName(const QString &newFileName);
|
|
|
|
|
2022-08-07 12:09:22 +08:00
|
|
|
const QString folder() const;
|
|
|
|
|
2021-09-16 12:03:10 +08:00
|
|
|
const QString &icon() const;
|
|
|
|
void setIcon(const QString &newIcon);
|
|
|
|
|
|
|
|
const QString &name() const;
|
|
|
|
void setName(const QString &newName);
|
|
|
|
|
|
|
|
const ProjectOptions &options() const;
|
|
|
|
void setOptions(const ProjectOptions &newOptions);
|
2021-09-15 22:19:59 +08:00
|
|
|
|
2021-09-16 23:51:05 +08:00
|
|
|
int version() const;
|
|
|
|
|
2022-08-07 21:41:57 +08:00
|
|
|
void setVersion(int newVersion);
|
|
|
|
|
2021-09-15 22:19:59 +08:00
|
|
|
private:
|
|
|
|
QString mFileName;
|
|
|
|
ProjectOptions mOptions;
|
2021-09-16 12:03:10 +08:00
|
|
|
QString mDescription;
|
2021-09-15 22:19:59 +08:00
|
|
|
QString mCategory;
|
|
|
|
QString mName;
|
|
|
|
QString mIcon; // icon in project form
|
2021-09-16 12:03:10 +08:00
|
|
|
PSimpleIni mIni;
|
2021-09-15 22:19:59 +08:00
|
|
|
int mVersion;
|
|
|
|
};
|
2021-09-16 12:03:10 +08:00
|
|
|
using PProjectTemplate = std::shared_ptr<ProjectTemplate>;
|
2021-09-15 22:19:59 +08:00
|
|
|
|
|
|
|
#endif // PROJECTTEMPLATE_H
|