work save: save as template

This commit is contained in:
Roy Qu 2022-04-08 21:15:10 +08:00
parent 628b247fcb
commit 93d16ab9e4
2 changed files with 42 additions and 0 deletions

View File

@ -615,6 +615,45 @@ bool Project::saveUnits()
return true; return true;
} }
void Project::saveAsTemplate(const QString &filename,
const QString &name,
const QString &description,
const QString &category)
{
SimpleIni ini;
ini.SetValue("Template", "Icon", "");
ini.SetValue("Template", "Category",toByteArray(category));
ini.SetValue("Template", "Name",toByteArray(name));
ini.SetValue("Template", "Description", toByteArray(description));
ini.SetValue("Project", "Icon", toByteArray(options().icon));
//todo: save to template
// mOptions.type = static_cast<ProjectType>(mIni->GetLongValue("Project", "Type", 0)); // default = gui
// mOptions.objFiles = fromByteArray(mIni->GetValue("Project", "ObjFiles", "")).split(";",QString::SkipEmptyParts);
// mOptions.includes = fromByteArray(mIni->GetValue("Project", "Includes", "")).split(";",QString::SkipEmptyParts);
// mOptions.libs = fromByteArray(mIni->GetValue("Project", "Libs", "")).split(";",QString::SkipEmptyParts);
// mOptions.resourceIncludes = fromByteArray(mIni->GetValue("Project", "ResourceIncludes", "")).split(";",QString::SkipEmptyParts);
// mOptions.compilerCmd = fromByteArray(mIni->GetValue("Project", "Compiler", ""));
// mOptions.cppCompilerCmd = fromByteArray(mIni->GetValue("Project", "CppCompiler", ""));
// mOptions.linkerCmd = fromByteArray(mIni->GetValue("Project", "Linker",""));
// mOptions.isCpp = mIni->GetBoolValue("Project", "IsCpp", false);
// mOptions.includeVersionInfo = mIni->GetBoolValue("Project", "IncludeVersionInfo", false);
// mOptions.supportXPThemes = mIni->GetBoolValue("Project", "SupportXPThemes", false);
// mOptions.exeOutput = fromByteArray(mIni->GetValue("Project", "ExeOutput", ""));
// mOptions.objectOutput = fromByteArray(mIni->GetValue("Project", "ObjectOutput", ""));
// mOptions.logOutput = fromByteArray(mIni->GetValue("Project", "LogOutput", ""));
// mOptions.staticLink = mIni->GetBoolValue("Project", "StaticLink",true);
// mOptions.addCharset = mIni->GetBoolValue("Project", "AddCharset",true);
// bool useUTF8 = mIni->GetBoolValue("Project", "UseUTF8", false);
// if (useUTF8) {
// mOptions.encoding = fromByteArray(mIni->GetValue("Project","Encoding", ENCODING_UTF8));
// } else {
// mOptions.encoding = fromByteArray(mIni->GetValue("Project","Encoding", ENCODING_AUTO_DETECT));
// }
// mOptions.modelType = (ProjectModelType)mIni->GetLongValue("Project", "ModelType", (int)ProjectModelType::FileSystem);
}
PProjectUnit Project::findUnitByFilename(const QString &filename) PProjectUnit Project::findUnitByFilename(const QString &filename)
{ {
foreach(PProjectUnit unit, mUnits) { foreach(PProjectUnit unit, mUnits) {

View File

@ -204,6 +204,9 @@ public:
void saveOptions(); void saveOptions();
void saveUnitAs(int i, const QString& sFileName, bool syncEditor = true); // save single [UnitX] void saveUnitAs(int i, const QString& sFileName, bool syncEditor = true); // save single [UnitX]
bool saveUnits(); bool saveUnits();
void saveAsTemplate(const QString &filename, const QString &name, const QString &description,
const QString &category);
PProjectUnit findUnitByFilename(const QString& filename); PProjectUnit findUnitByFilename(const QString& filename);
void associateEditor(Editor* editor); void associateEditor(Editor* editor);
void associateEditorToUnit(Editor* editor, PProjectUnit unit); void associateEditorToUnit(Editor* editor, PProjectUnit unit);