- enhancement: Add "Open files in editor" in the search panel
- enhancement: Auto disable the "in project" option in the "search in files" dialog, if no project is opened. - enhancement: Auto disable the "search again" button in the search panel if the current search history item is search in the project, and no project is opened.
This commit is contained in:
parent
93a37a2bc6
commit
ea26548835
3
NEWS.md
3
NEWS.md
|
@ -28,6 +28,9 @@ Red Panda C++ Version 2.8
|
||||||
- enhancement: Rename symbols won't remove all breakpoints/bookmarks
|
- enhancement: Rename symbols won't remove all breakpoints/bookmarks
|
||||||
- enhancement: Batch replace won't remove all breakpoints/bookmarks
|
- enhancement: Batch replace won't remove all breakpoints/bookmarks
|
||||||
- enhancement: Execute parameters can be used in debug.
|
- enhancement: Execute parameters can be used in debug.
|
||||||
|
- enhancement: Add "Open files in editor" in the search panel
|
||||||
|
- enhancement: Auto disable the "in project" option in the "search in files" dialog, if no project is opened.
|
||||||
|
- enhancement: Auto disable the "search again" button in the search panel if the current search history item is search in the project, and no project is opened.
|
||||||
|
|
||||||
Red Panda C++ Version 2.7
|
Red Panda C++ Version 2.7
|
||||||
|
|
||||||
|
|
|
@ -324,9 +324,17 @@ void CppRefacter::renameSymbolInFile(const QString &filename, const PStatement &
|
||||||
} else {
|
} else {
|
||||||
Editor editor(nullptr);
|
Editor editor(nullptr);
|
||||||
QByteArray encoding;
|
QByteArray encoding;
|
||||||
editor.document()->loadFromFile(filename,ENCODING_AUTO_DETECT,encoding);
|
|
||||||
QStringList newContents;
|
|
||||||
editor.setSyntaxer(syntaxerManager.getSyntaxer(QSynedit::ProgrammingLanguage::CPP));
|
editor.setSyntaxer(syntaxerManager.getSyntaxer(QSynedit::ProgrammingLanguage::CPP));
|
||||||
|
try {
|
||||||
|
editor.document()->loadFromFile(filename,ENCODING_AUTO_DETECT,encoding);
|
||||||
|
} catch(FileError e) {
|
||||||
|
QMessageBox::critical(pMainWindow,
|
||||||
|
tr("Rename Symbol Error"),
|
||||||
|
e.reason());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList newContents;
|
||||||
int posY = 0;
|
int posY = 0;
|
||||||
while (posY < editor.document()->count()) {
|
while (posY < editor.document()->count()) {
|
||||||
QString line = editor.document()->getLine(posY);
|
QString line = editor.document()->getLine(posY);
|
||||||
|
@ -365,8 +373,16 @@ void CppRefacter::renameSymbolInFile(const QString &filename, const PStatement &
|
||||||
}
|
}
|
||||||
QByteArray realEncoding;
|
QByteArray realEncoding;
|
||||||
QFile file(filename);
|
QFile file(filename);
|
||||||
|
try {
|
||||||
editor.document()->saveToFile(file,ENCODING_AUTO_DETECT,
|
editor.document()->saveToFile(file,ENCODING_AUTO_DETECT,
|
||||||
pSettings->editor().defaultEncoding(),
|
pSettings->editor().defaultEncoding(),
|
||||||
realEncoding);
|
realEncoding);
|
||||||
|
} catch(FileError e) {
|
||||||
|
QMessageBox::critical(pMainWindow,
|
||||||
|
tr("Rename Symbol Error"),
|
||||||
|
e.reason());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -934,6 +934,7 @@ void MainWindow::applySettings()
|
||||||
void MainWindow::applyUISettings()
|
void MainWindow::applyUISettings()
|
||||||
{
|
{
|
||||||
const Settings::UI& settings = pSettings->ui();
|
const Settings::UI& settings = pSettings->ui();
|
||||||
|
ui->chkOpenFileInEditors->setChecked(settings.openEditorsWhenReplace());
|
||||||
restoreGeometry(settings.mainWindowGeometry());
|
restoreGeometry(settings.mainWindowGeometry());
|
||||||
restoreState(settings.mainWindowState());
|
restoreState(settings.mainWindowState());
|
||||||
ui->actionTool_Window_Bars->setChecked(settings.showToolWindowBars());
|
ui->actionTool_Window_Bars->setChecked(settings.showToolWindowBars());
|
||||||
|
@ -5030,6 +5031,8 @@ void MainWindow::closeProject(bool refreshEditor)
|
||||||
updateProjectView();
|
updateProjectView();
|
||||||
mClosingProject=false;
|
mClosingProject=false;
|
||||||
}
|
}
|
||||||
|
if (refreshEditor)
|
||||||
|
on_cbSearchHistory_currentIndexChanged(ui->cbSearchHistory->currentIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::updateProjectView()
|
void MainWindow::updateProjectView()
|
||||||
|
@ -5203,6 +5206,7 @@ void MainWindow::closeEvent(QCloseEvent *event) {
|
||||||
if (mCPUDialog)
|
if (mCPUDialog)
|
||||||
mCPUDialog->close();
|
mCPUDialog->close();
|
||||||
Settings::UI& settings = pSettings->ui();
|
Settings::UI& settings = pSettings->ui();
|
||||||
|
settings.setOpenEditorsWhenReplace(ui->chkOpenFileInEditors->isChecked());
|
||||||
settings.setMainWindowState(saveState());
|
settings.setMainWindowState(saveState());
|
||||||
settings.setMainWindowGeometry(saveGeometry());
|
settings.setMainWindowGeometry(saveGeometry());
|
||||||
settings.setBottomPanelIndex(ui->tabMessages->currentIndex());
|
settings.setBottomPanelIndex(ui->tabMessages->currentIndex());
|
||||||
|
@ -6197,6 +6201,11 @@ void MainWindow::on_cbSearchHistory_currentIndexChanged(int index)
|
||||||
mSearchResultModel.setCurrentIndex(index);
|
mSearchResultModel.setCurrentIndex(index);
|
||||||
PSearchResults results = mSearchResultModel.results(index);
|
PSearchResults results = mSearchResultModel.results(index);
|
||||||
if (results) {
|
if (results) {
|
||||||
|
if (results->searchType==SearchType::Search
|
||||||
|
&& results->scope==SearchFileScope::wholeProject
|
||||||
|
&& pMainWindow->project()==nullptr)
|
||||||
|
ui->btnSearchAgain->setEnabled(false);
|
||||||
|
else
|
||||||
ui->btnSearchAgain->setEnabled(true);
|
ui->btnSearchAgain->setEnabled(true);
|
||||||
} else {
|
} else {
|
||||||
ui->btnSearchAgain->setEnabled(false);
|
ui->btnSearchAgain->setEnabled(false);
|
||||||
|
@ -6212,6 +6221,9 @@ void MainWindow::on_btnSearchAgain_clicked()
|
||||||
if (!results)
|
if (!results)
|
||||||
return;
|
return;
|
||||||
if (results->searchType == SearchType::Search){
|
if (results->searchType == SearchType::Search){
|
||||||
|
if (results->scope==SearchFileScope::wholeProject
|
||||||
|
&& pMainWindow->project()==nullptr)
|
||||||
|
return;
|
||||||
mSearchInFilesDialog->findInFiles(results->keyword,
|
mSearchInFilesDialog->findInFiles(results->keyword,
|
||||||
results->scope,
|
results->scope,
|
||||||
results->options);
|
results->options);
|
||||||
|
@ -7705,26 +7717,56 @@ void MainWindow::on_btnReplace_clicked()
|
||||||
}
|
}
|
||||||
QString newWord = ui->cbReplaceInHistory->currentText();
|
QString newWord = ui->cbReplaceInHistory->currentText();
|
||||||
foreach (const PSearchResultTreeItem& file, results->results) {
|
foreach (const PSearchResultTreeItem& file, results->results) {
|
||||||
QStringList contents;
|
QVector<PSearchResultTreeItem> selections;
|
||||||
Editor* editor = openFile(file->filename);
|
foreach(const PSearchResultTreeItem& item,file->results) {
|
||||||
|
if (item->selected) {
|
||||||
|
selections.push_back(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (selections.isEmpty())
|
||||||
|
continue;
|
||||||
|
Editor* editor = nullptr;
|
||||||
|
if (ui->chkOpenFileInEditors->isChecked()) {
|
||||||
|
editor = openFile(file->filename);
|
||||||
if (!editor) {
|
if (!editor) {
|
||||||
QMessageBox::critical(this,
|
QMessageBox::critical(this,
|
||||||
tr("Replace Error"),
|
tr("Replace Error"),
|
||||||
tr("Can't open file '%1' for replace!").arg(file->filename));
|
tr("Can't open file '%1' for replace!").arg(file->filename));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
editor = mEditorList->getOpenedEditorByFilename(file->filename);
|
||||||
|
}
|
||||||
|
bool needSave=false;
|
||||||
|
std::shared_ptr<Editor> pEditor;
|
||||||
|
if (editor) {
|
||||||
editor->clearSelection();
|
editor->clearSelection();
|
||||||
editor->addGroupBreak();
|
editor->addGroupBreak();
|
||||||
editor->beginUndoBlock();
|
editor->beginUndoBlock();
|
||||||
for (int i=file->results.count()-1;i>=0;i--) {
|
} else {
|
||||||
const PSearchResultTreeItem& item = file->results[i];
|
needSave=true;
|
||||||
if (!item->selected)
|
pEditor = std::make_shared<Editor>(nullptr);
|
||||||
continue;
|
editor = pEditor.get();
|
||||||
|
QByteArray encoding;
|
||||||
|
editor->setSyntaxer(syntaxerManager.getSyntaxer(QSynedit::ProgrammingLanguage::CPP));
|
||||||
|
try {
|
||||||
|
editor->document()->loadFromFile(file->filename,ENCODING_AUTO_DETECT,encoding);
|
||||||
|
} catch(FileError e) {
|
||||||
|
QMessageBox::critical(this,
|
||||||
|
tr("Replace Error"),
|
||||||
|
e.reason());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (!selections.isEmpty()) {
|
||||||
|
const PSearchResultTreeItem& item = selections.back();
|
||||||
|
selections.pop_back();
|
||||||
QString line = editor->document()->getLine(item->line-1);
|
QString line = editor->document()->getLine(item->line-1);
|
||||||
if (line.mid(item->start-1,results->keyword.length())!=results->keyword) {
|
if (line.mid(item->start-1,results->keyword.length())!=results->keyword) {
|
||||||
QMessageBox::critical(editor,
|
QMessageBox::critical(editor,
|
||||||
tr("Replace Error"),
|
tr("Replace Error"),
|
||||||
tr("Contents has changed since last search!"));
|
tr("Contents has changed since last search!"));
|
||||||
|
if (!needSave)
|
||||||
editor->endUndoBlock();
|
editor->endUndoBlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -7732,7 +7774,22 @@ void MainWindow::on_btnReplace_clicked()
|
||||||
line.insert(item->start-1, newWord);
|
line.insert(item->start-1, newWord);
|
||||||
editor->replaceLine(item->line,line);
|
editor->replaceLine(item->line,line);
|
||||||
}
|
}
|
||||||
|
if (!needSave) {
|
||||||
editor->endUndoBlock();
|
editor->endUndoBlock();
|
||||||
|
} else {
|
||||||
|
QByteArray realEncoding;
|
||||||
|
QFile toFile(file->filename);
|
||||||
|
try {
|
||||||
|
editor->document()->saveToFile(toFile,ENCODING_AUTO_DETECT,
|
||||||
|
pSettings->editor().defaultEncoding(),
|
||||||
|
realEncoding);
|
||||||
|
} catch(FileError e) {
|
||||||
|
QMessageBox::critical(this,
|
||||||
|
tr("Replace Error"),
|
||||||
|
e.reason());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
showSearchReplacePanel(false);
|
showSearchReplacePanel(false);
|
||||||
stretchMessagesPanel(false);
|
stretchMessagesPanel(false);
|
||||||
|
|
|
@ -929,7 +929,7 @@
|
||||||
<enum>QTabWidget::South</enum>
|
<enum>QTabWidget::South</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>6</number>
|
<number>3</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="iconSize">
|
<property name="iconSize">
|
||||||
<size>
|
<size>
|
||||||
|
@ -1445,6 +1445,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QCheckBox" name="chkOpenFileInEditors">
|
||||||
|
<property name="text">
|
||||||
|
<string>Open file in editors</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="btnReplace">
|
<widget class="QPushButton" name="btnReplace">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|
|
@ -5272,6 +5272,16 @@ void Settings::UI::setProblemOrder(int newProblemOrder)
|
||||||
mProblemOrder = newProblemOrder;
|
mProblemOrder = newProblemOrder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Settings::UI::openEditorsWhenReplace() const
|
||||||
|
{
|
||||||
|
return mOpenEditorsWhenReplace;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::UI::setOpenEditorsWhenReplace(bool newOpenEditorsWhenReplace)
|
||||||
|
{
|
||||||
|
mOpenEditorsWhenReplace = newOpenEditorsWhenReplace;
|
||||||
|
}
|
||||||
|
|
||||||
int Settings::UI::bookmarkOrder() const
|
int Settings::UI::bookmarkOrder() const
|
||||||
{
|
{
|
||||||
return mBookmarkOrder;
|
return mBookmarkOrder;
|
||||||
|
@ -5644,6 +5654,8 @@ void Settings::UI::setMainWindowState(const QByteArray &newMainWindowState)
|
||||||
|
|
||||||
void Settings::UI::doSave()
|
void Settings::UI::doSave()
|
||||||
{
|
{
|
||||||
|
saveValue("open_editor_when_batch_replace",mOpenEditorsWhenReplace);
|
||||||
|
|
||||||
saveValue("main_window_state",mMainWindowState);
|
saveValue("main_window_state",mMainWindowState);
|
||||||
saveValue("main_window_geometry",mMainWindowGeometry);
|
saveValue("main_window_geometry",mMainWindowGeometry);
|
||||||
saveValue("bottom_panel_index",mBottomPanelIndex);
|
saveValue("bottom_panel_index",mBottomPanelIndex);
|
||||||
|
@ -5707,6 +5719,8 @@ void Settings::UI::doSave()
|
||||||
|
|
||||||
void Settings::UI::doLoad()
|
void Settings::UI::doLoad()
|
||||||
{
|
{
|
||||||
|
mOpenEditorsWhenReplace=boolValue("open_editor_when_batch_replace",true);
|
||||||
|
|
||||||
mMainWindowState = value("main_window_state",QByteArray()).toByteArray();
|
mMainWindowState = value("main_window_state",QByteArray()).toByteArray();
|
||||||
mMainWindowGeometry = value("main_window_geometry",QByteArray()).toByteArray();
|
mMainWindowGeometry = value("main_window_geometry",QByteArray()).toByteArray();
|
||||||
mBottomPanelIndex = intValue("bottom_panel_index",0);
|
mBottomPanelIndex = intValue("bottom_panel_index",0);
|
||||||
|
|
|
@ -1122,7 +1122,11 @@ public:
|
||||||
int problemOrder() const;
|
int problemOrder() const;
|
||||||
void setProblemOrder(int newProblemOrder);
|
void setProblemOrder(int newProblemOrder);
|
||||||
|
|
||||||
|
bool openEditorsWhenReplace() const;
|
||||||
|
void setOpenEditorsWhenReplace(bool newOpenEditorsWhenReplace);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool mOpenEditorsWhenReplace;
|
||||||
QByteArray mMainWindowState;
|
QByteArray mMainWindowState;
|
||||||
QByteArray mMainWindowGeometry;
|
QByteArray mMainWindowGeometry;
|
||||||
int mBottomPanelIndex;
|
int mBottomPanelIndex;
|
||||||
|
|
|
@ -4940,6 +4940,10 @@
|
||||||
<source>Newline</source>
|
<source>Newline</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Open file in editors</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>NewClassDialog</name>
|
<name>NewClassDialog</name>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -4753,6 +4753,10 @@
|
||||||
<source>Newline</source>
|
<source>Newline</source>
|
||||||
<translation type="unfinished"></translation>
|
<translation type="unfinished"></translation>
|
||||||
</message>
|
</message>
|
||||||
|
<message>
|
||||||
|
<source>Open file in editors</source>
|
||||||
|
<translation type="unfinished"></translation>
|
||||||
|
</message>
|
||||||
</context>
|
</context>
|
||||||
<context>
|
<context>
|
||||||
<name>NewClassDialog</name>
|
<name>NewClassDialog</name>
|
||||||
|
|
|
@ -163,6 +163,8 @@ void SearchInFileDialog::doSearch(bool replace)
|
||||||
}
|
}
|
||||||
pMainWindow->searchResultModel()->notifySearchResultsUpdated();
|
pMainWindow->searchResultModel()->notifySearchResultsUpdated();
|
||||||
} else if (ui->rbProject->isChecked()) {
|
} else if (ui->rbProject->isChecked()) {
|
||||||
|
if (!pMainWindow->project())
|
||||||
|
return;
|
||||||
PSearchResults results = pMainWindow->searchResultModel()->addSearchResults(
|
PSearchResults results = pMainWindow->searchResultModel()->addSearchResults(
|
||||||
keyword,
|
keyword,
|
||||||
mSearchOptions,
|
mSearchOptions,
|
||||||
|
@ -277,6 +279,9 @@ std::shared_ptr<SearchResultTreeItem> SearchInFileDialog::batchFindInEditor(QSyn
|
||||||
void SearchInFileDialog::showEvent(QShowEvent *event)
|
void SearchInFileDialog::showEvent(QShowEvent *event)
|
||||||
{
|
{
|
||||||
QDialog::showEvent(event);
|
QDialog::showEvent(event);
|
||||||
|
ui->rbProject->setEnabled(pMainWindow->project()!=nullptr);
|
||||||
|
if (ui->rbProject->isChecked() && !ui->rbProject->isEnabled())
|
||||||
|
ui->rbCurrentFile->setChecked(true);
|
||||||
if (pSettings->environment().language()=="zh_CN") {
|
if (pSettings->environment().language()=="zh_CN") {
|
||||||
ui->txtRegExpHelp->setText(
|
ui->txtRegExpHelp->setText(
|
||||||
QString("<html><head/><body><p><a href=\"%1\"><span style=\" text-decoration: underline; color:#0000ff;\">(?)</span></a></p></body></html>")
|
QString("<html><head/><body><p><a href=\"%1\"><span style=\" text-decoration: underline; color:#0000ff;\">(?)</span></a></p></body></html>")
|
||||||
|
|
|
@ -4373,7 +4373,6 @@ void QSynEdit::doUndoItem()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ChangeReason::ReplaceLine:
|
case ChangeReason::ReplaceLine:
|
||||||
qDebug()<<item->changeStartPos().line<<item->changeText();
|
|
||||||
mRedoList->addRedo(
|
mRedoList->addRedo(
|
||||||
item->changeReason(),
|
item->changeReason(),
|
||||||
item->changeStartPos(),
|
item->changeStartPos(),
|
||||||
|
|
Loading…
Reference in New Issue