- fix: add unit to project not correctly set new unit file's encoding

- fix: correctly set encoding for the new added project unit file
 - fix: if there's a project openned, new file should ask user if he want to add the new file to the project
 - fix: when adding a file openned in the editor to the project, properties of it are not correctly setted.
 - enhancement: when remove a file from the project, also ask if user want to remove it from disk
 - fix: double click a project's .dev file in the Files panel should load the project
This commit is contained in:
royqh1979@gmail.com 2021-11-15 22:08:35 +08:00
parent 0f130291aa
commit 284a8ed695
8 changed files with 209 additions and 152 deletions

View File

@ -1,6 +1,11 @@
Version 0.8.10 For Dev-C++ 7 Beta
- fix: Shouldn't update auto link settings, if the header name to be modified is unchanged
- fix: add unit to project not correctly set new unit file's encoding
- fix: correctly set encoding for the new added project unit file
- fix: if there's a project openned, new file should ask user if he want to add the new file to the project
- fix: when adding a file openned in the editor to the project, properties of it are not correctly setted.
- enhancement: when remove a file from the project, also ask if user want to remove it from disk
- fix: double click a project's .dev file in the Files panel should load the project
Version 0.8.9 For Dev-C++ 7 Beta
- fix: text color of labels in statusbar not correctly updated when change theme

Binary file not shown.

View File

@ -82,12 +82,12 @@
<translation></translation>
</message>
<message>
<location filename="settingsdialog/compilerautolinkwidget.cpp" line="115"/>
<location filename="settingsdialog/compilerautolinkwidget.cpp" line="117"/>
<source>Header exists</source>
<translation></translation>
</message>
<message>
<location filename="settingsdialog/compilerautolinkwidget.cpp" line="116"/>
<location filename="settingsdialog/compilerautolinkwidget.cpp" line="118"/>
<source>Header already exists.</source>
<translation></translation>
</message>
@ -2857,11 +2857,11 @@ Are you really want to continue?</source>
<message>
<location filename="mainwindow.ui" line="524"/>
<location filename="mainwindow.ui" line="2555"/>
<location filename="mainwindow.cpp" line="3512"/>
<location filename="mainwindow.cpp" line="3515"/>
<location filename="mainwindow.cpp" line="3519"/>
<location filename="mainwindow.cpp" line="3522"/>
<location filename="mainwindow.cpp" line="5099"/>
<location filename="mainwindow.cpp" line="3521"/>
<location filename="mainwindow.cpp" line="3524"/>
<location filename="mainwindow.cpp" line="3528"/>
<location filename="mainwindow.cpp" line="3531"/>
<location filename="mainwindow.cpp" line="5119"/>
<source>Issues</source>
<translation></translation>
</message>
@ -3269,7 +3269,7 @@ Are you really want to continue?</source>
<message>
<location filename="mainwindow.ui" line="323"/>
<location filename="mainwindow.ui" line="326"/>
<location filename="mainwindow.cpp" line="5417"/>
<location filename="mainwindow.cpp" line="5438"/>
<source>New Problem Set</source>
<translation></translation>
</message>
@ -3288,14 +3288,14 @@ Are you really want to continue?</source>
<message>
<location filename="mainwindow.ui" line="365"/>
<location filename="mainwindow.ui" line="368"/>
<location filename="mainwindow.cpp" line="5460"/>
<location filename="mainwindow.cpp" line="5481"/>
<source>Save Problem Set</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.ui" line="379"/>
<location filename="mainwindow.ui" line="382"/>
<location filename="mainwindow.cpp" line="5480"/>
<location filename="mainwindow.cpp" line="5501"/>
<source>Load Problem Set</source>
<translation></translation>
</message>
@ -3630,7 +3630,7 @@ Are you really want to continue?</source>
</message>
<message>
<location filename="mainwindow.ui" line="2239"/>
<location filename="mainwindow.cpp" line="4391"/>
<location filename="mainwindow.cpp" line="4400"/>
<source>Clear all breakpoints</source>
<translation></translation>
</message>
@ -3731,7 +3731,7 @@ Are you really want to continue?</source>
</message>
<message>
<location filename="mainwindow.ui" line="2390"/>
<location filename="mainwindow.cpp" line="5056"/>
<location filename="mainwindow.cpp" line="5076"/>
<source>Rename Symbol</source>
<translation></translation>
</message>
@ -3752,13 +3752,13 @@ Are you really want to continue?</source>
</message>
<message>
<location filename="mainwindow.ui" line="2410"/>
<location filename="mainwindow.cpp" line="5236"/>
<location filename="mainwindow.cpp" line="5256"/>
<source>Export As RTF</source>
<translation>RTF</translation>
</message>
<message>
<location filename="mainwindow.ui" line="2415"/>
<location filename="mainwindow.cpp" line="5258"/>
<location filename="mainwindow.cpp" line="5278"/>
<source>Export As HTML</source>
<translation>HTML</translation>
</message>
@ -3824,7 +3824,7 @@ Are you really want to continue?</source>
</message>
<message>
<location filename="mainwindow.ui" line="2477"/>
<location filename="mainwindow.cpp" line="5396"/>
<location filename="mainwindow.cpp" line="5417"/>
<source>Open Folder</source>
<translation></translation>
</message>
@ -4055,7 +4055,7 @@ Are you really want to continue?</source>
</message>
<message>
<location filename="mainwindow.cpp" line="222"/>
<location filename="mainwindow.cpp" line="5426"/>
<location filename="mainwindow.cpp" line="5447"/>
<source>Problem Set %1</source>
<translation>%1</translation>
</message>
@ -4122,15 +4122,15 @@ Are you really want to continue?</source>
</message>
<message>
<location filename="mainwindow.cpp" line="1894"/>
<location filename="mainwindow.cpp" line="5316"/>
<location filename="mainwindow.cpp" line="5356"/>
<location filename="mainwindow.cpp" line="5336"/>
<location filename="mainwindow.cpp" line="5376"/>
<source>Bookmark Description</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="1895"/>
<location filename="mainwindow.cpp" line="5317"/>
<location filename="mainwindow.cpp" line="5357"/>
<location filename="mainwindow.cpp" line="5337"/>
<location filename="mainwindow.cpp" line="5377"/>
<source>Description:</source>
<translation></translation>
</message>
@ -4294,183 +4294,203 @@ Are you really want to continue?</source>
</message>
<message>
<location filename="mainwindow.cpp" line="3069"/>
<location filename="mainwindow.cpp" line="5420"/>
<location filename="mainwindow.cpp" line="5441"/>
<source>Do you want to save it?</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="3284"/>
<location filename="mainwindow.cpp" line="3294"/>
<location filename="mainwindow.cpp" line="3306"/>
<location filename="mainwindow.cpp" line="5469"/>
<location filename="mainwindow.cpp" line="3216"/>
<source>New Project File?</source>
<translation>?</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="3217"/>
<source>Do you want to add the new file to the project?</source>
<translation>?</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="3293"/>
<location filename="mainwindow.cpp" line="3303"/>
<location filename="mainwindow.cpp" line="3315"/>
<location filename="mainwindow.cpp" line="5490"/>
<source>Save Error</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="3445"/>
<location filename="mainwindow.cpp" line="3454"/>
<source>Change Project Compiler Set</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="3446"/>
<location filename="mainwindow.cpp" line="3455"/>
<source>Change the project&apos;s compiler set will lose all custom compiler set options.</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="3448"/>
<location filename="mainwindow.cpp" line="3457"/>
<source>Do you really want to do that?</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4392"/>
<location filename="mainwindow.cpp" line="4401"/>
<source>Do you really want to clear all breakpoints in this file?</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4571"/>
<location filename="mainwindow.cpp" line="4580"/>
<source>New project</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4572"/>
<location filename="mainwindow.cpp" line="4581"/>
<source>Close %1 and start new project?</source>
<translation>&apos;%1&apos;?</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4584"/>
<location filename="mainwindow.cpp" line="4593"/>
<source>Folder not exist</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4585"/>
<location filename="mainwindow.cpp" line="4594"/>
<source>Folder &apos;%1&apos; doesn&apos;t exist. Create it now?</source>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4592"/>
<location filename="mainwindow.cpp" line="4601"/>
<source>Can&apos;t create folder</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4593"/>
<location filename="mainwindow.cpp" line="4602"/>
<source>Failed to create folder &apos;%1&apos;.</source>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4608"/>
<location filename="mainwindow.cpp" line="4617"/>
<source>Save new project as</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4610"/>
<location filename="mainwindow.cpp" line="4619"/>
<source>Red panda Dev-C++ project file (*.dev)</source>
<translation>Dev-C++ (*.dev)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4621"/>
<location filename="mainwindow.cpp" line="4630"/>
<source>New project fail</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4622"/>
<location filename="mainwindow.cpp" line="4631"/>
<source>Can&apos;t assign project template</source>
<translation>使</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4667"/>
<location filename="mainwindow.cpp" line="4716"/>
<source>Remove file</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4717"/>
<source>Remove the file from disk?</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4944"/>
<source>untitled</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4677"/>
<location filename="mainwindow.cpp" line="4954"/>
<source>New Project File Name</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4678"/>
<location filename="mainwindow.cpp" line="4955"/>
<source>File Name:</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4684"/>
<location filename="mainwindow.cpp" line="4961"/>
<source>File Already Exists!</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4685"/>
<location filename="mainwindow.cpp" line="4962"/>
<source>File &apos;%1&apos; already exists!</source>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4704"/>
<location filename="mainwindow.cpp" line="4674"/>
<source>Add to project</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="5042"/>
<location filename="mainwindow.cpp" line="5062"/>
<source>Rename Error</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="5043"/>
<location filename="mainwindow.cpp" line="5063"/>
<source>Symbol &apos;%1&apos; is defined in system header.</source>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="5057"/>
<location filename="mainwindow.cpp" line="5077"/>
<source>New Name</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="5181"/>
<location filename="mainwindow.cpp" line="5191"/>
<location filename="mainwindow.cpp" line="5201"/>
<location filename="mainwindow.cpp" line="5211"/>
<source>Replace Error</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="5182"/>
<location filename="mainwindow.cpp" line="5202"/>
<source>Can&apos;t open file &apos;%1&apos; for replace!</source>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="5192"/>
<location filename="mainwindow.cpp" line="5212"/>
<source>Contents has changed since last search!</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="5238"/>
<location filename="mainwindow.cpp" line="5258"/>
<source>Rich Text Format Files (*.rtf)</source>
<translation>RTF格式文件 (*.rtf)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="5260"/>
<location filename="mainwindow.cpp" line="5280"/>
<source>HTML Files (*.html)</source>
<translation>HTML文件 (*.html)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="5418"/>
<location filename="mainwindow.cpp" line="5439"/>
<source>The current problem set is not empty.</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="5436"/>
<location filename="mainwindow.cpp" line="5457"/>
<source>Problem %1</source>
<translation>%1</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="5462"/>
<location filename="mainwindow.cpp" line="5482"/>
<location filename="mainwindow.cpp" line="5483"/>
<location filename="mainwindow.cpp" line="5503"/>
<source>Problem Set Files (*.pbs)</source>
<translation> (*.pbs)</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="5488"/>
<location filename="mainwindow.cpp" line="5509"/>
<source>Load Error</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="2817"/>
<location filename="mainwindow.cpp" line="5502"/>
<location filename="mainwindow.cpp" line="5523"/>
<source>Problem Case %1</source>
<translation>%1</translation>
</message>
@ -4485,11 +4505,11 @@ Are you really want to continue?</source>
<location filename="mainwindow.cpp" line="1793"/>
<location filename="mainwindow.cpp" line="2369"/>
<location filename="mainwindow.cpp" line="3153"/>
<location filename="mainwindow.cpp" line="3242"/>
<location filename="mainwindow.cpp" line="3414"/>
<location filename="mainwindow.cpp" line="3426"/>
<location filename="mainwindow.cpp" line="3816"/>
<location filename="mainwindow.cpp" line="3828"/>
<location filename="mainwindow.cpp" line="3251"/>
<location filename="mainwindow.cpp" line="3423"/>
<location filename="mainwindow.cpp" line="3435"/>
<location filename="mainwindow.cpp" line="3825"/>
<location filename="mainwindow.cpp" line="3837"/>
<source>Error</source>
<translation></translation>
</message>
@ -4519,55 +4539,55 @@ Are you really want to continue?</source>
<translation>C++</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="3235"/>
<location filename="mainwindow.cpp" line="3244"/>
<source>Open</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="3605"/>
<location filename="mainwindow.cpp" line="3614"/>
<source>Compile Failed</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="3611"/>
<location filename="mainwindow.cpp" line="3620"/>
<source>Run Failed</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="3845"/>
<location filename="mainwindow.cpp" line="3859"/>
<location filename="mainwindow.cpp" line="3854"/>
<location filename="mainwindow.cpp" line="3868"/>
<source>Confirm Convertion</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="3846"/>
<location filename="mainwindow.cpp" line="3860"/>
<location filename="mainwindow.cpp" line="3855"/>
<location filename="mainwindow.cpp" line="3869"/>
<source>The editing file will be saved using %1 encoding. &lt;br /&gt;This operation can&apos;t be reverted. &lt;br /&gt;Are you sure to continue?</source>
<translation>使%1&lt;br /&gt;&lt;br /&gt;</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4024"/>
<location filename="mainwindow.cpp" line="4033"/>
<source>New Watch Expression</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4025"/>
<location filename="mainwindow.cpp" line="4034"/>
<source>Enter Watch Expression (it is recommended to use &apos;this-&gt;&apos; for class members):</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4081"/>
<location filename="mainwindow.cpp" line="4090"/>
<source>Parsing file %1 of %2: &quot;%3&quot;</source>
<translation>%1/%2&quot;%3&quot;</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4103"/>
<location filename="mainwindow.cpp" line="4109"/>
<location filename="mainwindow.cpp" line="4112"/>
<location filename="mainwindow.cpp" line="4118"/>
<source>Done parsing %1 files in %2 seconds</source>
<translation>%1,%2</translation>
</message>
<message>
<location filename="mainwindow.cpp" line="4106"/>
<location filename="mainwindow.cpp" line="4115"/>
<source>(%1 files per second)</source>
<translation>(%1</translation>
</message>
@ -4695,77 +4715,77 @@ Are you really want to continue?</source>
<translation></translation>
</message>
<message>
<location filename="project.cpp" line="521"/>
<location filename="project.cpp" line="525"/>
<source>Can&apos;t save file</source>
<translation></translation>
</message>
<message>
<location filename="project.cpp" line="522"/>
<location filename="project.cpp" line="526"/>
<source>Can&apos;t save file &apos;%1&apos;</source>
<translation>&apos;%1&apos;.</translation>
</message>
<message>
<location filename="project.cpp" line="674"/>
<location filename="project.cpp" line="678"/>
<source>Error Load File</source>
<translation></translation>
</message>
<message>
<location filename="project.cpp" line="783"/>
<location filename="project.cpp" line="787"/>
<source>File Exists</source>
<translation></translation>
</message>
<message>
<location filename="project.cpp" line="784"/>
<location filename="project.cpp" line="788"/>
<source>File &apos;%1&apos; is already in the project</source>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location filename="project.cpp" line="1149"/>
<location filename="project.cpp" line="1161"/>
<source>Project Updated</source>
<translation></translation>
</message>
<message>
<location filename="project.cpp" line="1150"/>
<location filename="project.cpp" line="1162"/>
<source>Your project was succesfully updated to a newer file format!</source>
<translation></translation>
</message>
<message>
<location filename="project.cpp" line="1152"/>
<location filename="project.cpp" line="1164"/>
<source>If something has gone wrong, we kept a backup-file: &apos;%1&apos;...</source>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location filename="project.cpp" line="1328"/>
<location filename="project.cpp" line="1340"/>
<source>Settings need update</source>
<translation></translation>
</message>
<message>
<location filename="project.cpp" line="1329"/>
<location filename="project.cpp" line="1341"/>
<source>The compiler settings format of Dev-C++ has changed.</source>
<translation>Dev-C++</translation>
</message>
<message>
<location filename="project.cpp" line="1331"/>
<location filename="project.cpp" line="1343"/>
<source>Please update your settings at Project &gt;&gt; Project Options &gt;&gt; Compiler and save your project.</source>
<translation> &gt;&gt; &gt;&gt; </translation>
</message>
<message>
<location filename="project.cpp" line="1367"/>
<location filename="project.cpp" line="1379"/>
<source>Compiler not found</source>
<translation></translation>
</message>
<message>
<location filename="project.cpp" line="1368"/>
<location filename="project.cpp" line="1380"/>
<source>The compiler set you have selected for this project, no longer exists.</source>
<translation></translation>
</message>
<message>
<location filename="project.cpp" line="1370"/>
<location filename="project.cpp" line="1382"/>
<source>It will be substituted by the global compiler set.</source>
<translation></translation>
</message>
<message>
<location filename="project.cpp" line="1409"/>
<location filename="project.cpp" line="1421"/>
<source>Developed using the Red Panda Dev-C++ IDE</source>
<translation>使Dev-C++</translation>
</message>
@ -5156,24 +5176,24 @@ Are you really want to continue?</source>
<context>
<name>ProjectModel</name>
<message>
<location filename="project.cpp" line="1909"/>
<location filename="project.cpp" line="1921"/>
<source>File exists</source>
<translation></translation>
</message>
<message>
<location filename="project.cpp" line="1910"/>
<location filename="project.cpp" line="1922"/>
<source>File &apos;%1&apos; already exists. Delete it now?</source>
<translation>&apos;%1&apos;</translation>
</message>
<message>
<location filename="project.cpp" line="1928"/>
<location filename="project.cpp" line="1948"/>
<location filename="project.cpp" line="1940"/>
<location filename="project.cpp" line="1960"/>
<source>Remove failed</source>
<translation></translation>
</message>
<message>
<location filename="project.cpp" line="1929"/>
<location filename="project.cpp" line="1949"/>
<location filename="project.cpp" line="1941"/>
<location filename="project.cpp" line="1961"/>
<source>Failed to remove file &apos;%1&apos;</source>
<translation>&apos;%1&apos;</translation>
</message>
@ -6483,7 +6503,7 @@ Are you really want to continue?</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="5407"/>
<location filename="mainwindow.cpp" line="5428"/>
<location filename="settingsdialog/settingsdialog.cpp" line="138"/>
<location filename="settingsdialog/settingsdialog.cpp" line="182"/>
<location filename="settingsdialog/settingsdialog.cpp" line="190"/>
@ -6559,7 +6579,7 @@ Are you really want to continue?</source>
<translation></translation>
</message>
<message>
<location filename="mainwindow.cpp" line="5408"/>
<location filename="mainwindow.cpp" line="5429"/>
<location filename="settingsdialog/settingsdialog.cpp" line="182"/>
<location filename="settingsdialog/settingsdialog.cpp" line="186"/>
<source>Program Runner</source>

View File

@ -3211,6 +3211,15 @@ CPUDialog *MainWindow::cpuDialog() const
void MainWindow::on_actionNew_triggered()
{
if (mProject) {
if (QMessageBox::question(this,
tr("New Project File?"),
tr("Do you want to add the new file to the project?"),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) {
newProjectUnitFile();
return;
}
}
newEditor();
}
@ -4654,46 +4663,7 @@ void MainWindow::on_actionSaveAll_triggered()
void MainWindow::on_actionProject_New_File_triggered()
{
int idx = -1;
if (!mProject)
return;
QModelIndex current = ui->projectView->currentIndex();
FolderNode * node = nullptr;
if (current.isValid()) {
node = static_cast<FolderNode*>(current.internalPointer());
}
QString newFileName;
do {
newFileName = tr("untitled")+QString("%1").arg(getNewFileNumber());
if (mProject->options().useGPP) {
newFileName+=".cpp";
} else {
newFileName+=".c";
}
} while (fileExists(QDir(mProject->directory()).absoluteFilePath(newFileName)));
newFileName = QInputDialog::getText(
this,
tr("New Project File Name"),
tr("File Name:"),
QLineEdit::Normal,
newFileName);
if (newFileName.isEmpty())
return;
if (fileExists(QDir(mProject->directory()).absoluteFilePath(newFileName))) {
QMessageBox::critical(this,tr("File Already Exists!"),
tr("File '%1' already exists!").arg(newFileName));
return;
}
PProjectUnit newUnit = mProject->newUnit(
mProject->pointerToNode(node),newFileName);
idx = mProject->units().count()-1;
mProject->saveUnits();
updateProjectView();
Editor * editor = mProject->openUnit(idx);
//editor->setUseCppSyntax(mProject->options().useGPP);
//editor->setModified(true);
editor->activate();
newProjectUnitFile();
}
@ -4742,9 +4712,14 @@ void MainWindow::on_actionRemove_from_project_triggered()
continue;
selected.insert(folderNode->unitIndex);
};
bool removeFile = (QMessageBox::question(this,tr("Remove file"),
tr("Remove the file from disk?"),
QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes);
for (int i=mProject->units().count()-1;i>=0;i--) {
if (selected.contains(i)) {
mProject->removeEditor(i,true);
mProject->removeUnit(i,true,removeFile);
}
}
@ -4952,6 +4927,50 @@ void MainWindow::prepareTabMessagesData()
mTabMessagesData[widget]=info;
}
}
void MainWindow::newProjectUnitFile()
{
if (!mProject)
return;
int idx = -1;
QModelIndex current = ui->projectView->currentIndex();
FolderNode * node = nullptr;
if (current.isValid()) {
node = static_cast<FolderNode*>(current.internalPointer());
}
QString newFileName;
do {
newFileName = tr("untitled")+QString("%1").arg(getNewFileNumber());
if (mProject->options().useGPP) {
newFileName+=".cpp";
} else {
newFileName+=".c";
}
} while (fileExists(QDir(mProject->directory()).absoluteFilePath(newFileName)));
newFileName = QInputDialog::getText(
this,
tr("New Project File Name"),
tr("File Name:"),
QLineEdit::Normal,
newFileName);
if (newFileName.isEmpty())
return;
if (fileExists(QDir(mProject->directory()).absoluteFilePath(newFileName))) {
QMessageBox::critical(this,tr("File Already Exists!"),
tr("File '%1' already exists!").arg(newFileName));
return;
}
PProjectUnit newUnit = mProject->newUnit(
mProject->pointerToNode(node),newFileName);
idx = mProject->units().count()-1;
mProject->saveUnits();
updateProjectView();
Editor * editor = mProject->openUnit(idx);
//editor->setUseCppSyntax(mProject->options().useGPP);
//editor->setModified(true);
editor->activate();
}
void MainWindow::on_EditorTabsLeft_currentChanged(int)
{
Editor * editor = mEditorList->getEditor(-1,ui->EditorTabsLeft);
@ -5383,9 +5402,10 @@ void MainWindow::on_treeFiles_doubleClicked(const QModelIndex &index)
QString filepath = mFileSystemModel.filePath(index);
QFileInfo file(filepath);
if (file.isFile()) {
Editor * editor = mEditorList->getEditorByFilename(filepath);
if (editor) {
editor->activate();
if (getFileType(filepath)==FileType::Project) {
openProject(filepath);
} else {
openFile(filepath);
}
}
}

View File

@ -226,6 +226,7 @@ private:
void showHideMessagesTab(QWidget *widget, bool show);
void prepareTabInfosData();
void prepareTabMessagesData();
void newProjectUnitFile();
private slots:
void onAutoSaveTimeout();

View File

@ -85,7 +85,7 @@
<enum>QTabWidget::West</enum>
</property>
<property name="currentIndex">
<number>1</number>
<number>3</number>
</property>
<property name="usesScrollButtons">
<bool>true</bool>

View File

@ -340,7 +340,7 @@ void Project::rebuildNodes()
emit nodesChanged();
}
bool Project::removeEditor(int index, bool doClose)
bool Project::removeUnit(int index, bool doClose , bool removeFile)
{
mModel.beginUpdate();
auto action = finally([this]{
@ -357,6 +357,10 @@ bool Project::removeEditor(int index, bool doClose)
return false;
}
if (removeFile) {
QFile::remove(unit->fileName());
}
//if not fUnits.GetItem(index).fNew then
PFolderNode node = unit->node();
PFolderNode parent = node->parent.lock();
@ -788,10 +792,17 @@ PProjectUnit Project::addUnit(const QString &inFileName, PFolderNode parentNode,
newUnit = std::make_shared<ProjectUnit>(this);
// Set all properties
newUnit->setEncoding(toByteArray(mOptions.encoding));
newUnit->setFileName(QDir(directory()).filePath(inFileName));
newUnit->setNew(false);
newUnit->setEditor(nullptr);
Editor * e= pMainWindow->editorList()->getOpenedEditorByFilename(newUnit->fileName());
if (e) {
newUnit->setEditor(e);
newUnit->setEncoding(e->encodingOption());
e->setInProject(true);
} else {
newUnit->setEditor(nullptr);
newUnit->setEncoding(ENCODING_AUTO_DETECT);
}
newUnit->setFolder(getFolderPath(parentNode));
newUnit->setNode(makeNewFileNode(extractFileName(newUnit->fileName()), false, parentNode));
newUnit->node()->unitIndex = mUnits.count();
@ -1515,7 +1526,7 @@ void Project::removeFolderRecurse(PFolderNode node)
} else if (childNode->unitIndex >= 0 && childNode->level > 0) {
// Remove editor in folder from project
int editorIndex = childNode->unitIndex;
if (!removeEditor(editorIndex,true))
if (!removeUnit(editorIndex,true))
return;
}
}
@ -1920,7 +1931,7 @@ bool ProjectModel::setData(const QModelIndex &index, const QVariant &value, int
// Remove it from the current project...
int projindex = mProject->indexInUnits(newName);
if (projindex>=0) {
mProject->removeEditor(projindex,false);
mProject->removeUnit(projindex,false);
}
// All references to the file are removed. Delete the file from disk

View File

@ -148,7 +148,7 @@ public:
const QString& customFileName="");
Editor* openUnit(int index);
void rebuildNodes();
bool removeEditor(int index, bool doClose);
bool removeUnit(int index, bool doClose, bool removeFile = false);
bool removeFolder(PFolderNode node);
void resetParserProjectFiles();
void saveAll(); // save [Project] and all [UnitX]