From 895a927ee0c0238442ec465cd402aa348e7273a9 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Thu, 23 Jun 2022 13:05:10 +0800 Subject: [PATCH] - fix: select all shouldn't set file's modified flag - enhancement: add (return)type info for functions/varaibles/typedefs in the class browser panel --- NEWS.md | 2 ++ RedPandaIDE/cpprefacter.cpp | 3 +-- RedPandaIDE/editor.cpp | 4 ++-- RedPandaIDE/mainwindow.cpp | 3 +-- RedPandaIDE/qsynedit/SynEdit.h | 6 +++++- RedPandaIDE/widgets/classbrowser.cpp | 7 +++++++ 6 files changed, 18 insertions(+), 7 deletions(-) diff --git a/NEWS.md b/NEWS.md index 3ebda05e..b5c4d0fb 100644 --- a/NEWS.md +++ b/NEWS.md @@ -3,6 +3,8 @@ Red Panda C++ Version 1.1.2 - enhancement: auto add "/" to folder when completing #include headers - enhancement: add the option "Set Encoding for the Executable" to project's compiler options - fix: can't correctly compile when link params are seperated by line breaks + - fix: select all shouldn't set file's modified flag + - enhancement: add (return)type info for functions/varaibles/typedefs in the class browser panel Red Panda C++ Version 1.1.1 - enhancement: adjust the appearance of problem case's input/output/expected control diff --git a/RedPandaIDE/cpprefacter.cpp b/RedPandaIDE/cpprefacter.cpp index 2b3bc4e6..3802f7bc 100644 --- a/RedPandaIDE/cpprefacter.cpp +++ b/RedPandaIDE/cpprefacter.cpp @@ -319,8 +319,7 @@ void CppRefacter::renameSymbolInFile(const QString &filename, const PStatement & oldEditor->beginUndoBlock(); oldEditor->addLeftTopToUndo(); oldEditor->addCaretToUndo(); - oldEditor->selectAll(); - oldEditor->setSelText(newContents.join(oldEditor->lineBreak())); + oldEditor->replaceAll(newContents.join(oldEditor->lineBreak())); oldEditor->setTopLine(topLine); oldEditor->setLeftChar(leftChar); oldEditor->setCaretXY(oldXY); diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 8b846926..4436121a 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -4276,12 +4276,12 @@ void Editor::reformat() beginUndoBlock(); addLeftTopToUndo(); addCaretToUndo(); - selectAll(); + SynEditorOptions oldOptions = getOptions(); SynEditorOptions newOptions = oldOptions; newOptions.setFlag(SynEditorOption::eoAutoIndent,false); setOptions(newOptions); - setSelText(QString::fromUtf8(newContent)); + replaceAll(QString::fromUtf8(newContent)); setCaretXY(mOldCaret); setTopLine(oldTopLine); setOptions(oldOptions); diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index 0e94fb66..388bba90 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -6670,8 +6670,7 @@ void MainWindow::on_btnReplace_clicked() BufferCoord coord=editor->caretXY(); int topLine = editor->topLine(); int leftChar = editor->leftChar(); - editor->selectAll(); - editor->setSelText(contents.join(editor->lineBreak())); + editor->replaceAll(contents.join(editor->lineBreak())); editor->setCaretXY(coord); editor->setTopLine(topLine); editor->setLeftChar(leftChar); diff --git a/RedPandaIDE/qsynedit/SynEdit.h b/RedPandaIDE/qsynedit/SynEdit.h index c92c7b6e..9d43a4f7 100644 --- a/RedPandaIDE/qsynedit/SynEdit.h +++ b/RedPandaIDE/qsynedit/SynEdit.h @@ -270,6 +270,11 @@ public: void endUndoBlock(); void addCaretToUndo(); void addLeftTopToUndo(); + void replaceAll(const QString& text) { + mUndoList->AddChange(SynChangeReason::crSelection,mBlockBegin,mBlockEnd,"", activeSelectionMode()); + selectAll(); + setSelText(text); + } //Commands virtual void cutToClipboard() { commandProcessor(SynEditorCommand::ecCut);} @@ -280,7 +285,6 @@ public: virtual void zoomIn() { commandProcessor(SynEditorCommand::ecZoomIn);} virtual void zoomOut() { commandProcessor(SynEditorCommand::ecZoomOut);} virtual void selectAll() { - mUndoList->AddChange(SynChangeReason::crSelection,mBlockBegin,mBlockEnd,"", activeSelectionMode()); commandProcessor(SynEditorCommand::ecSelectAll); } virtual void tab() { commandProcessor(SynEditorCommand::ecTab);} diff --git a/RedPandaIDE/widgets/classbrowser.cpp b/RedPandaIDE/widgets/classbrowser.cpp index d8d9662c..488495f4 100644 --- a/RedPandaIDE/widgets/classbrowser.cpp +++ b/RedPandaIDE/widgets/classbrowser.cpp @@ -143,6 +143,13 @@ QVariant ClassBrowserModel::data(const QModelIndex &index, int role) const return QVariant(); if (role == Qt::DisplayRole) { if (node->statement) { + if (!(node->statement->type.isEmpty()) && + ((node->statement->kind == StatementKind::skFunction) + || (node->statement->kind == StatementKind::skVariable) + || (node->statement->kind == StatementKind::skTypedef) + )) { + return node->statement->command + node->statement->args + " : " + node->statement->type; + } return node->statement->command + node->statement->args; } } else if (role == Qt::ForegroundRole) {