- 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);
|
||||||
editor.document()->saveToFile(file,ENCODING_AUTO_DETECT,
|
try {
|
||||||
pSettings->editor().defaultEncoding(),
|
editor.document()->saveToFile(file,ENCODING_AUTO_DETECT,
|
||||||
realEncoding);
|
pSettings->editor().defaultEncoding(),
|
||||||
|
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,7 +6201,12 @@ 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) {
|
||||||
ui->btnSearchAgain->setEnabled(true);
|
if (results->searchType==SearchType::Search
|
||||||
|
&& results->scope==SearchFileScope::wholeProject
|
||||||
|
&& pMainWindow->project()==nullptr)
|
||||||
|
ui->btnSearchAgain->setEnabled(false);
|
||||||
|
else
|
||||||
|
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,34 +7717,79 @@ 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 (!editor) {
|
if (item->selected) {
|
||||||
QMessageBox::critical(this,
|
selections.push_back(item);
|
||||||
tr("Replace Error"),
|
}
|
||||||
tr("Can't open file '%1' for replace!").arg(file->filename));
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
editor->clearSelection();
|
if (selections.isEmpty())
|
||||||
editor->addGroupBreak();
|
continue;
|
||||||
editor->beginUndoBlock();
|
Editor* editor = nullptr;
|
||||||
for (int i=file->results.count()-1;i>=0;i--) {
|
if (ui->chkOpenFileInEditors->isChecked()) {
|
||||||
const PSearchResultTreeItem& item = file->results[i];
|
editor = openFile(file->filename);
|
||||||
if (!item->selected)
|
if (!editor) {
|
||||||
continue;
|
QMessageBox::critical(this,
|
||||||
|
tr("Replace Error"),
|
||||||
|
tr("Can't open file '%1' for replace!").arg(file->filename));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
editor = mEditorList->getOpenedEditorByFilename(file->filename);
|
||||||
|
}
|
||||||
|
bool needSave=false;
|
||||||
|
std::shared_ptr<Editor> pEditor;
|
||||||
|
if (editor) {
|
||||||
|
editor->clearSelection();
|
||||||
|
editor->addGroupBreak();
|
||||||
|
editor->beginUndoBlock();
|
||||||
|
} else {
|
||||||
|
needSave=true;
|
||||||
|
pEditor = std::make_shared<Editor>(nullptr);
|
||||||
|
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!"));
|
||||||
editor->endUndoBlock();
|
if (!needSave)
|
||||||
|
editor->endUndoBlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
line.remove(item->start-1,results->keyword.length());
|
line.remove(item->start-1,results->keyword.length());
|
||||||
line.insert(item->start-1, newWord);
|
line.insert(item->start-1, newWord);
|
||||||
editor->replaceLine(item->line,line);
|
editor->replaceLine(item->line,line);
|
||||||
}
|
}
|
||||||
editor->endUndoBlock();
|
if (!needSave) {
|
||||||
|
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