- enhancement: don't parse all openned files when start up

- enhancement: don't parse files when close all and exit
This commit is contained in:
Roy Qu 2022-08-24 17:05:16 +08:00
parent 3f37d1d9b6
commit 4df3ba4f14
10 changed files with 78 additions and 38 deletions

View File

@ -1,3 +1,8 @@
Red Panda C++ Version 1.3
- enhancement: don't parse all openned files when start up
- enhancement: don't parse files when close all and exit
Red Panda C++ Version 1.2
- enhancement: Portuguese Translation ( Thanks for crcpucmg@github)

View File

@ -10,7 +10,7 @@ isEmpty(APP_NAME) {
}
isEmpty(APP_VERSION) {
APP_VERSION=1.2
APP_VERSION=1.3
}
macos: {

View File

@ -1283,16 +1283,21 @@ void Editor::showEvent(QShowEvent */*event*/)
&& !inProject()) {
initParser();
}
if (mParser) {
if (mParser && !pMainWindow->isClosingAll()
&& !pMainWindow->isQuitting()
&& !mParser->isFileParsed(mFilename)
) {
connect(mParser.get(),
&CppParser::onEndParsing,
this,
&SynEdit::invalidate);
}
if (pSettings->codeCompletion().clearWhenEditorHidden()
&& !inProject()) {
reparse();
}
// if (pSettings->codeCompletion().clearWhenEditorHidden()
// && !inProject()) {
// reparse();
// }
reparseTodo();
setHideTime(QDateTime());
}
@ -1540,11 +1545,13 @@ void Editor::onStatusChanged(SynStatusChanges changes)
&& !changes.testFlag(SynStatusChange::scReadOnly)
&& changes.testFlag(SynStatusChange::scCaretY))) {
mCurrentLineModified = false;
if (pSettings->codeCompletion().clearWhenEditorHidden()
&& changes.testFlag(SynStatusChange::scOpenFile)) {
} else{
if (!changes.testFlag(SynStatusChange::scOpenFile))
reparse();
}
// if (pSettings->codeCompletion().clearWhenEditorHidden()
// && changes.testFlag(SynStatusChange::scOpenFile)) {
// } else{
// reparse();
// }
if (pSettings->editor().syntaxCheckWhenLineChanged())
checkSyntaxInBack();
reparseTodo();

View File

@ -164,10 +164,6 @@ bool EditorList::closeEditor(Editor* editor, bool transferFocus, bool force) {
}
beginUpdate();
auto end = finally([this] {
this->endUpdate();
});
// if (transferFocus && (editor->pageControl()->currentWidget()==editor)) {
// //todo: activate & focus the previous editor
// }
@ -184,14 +180,17 @@ bool EditorList::closeEditor(Editor* editor, bool transferFocus, bool force) {
delete editor;
}
updateLayout();
if (!force) {
if (!force && transferFocus) {
editor = getEditor();
if (transferFocus && editor)
if (editor) {
editor->activate();
else
pMainWindow->updateClassBrowserForEditor(editor);
} else {
pMainWindow->updateClassBrowserForEditor(nullptr);
}
}
emit editorClosed();
endUpdate();
return true;
}

View File

@ -110,6 +110,7 @@ MainWindow::MainWindow(QWidget *parent)
mCheckSyntaxInBack(false),
mShouldRemoveAllSettings(false),
mClosing(false),
mClosingAll(false),
mOpenningFiles(false),
mSystemTurnedOff(false)
{
@ -877,7 +878,7 @@ void MainWindow::onFileSaved(const QString &path, bool inProject)
ui->treeFiles->update(index);
}
}
pMainWindow->updateForEncodingInfo();
//updateForEncodingInfo();
}
void MainWindow::updateAppTitle()
@ -1160,17 +1161,25 @@ void MainWindow::openFiles(const QStringList &files)
}
}
//Didn't find a project? Open all files
for (const QString& file:files) {
openFile(file);
for (int i=0;i<files.length()-1;i++) {
openFile(files[i],false);
}
if (files.length()>0) {
openFile(files.last(),true);
}
mEditorList->endUpdate();
Editor* e=mEditorList->getEditor();
if (e)
e->activate();
}
void MainWindow::openFile(const QString &filename, QTabWidget* page)
void MainWindow::openFile(const QString &filename, bool activate, QTabWidget* page)
{
Editor* editor = mEditorList->getOpenedEditorByFilename(filename);
if (editor!=nullptr) {
if (activate) {
editor->activate();
}
return;
}
try {
@ -1187,8 +1196,10 @@ void MainWindow::openFile(const QString &filename, QTabWidget* page)
// if (mProject) {
// mProject->associateEditorToUnit(editor,unit);
// }
if (activate) {
editor->activate();
this->updateForEncodingInfo();
}
// editor->activate();
} catch (FileError e) {
QMessageBox::critical(this,tr("Error"),e.reason());
}
@ -1263,7 +1274,7 @@ void MainWindow::openProject(const QString &filename, bool openFiles)
updateCompilerSet();
updateClassBrowserForEditor(e);
}
updateForEncodingInfo();
//updateForEncodingInfo();
}
void MainWindow::changeOptions(const QString &widgetName, const QString &groupName)
@ -2230,7 +2241,7 @@ void MainWindow::loadLastOpens()
}
if (count>0) {
updateEditorActions();
updateForEncodingInfo();
//updateForEncodingInfo();
}
if (focusedEditor)
focusedEditor->activate();
@ -2298,7 +2309,7 @@ void MainWindow::newEditor()
pSettings->editor().defaultEncoding(),
false,true);
editor->activate();
updateForEncodingInfo();
//updateForEncodingInfo();
} catch (FileError e) {
QMessageBox::critical(this,tr("Error"),e.reason());
}
@ -4510,11 +4521,14 @@ void MainWindow::closeEvent(QCloseEvent *event) {
}
}
mClosingAll=true;
if (!mEditorList->closeAll(false)) {
mClosingAll=false;
mQuitting = false;
event->ignore();
return ;
}
mClosingAll=false;
if (!mShouldRemoveAllSettings && pSettings->editor().autoLoadLastFiles()) {
if (mProject) {
@ -5542,9 +5556,11 @@ void MainWindow::on_actionClose_triggered()
void MainWindow::on_actionClose_All_triggered()
{
mClosingAll=true;
mClosing = true;
mEditorList->closeAll(mSystemTurnedOff);
mClosing = false;
mClosingAll=false;
}
@ -8089,3 +8105,13 @@ void MainWindow::on_actionNew_Template_triggered()
}
}
bool MainWindow::isQuitting() const
{
return mQuitting;
}
bool MainWindow::isClosingAll() const
{
return mClosingAll;
}

View File

@ -190,7 +190,7 @@ public:
const PBookmarkModel &bookmarkModel() const;
void openFile(const QString& filename, QTabWidget* page=nullptr);
void openFile(const QString& filename, bool activate=true, QTabWidget* page=nullptr);
void openProject(const QString& filename, bool openFiles = true);
void changeOptions(const QString& widgetName=QString(), const QString& groupName=QString());
@ -759,6 +759,7 @@ private:
CaretList mCaretList;
bool mClosing;
bool mClosingAll;
bool mOpenningFiles;
bool mSystemTurnedOff;
QPoint mEditorContextMenuPos;
@ -844,6 +845,8 @@ protected:
// QObject interface
public:
bool event(QEvent *event) override;
bool isClosingAll() const;
bool isQuitting() const;
};
extern MainWindow* pMainWindow;

View File

@ -959,6 +959,11 @@ QSet<QString> CppParser::scannedFiles()
return mPreprocessor.scannedFiles();
}
bool CppParser::isFileParsed(const QString &filename)
{
return mPreprocessor.scannedFiles().contains(filename);
}
QString CppParser::getScopePrefix(const PStatement& statement){
switch (statement->classScope) {
case StatementClassScope::scsPublic:

View File

@ -112,6 +112,8 @@ public:
void unFreeze(); // UnFree/UnLock (reparse while searching)
QSet<QString> scannedFiles();
bool isFileParsed(const QString& filename);
QString prettyPrintStatement(const PStatement& statement, const QString& filename, int line = -1);
bool enabled() const;

View File

@ -31,21 +31,14 @@ EditorsTabWidget::EditorsTabWidget(QWidget* parent):QTabWidget(parent)
void EditorsTabWidget::dropEvent(QDropEvent *event)
{
if (event->mimeData()->hasUrls()) {
QStringList files;
foreach(const QUrl& url, event->mimeData()->urls()){
if (!url.isLocalFile())
continue;
QString file = url.toLocalFile();
if (getFileType(file)==FileType::Project) {
pMainWindow->openProject(file);
return;
}
}
foreach(const QUrl& url, event->mimeData()->urls()){
if (!url.isLocalFile())
continue;
QString file = url.toLocalFile();
pMainWindow->openFile(file,this);
files.append(file);
}
pMainWindow->openFiles(files);
}
}

View File

@ -23,7 +23,7 @@ SUBDIRS += \
APP_NAME = RedPandaCPP
APP_VERSION = 1.2
APP_VERSION = 1.3
linux: {
isEmpty(PREFIX) {