work save

This commit is contained in:
royqh1979@gmail.com 2021-09-10 10:27:01 +08:00
parent cc0ea5661b
commit 06b30e77d5
2 changed files with 100 additions and 79 deletions

View File

@ -179,6 +179,19 @@ void Project::setModified(bool value)
} }
} }
PFolderNode Project::makeNewFileNode(const QString &s, bool isFolder, PFolderNode newParent)
{
PFolderNode node = std::make_shared<FolderNode>();
node->parent = newParent;
node->text = s;
}
PFolderNode Project::makeProjectNode()
{
PFolderNode node = std::make_shared<FolderNode>();
node->text = mName;
}
void Project::addFolder(const QString &s) void Project::addFolder(const QString &s)
{ {
if (mFolders.indexOf(s)<0) { if (mFolders.indexOf(s)<0) {
@ -656,11 +669,11 @@ QString Project::getFolderPath(PFolderNode node)
if (node->unitIndex>=0) // not a folder if (node->unitIndex>=0) // not a folder
return result; return result;
FolderNode* p = node.get(); PFolderNode p = node;
while (p && p->unitIndex==-1) { while (p && p->unitIndex==-1) {
if (!result.isEmpty()) if (!result.isEmpty())
result = p->text + "/" + result; result = p->text + "/" + result;
p = p->parent; p = p->parent.lock();
} }
return result; return result;
} }
@ -735,80 +748,88 @@ void Project::loadOptions()
mOptions.type = static_cast<ProjectType>(mIniFile->value("type", 0).toInt()); mOptions.type = static_cast<ProjectType>(mIniFile->value("type", 0).toInt());
mOptions.compilerCmd = mIniFile->value("Compiler", "").toString(); mOptions.compilerCmd = mIniFile->value("Compiler", "").toString();
mOptions.cppCompilerCmd = mIniFile->value("CppCompiler", "").toString(); mOptions.cppCompilerCmd = mIniFile->value("CppCompiler", "").toString();
fOptions.LinkerCmd := ReadString('Project', 'Linker', ''); mOptions.linkerCmd = mIniFile->value("Linker", "").toString();
fOptions.ObjFiles.DelimitedText := ReadString('Project', 'ObjFiles', ''); mOptions.objFiles = mIniFile->value("ObjFiles", "").toString().split(";");
fOptions.Libs.DelimitedText := ReadString('Project', 'Libs', ''); mOptions.libs = mIniFile->value("Libs", "").toString().split(";");
fOptions.Includes.DelimitedText := ReadString('Project', 'Includes', ''); mOptions.includes = mIniFile->value("Includes", "").toString().split(";");
fOptions.PrivateResource := ReadString('Project', 'PrivateResource', ''); mOptions.privateResource = mIniFile->value("PrivateResource", "").toString();
fOptions.ResourceIncludes.DelimitedText := ReadString('Project', 'ResourceIncludes', ''); mOptions.resourceIncludes = mIniFile->value("ResourceIncludes", "").toString().split(";");
fOptions.MakeIncludes.DelimitedText := ReadString('Project', 'MakeIncludes', ''); mOptions.makeIncludes = mIniFile->value("MakeIncludes","").toString().split(";");
fOptions.UseGpp := ReadBool('Project', 'IsCpp', FALSE); mOptions.useGPP = mIniFile->value("IsCpp", false).toBool();
fOptions.ExeOutput := ReadString('Project', 'ExeOutput', ''); mOptions.exeOutput = mIniFile->value("ExeOutput", "").toString();
fOptions.ObjectOutput := ReadString('Project', 'ObjectOutput', ''); mOptions.objectOutput = mIniFile->value("ObjectOutput", "").toString();
fOptions.LogOutput := ReadString('Project', 'LogOutput', ''); mOptions.logOutput = mIniFile->value("LogOutput","").toString();
fOptions.LogOutputEnabled := ReadBool('Project', 'LogOutputEnabled', FALSE); mOptions.logOutputEnabled = mIniFile->value("LogOutputEnabled", false).toBool();
fOptions.OverrideOutput := ReadBool('Project', 'OverrideOutput', FALSE); mOptions.overrideOutput = mIniFile->value("OverrideOutput", false).toBool();
fOptions.OverridenOutput := ReadString('Project', 'OverrideOutputName', ''); mOptions.overridenOutput = mIniFile->value("OverrideOutputName","").toString();
fOptions.HostApplication := ReadString('Project', 'HostApplication', ''); mOptions.hostApplication = mIniFile->value("HostApplication","").toString();
fOptions.UseCustomMakefile := ReadBool('Project', 'UseCustomMakefile', FALSE); mOptions.useCustomMakefile = mIniFile->value("UseCustomMakefile", false).toBool();
fOptions.CustomMakefile := ReadString('Project', 'CustomMakefile', ''); mOptions.customMakefile = mIniFile->value("CustomMakefile","").toString();
fOptions.UsePrecompiledHeader := ReadBool('Project', 'UsePrecompiledHeader', FALSE); mOptions.usePrecompiledHeader = mIniFile->value("UsePrecompiledHeader", false).toBool();
fOptions.PrecompiledHeader := ReadString('Project', 'PrecompiledHeader', ''); mOptions.precompiledHeader = mIniFile->value("PrecompiledHeader","").toString();
fOptions.CmdLineArgs := ReadString('Project', 'CommandLine', ''); mOptions.cmdLineArgs = mIniFile->value("CommandLine","").toString();
fFolders.CommaText := ReadString('Project', 'Folders', ''); mFolders = mIniFile->value("Folders","").toString().split(";");
fOptions.IncludeVersionInfo := ReadBool('Project', 'IncludeVersionInfo', False); mOptions.includeVersionInfo = mIniFile->value("IncludeVersionInfo", false).toBool();
fOptions.SupportXPThemes := ReadBool('Project', 'SupportXPThemes', False); mOptions.supportXPThemes = mIniFile->value("SupportXPThemes", false).toBool();
fOptions.CompilerSet := ReadInteger('Project', 'CompilerSet', devCompilerSets.DefaultSetIndex); mOptions.compilerSet = mIniFile->value("CompilerSet", pSettings->compilerSets().defaultIndex()).toInt();
if (fOptions.CompilerSet >= devCompilerSets.Count) or (fOptions.CompilerSet < 0) then begin // TODO: change from indices to names
MessageDlg(Lang[ID_MSG_COMPILERNOTFOUND], mtError, [mbOk], 0);
fOptions.CompilerSet := devCompilerSets.DefaultSetIndex;
Modified := True;
end;
fOptions.CompilerOptions := ReadString('Project', 'CompilerSettings', '');
fOptions.StaticLink := ReadBool('Project','StaticLink',True);
fOptions.AddCharset := ReadBool('Project','AddCharset',True);
fOptions.UseUTF8 := ReadBool('Project','UseUTF8',False);
fOptions.VersionInfo.Major := ReadInteger('VersionInfo', 'Major', 0);
fOptions.VersionInfo.Minor := ReadInteger('VersionInfo', 'Minor', 1);
fOptions.VersionInfo.Release := ReadInteger('VersionInfo', 'Release', 1);
fOptions.VersionInfo.Build := ReadInteger('VersionInfo', 'Build', 1);
fOptions.VersionInfo.LanguageID := ReadInteger('VersionInfo', 'LanguageID', $0409);
fOptions.VersionInfo.CharsetID := ReadInteger('VersionInfo', 'CharsetID', $04E4);
fOptions.VersionInfo.CompanyName := ReadString('VersionInfo', 'CompanyName', '');
fOptions.VersionInfo.FileVersion := ReadString('VersionInfo', 'FileVersion', '0.1');
fOptions.VersionInfo.FileDescription := ReadString('VersionInfo', 'FileDescription',
'Developed using the Dev-C++ IDE');
fOptions.VersionInfo.InternalName := ReadString('VersionInfo', 'InternalName', '');
fOptions.VersionInfo.LegalCopyright := ReadString('VersionInfo', 'LegalCopyright', '');
fOptions.VersionInfo.LegalTrademarks := ReadString('VersionInfo', 'LegalTrademarks', '');
fOptions.VersionInfo.OriginalFilename := ReadString('VersionInfo', 'OriginalFilename',
ExtractFilename(Executable));
fOptions.VersionInfo.ProductName := ReadString('VersionInfo', 'ProductName', Name);
fOptions.VersionInfo.ProductVersion := ReadString('VersionInfo', 'ProductVersion', '0.1.1.1');
fOptions.VersionInfo.AutoIncBuildNr := ReadBool('VersionInfo', 'AutoIncBuildNr', False);
fOptions.VersionInfo.SyncProduct := ReadBool('VersionInfo', 'SyncProduct', False);
end else begin // dev-c < 4
fOptions.Ver := -1;
if not ReadBool('Project', 'NoConsole', TRUE) then
fOptions.typ := dptCon
else if ReadBool('Project', 'IsDLL', FALSE) then
fOptions.Typ := dptDyn
else
fOptions.typ := dptGUI;
fOptions.PrivateResource := ReadString('Project', 'PrivateResource', ''); if (mOptions.compilerSet >= pSettings->compilerSets().size()
fOptions.ResourceIncludes.DelimitedText := ReadString('Project', 'ResourceIncludes', ''); || mOptions.compilerSet < 0) { // TODO: change from indices to names
fOptions.ObjFiles.Add(ReadString('Project', 'ObjFiles', '')); QMessageBox::critical(
fOptions.Includes.Add(ReadString('Project', 'IncludeDirs', '')); pMainWindow,
fOptions.CompilerCmd := ReadString('Project', 'CompilerOptions', ''); tr("Compiler not found"),
fOptions.usegpp := ReadBool('Project', 'Use_GPP', FALSE); tr("The compiler set you have selected for this project, no longer exists.")
fOptions.ExeOutput := ReadString('Project', 'ExeOutput', ''); +"<BR />"
fOptions.ObjectOutput := ReadString('Project', 'ObjectOutput', ''); +tr("It will be substituted by the global compiler set."),
fOptions.OverrideOutput := ReadBool('Project', 'OverrideOutput', FALSE); QMessageBox::Ok
fOptions.OverridenOutput := ReadString('Project', 'OverrideOutputName', ''); );
fOptions.HostApplication := ReadString('Project', 'HostApplication', ''); mOptions.compilerSet = pSettings->compilerSets().defaultIndex();
end; setModified(true);
end; }
mOptions.compilerOptions = mIniFile->value("CompilerSettings","").toString();
mOptions.staticLink = mIniFile->value("StaticLink", true).toBool();
mOptions.addCharset = mIniFile->value("AddCharset", true).toBool();
mOptions.useUTF8 = mIniFile->value("UseUTF8", false).toBool();
mOptions.versionInfo.major = mIniFile->value("Major", 0).toInt();
mOptions.versionInfo.minor = mIniFile->value("Minor", 1).toInt();
mOptions.versionInfo.release = mIniFile->value("Release", 1).toInt();
mOptions.versionInfo.build = mIniFile->value("Build", 1).toInt();
mOptions.versionInfo.languageID = mIniFile->value("LanguageID", 0x0409).toInt();
mOptions.versionInfo.charsetID = mIniFile->value("CharsetID", 0x04E4).toInt();
mOptions.versionInfo.companyName = mIniFile->value("CompanyName","").toString();
mOptions.versionInfo.fileVersion = mIniFile->value("FileVersion", "0.1").toString();
mOptions.versionInfo.fileDescription = mIniFile->value("FileDescription",
tr("Developed using the Red Panda Dev-C++ IDE")).toString();
mOptions.versionInfo.internalName = mIniFile->value("InternalName","").toString();
mOptions.versionInfo.legalCopyright = mIniFile->value("LegalCopyright","").toString();
mOptions.versionInfo.legalTrademarks = mIniFile->value("LegalTrademarks","").toString();
mOptions.versionInfo.originalFilename = mIniFile->value("OriginalFilename",
baseFileName(executable())).toString();
mOptions.versionInfo.productName = mIniFile->value("ProductName", mName).toString();
mOptions.versionInfo.productVersion = mIniFile->value("ProductVersion", "0.1.1.1").toString();
mOptions.versionInfo.autoIncBuildNr = mIniFile->value("AutoIncBuildNr", false).toBool();
mOptions.versionInfo.syncProduct = mIniFile->value("SyncProduct", false).toBool();
} else { // dev-c < 4
mOptions.version = -1;
if (!mIniFile->value("NoConsole", true).toBool())
mOptions.type = ProjectType::Console;
else if (mIniFile->value("IsDLL", false).toBool())
mOptions.type = ProjectType::DynamicLib;
else
mOptions.type = ProjectType::GUI;
mOptions.privateResource = mIniFile->value("PrivateResource","").toString();
mOptions.resourceIncludes = mIniFile->value("ResourceIncludes","").toString().split(";");
mOptions.objFiles = mIniFile->value("ObjFiles","").toString().split(";");
mOptions.includes = mIniFile->value("IncludeDirs","").toString().split(";");
mOptions.compilerCmd = mIniFile->value("CompilerOptions","").toString();
mOptions.useGPP = mIniFile->value("Use_GPP", false).toBool();
mOptions.exeOutput = mIniFile->value("ExeOutput","").toString();
mOptions.objectOutput = mIniFile->value("ObjectOutput","").toString();
mOptions.overrideOutput = mIniFile->value("OverrideOutput", false).toBool();
mOptions.overridenOutput = mIniFile->value("OverrideOutputName","").toString();
mOptions.hostApplication = mIniFile->value("HostApplication","").toString();
}
} }
PCppParser Project::cppParser() PCppParser Project::cppParser()

View File

@ -20,7 +20,7 @@ struct FolderNode;
using PFolderNode = std::shared_ptr<FolderNode>; using PFolderNode = std::shared_ptr<FolderNode>;
struct FolderNode { struct FolderNode {
QString text; QString text;
FolderNode * parent; std::weak_ptr<FolderNode> parent;
int unitIndex; int unitIndex;
QList<PFolderNode> children; QList<PFolderNode> children;
}; };
@ -105,7 +105,7 @@ struct ProjectOptions{
ProjectType type; ProjectType type;
int version; int version;
bool useUTF8; bool useUTF8;
QStringList objfiles; QStringList objFiles;
QString compilerCmd; QString compilerCmd;
QString cppCompilerCmd; QString cppCompilerCmd;
QString linkerCmd; QString linkerCmd;
@ -123,7 +123,7 @@ struct ProjectOptions{
bool useCustomMakefile; bool useCustomMakefile;
QString customMakefile; QString customMakefile;
bool usePrecompiledHeader; bool usePrecompiledHeader;
bool precompiledHeader; QString precompiledHeader;
bool overrideOutput; bool overrideOutput;
QString overridenOutput; QString overridenOutput;
QString hostApplication; QString hostApplication;
@ -148,6 +148,7 @@ public:
bool modified() const; bool modified() const;
void setFileName(const QString& value); void setFileName(const QString& value);
void setModified(bool value); void setModified(bool value);
PFolderNode makeNewFileNode(const QString& s, bool isFolder, PFolderNode newParent);
void addFolder(const QString& s); void addFolder(const QString& s);
PProjectUnit addUnit(const QString& inFileName, PProjectUnit addUnit(const QString& inFileName,
@ -179,7 +180,6 @@ public:
void saveLayout(); // save all [UnitX] void saveLayout(); // save all [UnitX]
void saveUnitLayout(Editor* e, int index); // save single [UnitX] cursor positions void saveUnitLayout(Editor* e, int index); // save single [UnitX] cursor positions
PFolderNode makeProjectNode(); PFolderNode makeProjectNode();
PFolderNode makeNewFileNode(const QString& s, bool isFolder, PFolderNode newParent);
void saveOptions(); void saveOptions();
bool saveUnits(); bool saveUnits();
// procedure Open; // procedure Open;