From c5a3c820c5b12c75a4e17950349a0b5a140bffbc Mon Sep 17 00:00:00 2001 From: "royqh1979@gmail.com" Date: Fri, 9 Apr 2021 10:08:05 +0800 Subject: [PATCH] * new changes --- IDE-todo.xlsx | Bin 0 -> 9868 bytes RedPandaIDE/editor.cpp | 2 +- RedPandaIDE/editor.h | 3 +- RedPandaIDE/editorlist.cpp | 71 +++++++++++++++++++++++++++++++++---- RedPandaIDE/editorlist.h | 16 ++++++++- RedPandaIDE/mainwindow.cpp | 1 - 6 files changed, 83 insertions(+), 10 deletions(-) create mode 100644 IDE-todo.xlsx diff --git a/IDE-todo.xlsx b/IDE-todo.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..6c95383abbfbe932b681fb31c751d87e140eca68 GIT binary patch literal 9868 zcmeHNby!sEx*xhrYRI7*Ns&gnyQCzC?hr=0hL93axzs(M>7*ts(q}!0?BXp zj}c@WRa%n>N`ju)l)}Ap;09sxK+$k3xd@J^tOAfZXy+UH>$%Z8XS{q&c4UDK8LQ>B z9>za}fqP9B34Z?A^cg^srz!EPa=}wf z#6ZklNmuKsvncY*l3DEej9hWh(wjqUvRjy(-Q6Jo)czu-HQJoCCotYqf<486iK($G z*xrrf;m_lL#q&Q{CjZp+(s*UnPEJhdzTA(n-t#Z>akvtSp5k(i)LMQ4@^d&f(Rp-a z^R0~JxLTya2(tdoen0wW=Y^xUd#TS>cuQYCAP}Oh^(=!XUAcImurRp3k#Q+q{)G4Z z%juW16j=ob)AQz7mXi8+If{LYv@+v|QkA$P4|Pe=@C(SHL?S7H`rXQU3uYJPa9<=e z_sXCZb&s>R6GqbfC*Kr)!x9S@P}&_!A?$TCvzjjV>9wamy(HDvv=*?bFw1lmq=6V) z*tZ=^rM2SU_^_*__iE7aKDgi>k?o<+KK0kH<~+bf&=>R)^lkxWvHmV3 zfue~?$FLD;fC&jH02R*5p5u2p@pN*vGjnpX`)SSoB{Og^lLkZi&)!Nklodb0R653O z7^i32b3(jncMh6e?HwG{zG~)K25KI^l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<=R$~Z3sl_o4XVdMlUw&{+dx|B=V*4C6t{%Kx5J8FhiqxQmtbnsF&N3;R) zuIuUE0mi@s7G0Jd3IcnKh>YG~95X!MfN*3D8KQ@Tr81a2!wKa%>NXNpv;{|%>T))Q zZpPX&okf$ASo~|U5Whjw;3WknoX+7mte6i(cazm84XcW}B@R?3%q>upXdOAtevpi8 zmQU#Pv`jFe4;y-}K~PH!ave9ZPkLm54$+1M8!H$e^;REuGrOUHJuyN)lE{kP`h-hy z<8j$uI9NY!`S)_~rU1_<4+|?8`L|t@YUU=>fa^=m+|4p(Cr>AUn$|rujB{1lw zd)Q=&$~4OvJSx%fj)-MNsBN6fd4zKbn}2{55caso=jPMNnAn2bBI0^2-EQuF_l-i5 z>AEUm#{l2?OEbL^RC)@Nx;-QD^l_TJJ*ABrS34%-7Ypd~d+(t*58q}nUiPF93l^i@ zUcFxDflbWs3LFle9aez&=M^>on!kUY|6zTNn&Mvp{#xt*7vazITbPjisq%lH@UQjH zKNAkZ!nyyw8hRh+eo^cf(j9Ek(7h7bed7C7nP0?>=)V#FtwwVn;eIap7lJJIzd!$f zWtQ&)-cQZ`0+ff<{9ygLpQybLa6c;k1%N~Jd!POtBi|>zA9Va8-GRj*e~jfHo%t1l z+(-GVTks150Endk0RHAA+$X=U?tcNCfqrYm|3~@X2mPz&{sjpD1W^5{O@HWdHAN&C T4*~#~upa}Ajn#fu2>|~CQhf2c literal 0 HcmV?d00001 diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 54ced689..f3bd8d39 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -95,7 +95,7 @@ void Editor::saveFile(const QString &filename) { file.close(); } -bool Editor::save() { +bool Editor::save(bool force, bool reparse) { return true; } diff --git a/RedPandaIDE/editor.h b/RedPandaIDE/editor.h index e04354e7..4e79575c 100644 --- a/RedPandaIDE/editor.h +++ b/RedPandaIDE/editor.h @@ -26,9 +26,10 @@ public: void loadFile(); void saveFile(const QString& filename); - bool save(); + bool save(bool force=false, bool reparse=true); QsciScintilla* textEdit(); + QTabWidget* pageControl(); signals: private: diff --git a/RedPandaIDE/editorlist.cpp b/RedPandaIDE/editorlist.cpp index 4b2ab09c..09e5b858 100644 --- a/RedPandaIDE/editorlist.cpp +++ b/RedPandaIDE/editorlist.cpp @@ -1,7 +1,19 @@ #include "editorlist.h" #include "editor.h" +#include #include +#include +#include +EditorList::UpdateLocker::UpdateLocker(EditorList* editorList): mEditorList(editorList){ + mEditorList->beginUpdate(); +} + +EditorList::UpdateLocker::~UpdateLocker() { + mEditorList->endUpdate(); +} + +} EditorList::EditorList(QTabWidget* leftPageWidget, QTabWidget* rightPageWidget, QSplitter* splitter, @@ -27,30 +39,77 @@ Editor* EditorList::newEditor(const QString& filename, const QByteArray& encodin //UpdateLayout; } -QTabWidget* EditorList::getNewEditorPageControl() { +QTabWidget* EditorList::getNewEditorPageControl() const { //todo: return widget depends on layout return mLeftPageWidget; } +QTabWidget* EditorList::getFocusedPageControl() const { + //todo: + return mLeftPageWidget; +} + Editor* EditorList::getEditor(int index, QTabWidget* tabsWidget) const { QTabWidget* selectedWidget; if (tabsWidget == NULL) { - selectedWidget = mLeftPageWidget; // todo: get focused widget + selectedWidget = getFocusedPageControl(); // todo: get focused widget } else { selectedWidget = tabsWidget; } - QWidget* textEdit; if (index == -1) { - textEdit = selectedWidget->currentWidget(); - } else { - textEdit =selectedWidget->widget(index); + index = selectedWidget->currentIndex(); } + if (index<0 || index >= selectedWidget->count()) { + return NULL; + } + QWidget* textEdit = selectedWidget->widget(index); QVariant pop = textEdit->property("editor"); Editor *editor = (Editor*)pop.value(); return editor; } bool EditorList::closeEditor(Editor* editor, bool transferFocus, bool force) { + UpdateLocker locker(this); // use RAII to correctly pause/resume update of the panel widget + if (editor == NULL) + return false; + if (force) { + editor->save(true,false); + } else if ( (editor->textEdit()->isModified()) && (!editor->textEdit()->text().isEmpty())) { + // ask user if he wants to save + QMessageBox::StandardButton reply; + reply = QMessageBox::question(pMainWindow,QObject::tr("Save"),QObject::tr("Save changes to %s?"), + QMessageBox::Yes|QMessageBox::No|QMessageBox::Cancel); + if (reply == QMessageBox::Cancel) { + return false; + } else if (reply == QMessageBox::Yes) { + if (!editor->save(false,false)) { + return false; + } + } + } + + if (transferFocus && editor-) + delete editor; return true; } + +void EditorList::beginUpdate() { + if (mUpdateCount==0) { + mPanel->setUpdatesEnabled(false); + } + mUpdateCount++; +} + +void EditorList::endUpdate() { + mUpdateCount--; + if (mUpdateCount==0) { + mPanel->setUpdatesEnabled(true); + mPanel->update(); + } +} + +bool EditorList::closeAll(bool force) { + UpdateLocker locker(this); + +} diff --git a/RedPandaIDE/editorlist.h b/RedPandaIDE/editorlist.h index 69c2c072..b38beb8c 100644 --- a/RedPandaIDE/editorlist.h +++ b/RedPandaIDE/editorlist.h @@ -17,6 +17,14 @@ public: lstBoth }; + class UpdateLocker { + public: + UpdateLocker(EditorList* editorList); + ~UpdateLocker(); + private: + EditorList* mEditorList; + }; + explicit EditorList(QTabWidget* leftPageWidget, QTabWidget* rightPageWidget, QSplitter* splitter, @@ -30,8 +38,14 @@ public: bool closeEditor(Editor* editor, bool transferFocus=true, bool force=false); + bool closeAll(bool force = false); + + void beginUpdate(); + void endUpdate(); + private: - QTabWidget* getNewEditorPageControl(); + QTabWidget* getNewEditorPageControl() const; + QTabWidget* getFocusedPageControl() const; private: diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 442ea86d..eb9dfaaf 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -47,7 +47,6 @@ void MainWindow::setupActions() { void MainWindow::on_actionNew_triggered() { Editor * editor=mEditorList->newEditor("",ENCODING_AUTO_DETECT,false,true); - editor->textEdit()->setFocus(); updateStatusBarForEncoding(); }