work save
This commit is contained in:
parent
feafadd760
commit
090a6d3e1e
|
@ -63,7 +63,7 @@ bool FileCompiler::prepareForCompile()
|
||||||
}
|
}
|
||||||
mArguments += getLibraryArguments(fileType);
|
mArguments += getLibraryArguments(fileType);
|
||||||
|
|
||||||
if (!QFile(mCompiler).exists()) {
|
if (!fileExists(mCompiler)) {
|
||||||
throw CompileError(tr("The Compiler '%1' doesn't exists!").arg(mCompiler));
|
throw CompileError(tr("The Compiler '%1' doesn't exists!").arg(mCompiler));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ bool StdinCompiler::prepareForCompile()
|
||||||
}
|
}
|
||||||
mArguments += getLibraryArguments(fileType);
|
mArguments += getLibraryArguments(fileType);
|
||||||
|
|
||||||
if (!QFile(mCompiler).exists()) {
|
if (!fileExists(mCompiler)) {
|
||||||
throw CompileError(tr("The Compiler '%1' doesn't exists!").arg(mCompiler));
|
throw CompileError(tr("The Compiler '%1' doesn't exists!").arg(mCompiler));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2100,7 +2100,7 @@ void Editor::cancelHint()
|
||||||
QString Editor::getFileHint(const QString &s)
|
QString Editor::getFileHint(const QString &s)
|
||||||
{
|
{
|
||||||
QString fileName = mParser->getHeaderFileName(mFilename, s);
|
QString fileName = mParser->getHeaderFileName(mFilename, s);
|
||||||
if (QFileInfo(fileName).exists()) {
|
if (fileExists(fileName)) {
|
||||||
return fileName + " - " + tr("Ctrl+click for more info");
|
return fileName + " - " + tr("Ctrl+click for more info");
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
|
|
@ -661,7 +661,7 @@ bool MainWindow::compile(bool rebuild)
|
||||||
void MainWindow::runExecutable(const QString &exeName,const QString &filename)
|
void MainWindow::runExecutable(const QString &exeName,const QString &filename)
|
||||||
{
|
{
|
||||||
// Check if it exists
|
// Check if it exists
|
||||||
if (!QFile(exeName).exists()) {
|
if (!fileExists(exeName)) {
|
||||||
if (ui->actionCompile_Run->isEnabled()) {
|
if (ui->actionCompile_Run->isEnabled()) {
|
||||||
if (QMessageBox::question(this,tr("Confirm"),
|
if (QMessageBox::question(this,tr("Confirm"),
|
||||||
tr("Source file is not compiled.")
|
tr("Source file is not compiled.")
|
||||||
|
@ -1417,7 +1417,7 @@ void MainWindow::onFileChanged(const QString &path)
|
||||||
{
|
{
|
||||||
Editor *e = mEditorList->getOpenedEditorByFilename(path);
|
Editor *e = mEditorList->getOpenedEditorByFilename(path);
|
||||||
if (e) {
|
if (e) {
|
||||||
if (QFile(path).exists()) {
|
if (fileExists(path)) {
|
||||||
e->activate();
|
e->activate();
|
||||||
if (QMessageBox::question(this,tr("Compile"),
|
if (QMessageBox::question(this,tr("Compile"),
|
||||||
tr("File '%1' was changed.").arg(path)+"<BR /><BR />" + tr("Reload its content from disk?"),
|
tr("File '%1' was changed.").arg(path)+"<BR /><BR />" + tr("Reload its content from disk?"),
|
||||||
|
|
|
@ -131,7 +131,6 @@ void Project::open()
|
||||||
}
|
}
|
||||||
mIniFile->endGroup();
|
mIniFile->endGroup();
|
||||||
}
|
}
|
||||||
emit changed();
|
|
||||||
rebuildNodes();
|
rebuildNodes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,8 +153,305 @@ void Project::setModified(bool value)
|
||||||
if (!file.exists()
|
if (!file.exists()
|
||||||
|| (file.exists() && file.isWritable())) {
|
|| (file.exists() && file.isWritable())) {
|
||||||
mModified=value;
|
mModified=value;
|
||||||
|
emit modifyChanged(mModified);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Project::addFolder(const QString &s)
|
||||||
|
{
|
||||||
|
if (mFolders.indexOf(s)<0) {
|
||||||
|
mFolders.append(s);
|
||||||
|
rebuildNodes();
|
||||||
|
//todo: MainForm.ProjectView.Select(FolderNodeFromName(s));
|
||||||
|
//folderNodeFromName(s)->makeVisible();
|
||||||
|
setModified(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PProjectUnit Project::addUnit(const QString &inFileName, PFolderNode parentNode, bool rebuild)
|
||||||
|
{
|
||||||
|
PProjectUnit newUnit;
|
||||||
|
// Don't add if it already exists
|
||||||
|
if (fileAlreadyExists(inFileName)) {
|
||||||
|
QMessageBox::critical(pMainWindow,
|
||||||
|
tr("File Exists"),
|
||||||
|
tr("File '%1' is already in the project"),
|
||||||
|
QMessageBox::Ok);
|
||||||
|
return newUnit;
|
||||||
|
}
|
||||||
|
newUnit = std::make_shared<ProjectUnit>(this);
|
||||||
|
|
||||||
|
// Set all properties
|
||||||
|
newUnit->setFileName(QDir(directory()).filePath(inFileName));
|
||||||
|
newUnit->setNew(false);
|
||||||
|
newUnit->setEditor(nullptr);
|
||||||
|
newUnit->setFolder(getFolderPath(parentNode));
|
||||||
|
newUnit->setNode(makeNewFileNode(baseFileName(newUnit->fileName()), false, parentNode);
|
||||||
|
newUnit->node()->unitIndex = mUnits.count();
|
||||||
|
mUnits.append(newUnit);
|
||||||
|
|
||||||
|
// Determine compilation flags
|
||||||
|
switch(getFileType(inFileName)) {
|
||||||
|
case FileType::CSource:
|
||||||
|
newUnit->setCompile(true);
|
||||||
|
newUnit->setCompileCpp(mOptions.useGPP);
|
||||||
|
newUnit->setLink(true);
|
||||||
|
break;
|
||||||
|
case FileType::CppSource:
|
||||||
|
newUnit->setCompile(true);
|
||||||
|
newUnit->setCompileCpp(true);
|
||||||
|
newUnit->setLink(true);
|
||||||
|
break;
|
||||||
|
case FileType::WindowsResourceSource:
|
||||||
|
newUnit->setCompile(true);
|
||||||
|
newUnit->setCompileCpp(mOptions.useGPP);
|
||||||
|
newUnit->setLink(false);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
newUnit->setCompile(false);
|
||||||
|
newUnit->setCompileCpp(false);
|
||||||
|
newUnit->setLink(false);
|
||||||
|
}
|
||||||
|
newUnit->setPriority(1000);
|
||||||
|
newUnit->setOverrideBuildCmd(false);
|
||||||
|
newUnit->setBuildCmd("");
|
||||||
|
if (rebuild)
|
||||||
|
rebuildNodes();
|
||||||
|
setModified(true);
|
||||||
|
return newUnit;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Project::buildPrivateResource(bool forceSave)
|
||||||
|
{
|
||||||
|
int comp = 0;
|
||||||
|
foreach (const PProjectUnit& unit,mUnits) {
|
||||||
|
if (
|
||||||
|
(getFileType(unit->fileName()) == FileType::WindowsResourceSource)
|
||||||
|
&& unit->compile() )
|
||||||
|
comp++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if project has no other resources included
|
||||||
|
// and does not have an icon
|
||||||
|
// and does not include the XP style manifest
|
||||||
|
// and does not include version info
|
||||||
|
// then do not create a private resource file
|
||||||
|
if ((comp == 0) &&
|
||||||
|
(! mOptions.supportXPThemes)
|
||||||
|
&& (! mOptions.includeVersionInfo)
|
||||||
|
&& (mOptions.icon == "")) {
|
||||||
|
mOptions.privateResource="";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// change private resource from <project_filename>.res
|
||||||
|
// to <project_filename>_private.res
|
||||||
|
//
|
||||||
|
// in many cases (like in importing a MSVC project)
|
||||||
|
// the project's resource file has already the
|
||||||
|
// <project_filename>.res filename.
|
||||||
|
QString res;
|
||||||
|
if (!mOptions.privateResource.isEmpty()) {
|
||||||
|
res = QDir(directory()).filePath(mOptions.privateResource);
|
||||||
|
if (changeFileExt(res, DEV_PROJECT_EXT) == mFilename)
|
||||||
|
res = changeFileExt(mFilename,QString("_private") + RC_EXT);
|
||||||
|
} else
|
||||||
|
res = changeFileExt(mFilename,QString("_private") + RC_EXT);
|
||||||
|
res = extractRelativePath(mFilename, res);
|
||||||
|
res.replace(' ','_');
|
||||||
|
|
||||||
|
// don't run the private resource file and header if not modified,
|
||||||
|
// unless ForceSave is true
|
||||||
|
if (!forceSave
|
||||||
|
&& fileExists(res)
|
||||||
|
&& fileExists(changeFileExt(res, H_EXT))
|
||||||
|
&& !mModified)
|
||||||
|
return;
|
||||||
|
|
||||||
|
QStringList resFile;
|
||||||
|
resFile.append("/* THIS FILE WILL BE OVERWRITTEN BY DEV-C++ */");
|
||||||
|
resFile.append("/* DO NOT EDIT! */");
|
||||||
|
resFile.append("");
|
||||||
|
|
||||||
|
if (mOptions.includeVersionInfo) {
|
||||||
|
resFile.append("#include <windows.h> // include for version info constants");
|
||||||
|
resFile.append("");
|
||||||
|
end;
|
||||||
|
|
||||||
|
foreach (const PProjectUnit& unit, mUnits) {
|
||||||
|
if (
|
||||||
|
(getFileType(unit->fileName()) == FileType::WindowsResourceSource)
|
||||||
|
&& unit->compile() )
|
||||||
|
resFile.append("#include \"" +
|
||||||
|
genMakePath(
|
||||||
|
extractRelativePath(directory(), unit->fileName()),
|
||||||
|
false,
|
||||||
|
false) + "\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mOptions.icon.isEmpty()) {
|
||||||
|
resFile.append("");
|
||||||
|
QString icon = QDir(directory()).absoluteFilePath(mOptions.icon);
|
||||||
|
if (fileExists(icon)) {
|
||||||
|
icon = extractRelativePath(mFilename, icon);
|
||||||
|
icon.replace('\\', '/');
|
||||||
|
resFile.append("A ICON \"" + icon + '"');
|
||||||
|
} else
|
||||||
|
mOptions.icon = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mOptions.supportXPThemes) {
|
||||||
|
resFile.append("");
|
||||||
|
resFile.append("//");
|
||||||
|
resFile.append("// SUPPORT FOR WINDOWS XP THEMES:");
|
||||||
|
resFile.append("// THIS WILL MAKE THE PROGRAM USE THE COMMON CONTROLS");
|
||||||
|
resFile.append("// LIBRARY VERSION 6.0 (IF IT IS AVAILABLE)");
|
||||||
|
resFile.append("//");
|
||||||
|
if (!mOptions.exeOutput.isEmpty())
|
||||||
|
resFile.append(
|
||||||
|
"1 24 \"" +
|
||||||
|
genMakePath2(
|
||||||
|
includeTrailingPathDelimiter(mOptions.exeOutput)
|
||||||
|
+ baseFileName(executable()))
|
||||||
|
+ ".Manifest\"");
|
||||||
|
else
|
||||||
|
resFile.append("1 24 \"" + baseFileName(executable()) + ".Manifest\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
if Options.IncludeVersionInfo then begin
|
||||||
|
resFile.append("');
|
||||||
|
resFile.append("//');
|
||||||
|
resFile.append("// TO CHANGE VERSION INFORMATION, EDIT PROJECT OPTIONS...');
|
||||||
|
resFile.append("//');
|
||||||
|
resFile.append("1 VERSIONINFO');
|
||||||
|
resFile.append("FILEVERSION ' + Format('%d,%d,%d,%d', [Options.VersionInfo.Major, Options.VersionInfo.Minor,
|
||||||
|
Options.VersionInfo.Release, Options.VersionInfo.Build]));
|
||||||
|
resFile.append("PRODUCTVERSION ' + Format('%d,%d,%d,%d', [Options.VersionInfo.Major, Options.VersionInfo.Minor,
|
||||||
|
Options.VersionInfo.Release, Options.VersionInfo.Build]));
|
||||||
|
case Options.typ of
|
||||||
|
dptGUI,
|
||||||
|
dptCon: resFile.append("FILETYPE VFT_APP');
|
||||||
|
dptStat: resFile.append("FILETYPE VFT_STATIC_LIB');
|
||||||
|
dptDyn: resFile.append("FILETYPE VFT_DLL');
|
||||||
|
end;
|
||||||
|
resFile.append("{');
|
||||||
|
resFile.append(" BLOCK "StringFileInfo"');
|
||||||
|
resFile.append(" {');
|
||||||
|
resFile.append(" BLOCK "' + Format('%4.4x%4.4x', [fOptions.VersionInfo.LanguageID, fOptions.VersionInfo.CharsetID])
|
||||||
|
+
|
||||||
|
'"');
|
||||||
|
resFile.append(" {');
|
||||||
|
resFile.append(" VALUE "CompanyName", "' + fOptions.VersionInfo.CompanyName + '"');
|
||||||
|
resFile.append(" VALUE "FileVersion", "' + fOptions.VersionInfo.FileVersion + '"');
|
||||||
|
resFile.append(" VALUE "FileDescription", "' + fOptions.VersionInfo.FileDescription + '"');
|
||||||
|
resFile.append(" VALUE "InternalName", "' + fOptions.VersionInfo.InternalName + '"');
|
||||||
|
resFile.append(" VALUE "LegalCopyright", "' + fOptions.VersionInfo.LegalCopyright + '"');
|
||||||
|
resFile.append(" VALUE "LegalTrademarks", "' + fOptions.VersionInfo.LegalTrademarks + '"');
|
||||||
|
resFile.append(" VALUE "OriginalFilename", "' + fOptions.VersionInfo.OriginalFilename + '"');
|
||||||
|
resFile.append(" VALUE "ProductName", "' + fOptions.VersionInfo.ProductName + '"');
|
||||||
|
resFile.append(" VALUE "ProductVersion", "' + fOptions.VersionInfo.ProductVersion + '"');
|
||||||
|
resFile.append(" }');
|
||||||
|
resFile.append(" }');
|
||||||
|
|
||||||
|
// additional block for windows 95->NT
|
||||||
|
resFile.append(" BLOCK "VarFileInfo"');
|
||||||
|
resFile.append(" {');
|
||||||
|
resFile.append(" VALUE "Translation", ' + Format('0x%4.4x, %4.4d', [fOptions.VersionInfo.LanguageID,
|
||||||
|
fOptions.VersionInfo.CharsetID]));
|
||||||
|
resFile.append(" }');
|
||||||
|
|
||||||
|
resFile.append("}');
|
||||||
|
end;
|
||||||
|
|
||||||
|
Res := GetRealPath(Res, Directory);
|
||||||
|
if resFile.Count > 3 then begin
|
||||||
|
if FileExists(Res) and not ForceSave then begin
|
||||||
|
Original := TStringList.Create;
|
||||||
|
Original.LoadFromFile(Res);
|
||||||
|
if CompareStr(Original.Text, resFile.Text) <> 0 then begin
|
||||||
|
resFile.SaveToFile(Res);
|
||||||
|
end;
|
||||||
|
Original.Free;
|
||||||
|
end else begin
|
||||||
|
resFile.SaveToFile(Res);
|
||||||
|
end;
|
||||||
|
fOptions.PrivateResource := ExtractRelativePath(Directory, Res);
|
||||||
|
end else begin
|
||||||
|
if FileExists(Res) then
|
||||||
|
DeleteFile(PAnsiChar(Res));
|
||||||
|
Res := ChangeFileExt(Res, RES_EXT);
|
||||||
|
if FileExists(Res) then
|
||||||
|
DeleteFile(PAnsiChar(Res));
|
||||||
|
fOptions.PrivateResource := '';
|
||||||
|
end;
|
||||||
|
if FileExists(Res) then
|
||||||
|
FileSetDate(Res, DateTimeToFileDate(Now)); // fix the "Clock skew detected" warning ;)
|
||||||
|
|
||||||
|
// create XP manifest
|
||||||
|
if fOptions.SupportXPThemes then begin
|
||||||
|
resFile.Clear;
|
||||||
|
resFile.append("<?xml version="1.0" encoding="UTF-8" standalone="yes"?>');
|
||||||
|
resFile.append("<assembly');
|
||||||
|
resFile.append(" xmlns="urn:schemas-microsoft-com:asm.v1"');
|
||||||
|
resFile.append(" manifestVersion="1.0">');
|
||||||
|
resFile.append("<assemblyIdentity');
|
||||||
|
resFile.append(" name="DevCpp.Apps.' + StringReplace(Name, ' ', '_', [rfReplaceAll]) + '"');
|
||||||
|
resFile.append(" processorArchitecture="*"');
|
||||||
|
resFile.append(" version="1.0.0.0"');
|
||||||
|
resFile.append(" type="win32"/>');
|
||||||
|
resFile.append("<description>' + Name + '</description>');
|
||||||
|
resFile.append("<dependency>');
|
||||||
|
resFile.append(" <dependentAssembly>');
|
||||||
|
resFile.append(" <assemblyIdentity');
|
||||||
|
resFile.append(" type="win32"');
|
||||||
|
resFile.append(" name="Microsoft.Windows.Common-Controls"');
|
||||||
|
resFile.append(" version="6.0.0.0"');
|
||||||
|
resFile.append(" processorArchitecture="*"');
|
||||||
|
resFile.append(" publicKeyToken="6595b64144ccf1df"');
|
||||||
|
resFile.append(" language="*"');
|
||||||
|
resFile.append(" />');
|
||||||
|
resFile.append(" </dependentAssembly>');
|
||||||
|
resFile.append("</dependency>');
|
||||||
|
resFile.append("</assembly>');
|
||||||
|
resFile.SaveToFile(Executable + '.Manifest');
|
||||||
|
FileSetDate(Executable + '.Manifest', DateTimeToFileDate(Now)); // fix the "Clock skew detected" warning ;)
|
||||||
|
end else if FileExists(Executable + '.Manifest') then
|
||||||
|
DeleteFile(PAnsiChar(Executable + '.Manifest'));
|
||||||
|
|
||||||
|
// create private header file
|
||||||
|
Res := ChangeFileExt(Res, H_EXT);
|
||||||
|
resFile.Clear;
|
||||||
|
Def := StringReplace(ExtractFilename(UpperCase(Res)), '.', '_', [rfReplaceAll]);
|
||||||
|
resFile.append("/* THIS FILE WILL BE OVERWRITTEN BY DEV-C++ */');
|
||||||
|
resFile.append("/* DO NOT EDIT ! */');
|
||||||
|
resFile.append("');
|
||||||
|
resFile.append("#ifndef ' + Def);
|
||||||
|
resFile.append("#define ' + Def);
|
||||||
|
resFile.append("');
|
||||||
|
resFile.append("/* VERSION DEFINITIONS */');
|
||||||
|
resFile.append("#define VER_STRING'#9 + Format('"%d.%d.%d.%d"', [fOptions.VersionInfo.Major, fOptions.VersionInfo.Minor,
|
||||||
|
fOptions.VersionInfo.Release, fOptions.VersionInfo.Build]));
|
||||||
|
resFile.append("#define VER_MAJOR'#9 + IntToStr(fOptions.VersionInfo.Major));
|
||||||
|
resFile.append("#define VER_MINOR'#9 + IntToStr(fOptions.VersionInfo.Minor));
|
||||||
|
resFile.append("#define VER_RELEASE'#9 + IntToStr(fOptions.VersionInfo.Release));
|
||||||
|
resFile.append("#define VER_BUILD'#9 + IntToStr(fOptions.VersionInfo.Build));
|
||||||
|
resFile.append("#define COMPANY_NAME'#9'"' + fOptions.VersionInfo.CompanyName + '"');
|
||||||
|
resFile.append("#define FILE_VERSION'#9'"' + fOptions.VersionInfo.FileVersion + '"');
|
||||||
|
resFile.append("#define FILE_DESCRIPTION'#9'"' + fOptions.VersionInfo.FileDescription + '"');
|
||||||
|
resFile.append("#define INTERNAL_NAME'#9'"' + fOptions.VersionInfo.InternalName + '"');
|
||||||
|
resFile.append("#define LEGAL_COPYRIGHT'#9'"' + fOptions.VersionInfo.LegalCopyright + '"');
|
||||||
|
resFile.append("#define LEGAL_TRADEMARKS'#9'"' + fOptions.VersionInfo.LegalTrademarks + '"');
|
||||||
|
resFile.append("#define ORIGINAL_FILENAME'#9'"' + fOptions.VersionInfo.OriginalFilename + '"');
|
||||||
|
resFile.append("#define PRODUCT_NAME'#9'"' + fOptions.VersionInfo.ProductName + '"');
|
||||||
|
resFile.append("#define PRODUCT_VERSION'#9'"' + fOptions.VersionInfo.ProductVersion + '"');
|
||||||
|
resFile.append("');
|
||||||
|
resFile.append("#endif /*' + Def + '*/');
|
||||||
|
resFile.SaveToFile(Res);
|
||||||
|
|
||||||
|
if FileExists(Res) then
|
||||||
|
FileSetDate(Res, DateTimeToFileDate(Now)); // fix the "Clock skew detected" warning ;)
|
||||||
|
|
||||||
|
resFile.Free;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Project::sortUnitsByPriority()
|
void Project::sortUnitsByPriority()
|
||||||
|
@ -320,7 +616,7 @@ void ProjectUnit::setModified(bool value)
|
||||||
|
|
||||||
// If modified is set to true, mark project as modified too
|
// If modified is set to true, mark project as modified too
|
||||||
if (value) {
|
if (value) {
|
||||||
parent->setModified(true);
|
mParent->setModified(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -331,7 +627,7 @@ bool ProjectUnit::save()
|
||||||
pMainWindow->fileSystemWatcher()->blockSignals(previous);
|
pMainWindow->fileSystemWatcher()->blockSignals(previous);
|
||||||
});
|
});
|
||||||
bool result=true;
|
bool result=true;
|
||||||
if (!mEditor && !QFile(mFileName).exists()) {
|
if (!mEditor && !fileExists(mFileName)) {
|
||||||
// file is neither open, nor saved
|
// file is neither open, nor saved
|
||||||
QStringList temp;
|
QStringList temp;
|
||||||
StringsToFile(temp,mFileName);
|
StringsToFile(temp,mFileName);
|
||||||
|
@ -343,3 +639,13 @@ bool ProjectUnit::save()
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PFolderNode &ProjectUnit::node()
|
||||||
|
{
|
||||||
|
return mNode;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectUnit::setNode(const PFolderNode &newNode)
|
||||||
|
{
|
||||||
|
mNode = newNode;
|
||||||
|
}
|
||||||
|
|
|
@ -59,6 +59,9 @@ public:
|
||||||
void setModified(bool value);
|
void setModified(bool value);
|
||||||
bool save();
|
bool save();
|
||||||
|
|
||||||
|
PFolderNode &node();
|
||||||
|
void setNode(const PFolderNode &newNode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Project* mParent;
|
Project* mParent;
|
||||||
Editor* mEditor;
|
Editor* mEditor;
|
||||||
|
@ -140,57 +143,59 @@ class Project : public QObject
|
||||||
public:
|
public:
|
||||||
explicit Project(QObject *parent = nullptr);
|
explicit Project(QObject *parent = nullptr);
|
||||||
QString directory();
|
QString directory();
|
||||||
QString executableName();
|
QString executable();
|
||||||
QString makeFileName();
|
QString makeFileName();
|
||||||
bool modified();
|
bool modified();
|
||||||
void setFileName(const QString& value);
|
void setFileName(const QString& value);
|
||||||
void setModified(bool value);
|
void setModified(bool value);
|
||||||
|
|
||||||
int newUnit(bool newProject,
|
void addFolder(const QString& s);
|
||||||
PFolderNode parentNode,
|
|
||||||
const QString customFileName);
|
|
||||||
PProjectUnit addUnit(const QString& inFileName,
|
PProjectUnit addUnit(const QString& inFileName,
|
||||||
PFolderNode parentNode,
|
PFolderNode parentNode,
|
||||||
bool rebuild);
|
bool rebuild);
|
||||||
function GetFolderPath(Node: TTreeNode): AnsiString;
|
void buildPrivateResource(bool forceSave);
|
||||||
procedure UpdateFolders;
|
|
||||||
procedure AddFolder(const s: AnsiString);
|
int newUnit(bool newProject,
|
||||||
function OpenUnit(index: integer): TEditor;
|
PFolderNode parentNode,
|
||||||
procedure CloseUnit(index: integer);
|
const QString customFileName);
|
||||||
procedure DoAutoOpen;
|
QString getFolderPath(PFolderNode node);
|
||||||
procedure SaveUnitAs(i: integer; sFileName: AnsiString); // save single [UnitX]
|
void updateFolders();
|
||||||
procedure SaveAll; // save [Project] and all [UnitX]
|
Editor* openUnit(int index);
|
||||||
procedure LoadLayout; // load all [UnitX]
|
void closeUnit(int index);
|
||||||
procedure LoadUnitLayout(e: TEditor; Index: integer); // load single [UnitX] cursor positions
|
void doAutoOpen();
|
||||||
procedure SaveLayout; // save all [UnitX]
|
void saveUnitAs(int i, const QString& sFileName); // save single [UnitX]
|
||||||
procedure SaveUnitLayout(e: TEditor; Index: integer); // save single [UnitX] cursor positions
|
void saveAll(); // save [Project] and all [UnitX]
|
||||||
function MakeProjectNode: TTreeNode;
|
void loadLayout(); // load all [UnitX]
|
||||||
function MakeNewFileNode(const s: AnsiString; IsFolder: boolean; NewParent: TTreeNode): TTreeNode;
|
void loadUnitLayout(Editor *e, int index); // load single [UnitX] cursor positions
|
||||||
procedure BuildPrivateResource(ForceSave: boolean = False);
|
void saveLayout(); // save all [UnitX]
|
||||||
procedure LoadOptions;
|
void saveUnitLayout(Editor* e, int index); // save single [UnitX] cursor positions
|
||||||
procedure SaveOptions;
|
PFolderNode makeProjectNode();
|
||||||
function SaveUnits: Boolean;
|
PFolderNode makeNewFileNode(const QString& s, bool isFolder, PFolderNode newParent);
|
||||||
|
void loadOptions();
|
||||||
|
void saveOptions();
|
||||||
|
bool saveUnits();
|
||||||
// procedure Open;
|
// procedure Open;
|
||||||
function FileAlreadyExists(const s: AnsiString): boolean;
|
bool fileAlreadyExists(const QString& s);
|
||||||
function RemoveFolder(Node: TTreeNode): boolean;
|
bool removeFolder(PFolderNode node);
|
||||||
function RemoveEditor(index: integer; DoClose: boolean): boolean;
|
bool removeEditor(int index, bool doClose);
|
||||||
function GetUnitFromString(const s: AnsiString): integer;
|
int getUnitFromString(const QString& s);
|
||||||
procedure RebuildNodes;
|
void rebuildNodes();
|
||||||
function ListUnitStr(Separator: char): AnsiString;
|
QString listUnitStr(const QChar& separator);
|
||||||
procedure ExportToHTML;
|
void exportToHTML();
|
||||||
function ShowOptions: Integer;
|
void showOptions();
|
||||||
function AssignTemplate(const aFileName: AnsiString; aTemplate: TTemplate): boolean;
|
// bool assignTemplate(const QString& aFileName, const PTemplate& aTemplate);
|
||||||
function FolderNodeFromName(const name: AnsiString): TTreeNode;
|
PFolderNode folderNodeFromName(const QString& name);
|
||||||
procedure CreateFolderNodes;
|
void createFolderNodes();
|
||||||
procedure UpdateNodeIndexes;
|
void updateNodeIndexes();
|
||||||
procedure SetNodeValue(value: TTreeNode);
|
void setNodeValue(PFolderNode value);
|
||||||
procedure CheckProjectFileForUpdate;
|
void checkProjectFileForUpdate();
|
||||||
procedure IncrementBuildNumber;
|
void incrementBuildNumber();
|
||||||
function GetCompilerOption(const OptionString: AnsiString): Char;
|
QChar getCompilerOption(const QString& optionString);
|
||||||
procedure SetCompilerOption(const OptionString: AnsiString; Value: Char);
|
void setCompilerOption(const QString& optionString, const QChar& value);
|
||||||
procedure SaveToLog;
|
void saveToLog();
|
||||||
signals:
|
signals:
|
||||||
void changed();
|
void nodesChanged();
|
||||||
|
void modifyChanged(bool value);
|
||||||
private:
|
private:
|
||||||
void open();
|
void open();
|
||||||
void sortUnitsByPriority();
|
void sortUnitsByPriority();
|
||||||
|
|
|
@ -1339,22 +1339,22 @@ bool Settings::CompilerSet::dirsValid(QString &msg)
|
||||||
bool Settings::CompilerSet::validateExes(QString &msg)
|
bool Settings::CompilerSet::validateExes(QString &msg)
|
||||||
{
|
{
|
||||||
msg ="";
|
msg ="";
|
||||||
if (!QFile(mCCompiler).exists()) {
|
if (!fileExists(mCCompiler)) {
|
||||||
msg += QObject::tr("Cannot find the %1 \"%2\"")
|
msg += QObject::tr("Cannot find the %1 \"%2\"")
|
||||||
.arg("C Compiler")
|
.arg("C Compiler")
|
||||||
.arg(mCCompiler);
|
.arg(mCCompiler);
|
||||||
}
|
}
|
||||||
if (!QFile(mCppCompiler).exists()) {
|
if (!fileExists(mCppCompiler)) {
|
||||||
msg += QObject::tr("Cannot find the %1 \"%2\"")
|
msg += QObject::tr("Cannot find the %1 \"%2\"")
|
||||||
.arg("C++ Compiler")
|
.arg("C++ Compiler")
|
||||||
.arg(mCppCompiler);
|
.arg(mCppCompiler);
|
||||||
}
|
}
|
||||||
if (!QFile(mMake).exists()) {
|
if (!fileExists(mMake)) {
|
||||||
msg += QObject::tr("Cannot find the %1 \"%2\"")
|
msg += QObject::tr("Cannot find the %1 \"%2\"")
|
||||||
.arg("Maker")
|
.arg("Maker")
|
||||||
.arg(mMake);
|
.arg(mMake);
|
||||||
}
|
}
|
||||||
if (!QFile(mDebugger).exists()) {
|
if (!fileExists(mDebugger)) {
|
||||||
msg += QObject::tr("Cannot find the %1 \"%2\"")
|
msg += QObject::tr("Cannot find the %1 \"%2\"")
|
||||||
.arg("Maker")
|
.arg("Maker")
|
||||||
.arg(mDebugger);
|
.arg(mDebugger);
|
||||||
|
|
|
@ -18,6 +18,10 @@
|
||||||
#error "Only support windows now!"
|
#error "Only support windows now!"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define DEV_PROJECT_EXT "dev"
|
||||||
|
#define RC_EXT "rc"
|
||||||
|
#define H_EXT "h"
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
# define PATH_SENSITIVITY Qt::CaseInsensitive
|
# define PATH_SENSITIVITY Qt::CaseInsensitive
|
||||||
# define NULL_FILE "NUL"
|
# define NULL_FILE "NUL"
|
||||||
|
|
|
@ -126,7 +126,7 @@ bool isNonPrintableAsciiChar(char ch)
|
||||||
|
|
||||||
bool fileExists(const QString &file)
|
bool fileExists(const QString &file)
|
||||||
{
|
{
|
||||||
return QFileInfo(file).exists();
|
return fileExists(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool fileExists(const QString &dir, const QString &fileName)
|
bool fileExists(const QString &dir, const QString &fileName)
|
||||||
|
@ -461,7 +461,7 @@ QString changeFileExt(const QString& filename, const QString& ext)
|
||||||
if (suffix.isEmpty()) {
|
if (suffix.isEmpty()) {
|
||||||
return filename+"."+ext;
|
return filename+"."+ext;
|
||||||
} else {
|
} else {
|
||||||
return filename.mid(0,filename.length()-suffix.length()-1)+"."+ext;
|
return fileInfo.completeBaseName()+"."+ext;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -621,3 +621,29 @@ QString baseFileName(const QString &fileName)
|
||||||
QFileInfo fileInfo(fileName);
|
QFileInfo fileInfo(fileName);
|
||||||
return fileInfo.fileName();
|
return fileInfo.fileName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString extractRelativePath(const QString &base, const QString &dest)
|
||||||
|
{
|
||||||
|
QFileInfo baseInfo(base);
|
||||||
|
QDir baseDir;
|
||||||
|
if (baseInfo.isDir()) {
|
||||||
|
baseDir = baseInfo.absoluteDir();
|
||||||
|
} else {
|
||||||
|
baseDir = baseInfo.dir();
|
||||||
|
}
|
||||||
|
return baseDir.relativeFilePath(dest);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString genMakePath(const QString &fileName, bool escapeSpaces, bool encloseInQuotes)
|
||||||
|
{
|
||||||
|
QString result = fileName;
|
||||||
|
|
||||||
|
// Convert backslashes to slashes
|
||||||
|
result.replace('\\','/');
|
||||||
|
if (escapeSpaces) {
|
||||||
|
result.replace(' ',"\\ ");
|
||||||
|
}
|
||||||
|
if (encloseInQuotes)
|
||||||
|
result = '"'+result+'"';
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
|
@ -124,6 +124,8 @@ QString includeTrailingPathDelimiter(const QString& path);
|
||||||
QString excludeTrailingPathDelimiter(const QString& path);
|
QString excludeTrailingPathDelimiter(const QString& path);
|
||||||
FileType getFileType(const QString& filename);
|
FileType getFileType(const QString& filename);
|
||||||
QString changeFileExt(const QString& filename, const QString& ext);
|
QString changeFileExt(const QString& filename, const QString& ext);
|
||||||
|
QString extractRelativePath(const QString& base, const QString& dest);
|
||||||
|
QString genMakePath(const QString& fileName,bool escapeSpaces, bool encloseInQuotes);
|
||||||
QString getCompiledExecutableName(const QString& filename);
|
QString getCompiledExecutableName(const QString& filename);
|
||||||
void splitStringArguments(const QString& arguments, QStringList& argumentList);
|
void splitStringArguments(const QString& arguments, QStringList& argumentList);
|
||||||
bool programHasConsole(const QString& filename);
|
bool programHasConsole(const QString& filename);
|
||||||
|
|
Loading…
Reference in New Issue