- change: Merge search and replace to one dialog.
- fix: Search dialog's "Match whole word" option doesn't work with "Use Regular expresion". - fix:Search dialog's "Close after search" option doesn't work. - change: Fill the search dialog with the current selection if it's available.
This commit is contained in:
parent
78739e388a
commit
d3fde7ab53
4
NEWS.md
4
NEWS.md
|
@ -21,6 +21,10 @@ Red Panda C++ Version 2.15
|
|||
- enhancement: Generate asm with/without SEH directives.
|
||||
- enhancement: Generate asm using intel style/att style.
|
||||
- enhancement: make description for jump/cmov/setb instructions more explicit. (used for signed or unsigned)
|
||||
- fix: Lead and end spaces in search/replace text is wrongly trimmed.
|
||||
- change: Merge search and replace to one dialog.
|
||||
- fix: Search dialog's "Match whole word" option doesn't work with "Use Regular expresion".
|
||||
- fix:Search dialog's "Close after search" option doesn't work.
|
||||
|
||||
Red Panda C++ Version 2.14
|
||||
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
QT += core gui printsupport network svg xml
|
||||
|
||||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
|
||||
QT += core gui printsupport network svg xml widgets
|
||||
|
||||
CONFIG += c++17
|
||||
CONFIG += nokey
|
||||
|
@ -213,7 +211,6 @@ SOURCES += \
|
|||
widgets/projectalreadyopendialog.cpp \
|
||||
widgets/qconsole.cpp \
|
||||
widgets/qpatchedcombobox.cpp \
|
||||
widgets/replacedialog.cpp \
|
||||
widgets/searchdialog.cpp \
|
||||
widgets/searchinfiledialog.cpp \
|
||||
widgets/searchresultview.cpp \
|
||||
|
@ -349,7 +346,6 @@ HEADERS += \
|
|||
widgets/projectalreadyopendialog.h \
|
||||
widgets/qconsole.h \
|
||||
widgets/qpatchedcombobox.h \
|
||||
widgets/replacedialog.h \
|
||||
widgets/searchdialog.h \
|
||||
widgets/searchinfiledialog.h \
|
||||
widgets/searchresultview.h \
|
||||
|
@ -417,7 +413,6 @@ FORMS += \
|
|||
widgets/newtemplatedialog.ui \
|
||||
widgets/ojproblempropertywidget.ui \
|
||||
widgets/projectalreadyopendialog.ui \
|
||||
widgets/replacedialog.ui \
|
||||
widgets/searchdialog.ui \
|
||||
widgets/searchinfiledialog.ui \
|
||||
widgets/signalmessagedialog.ui
|
||||
|
|
|
@ -1902,10 +1902,10 @@ void Editor::onTooltipTimer()
|
|||
}
|
||||
break;
|
||||
case TipType::Identifier:
|
||||
if (pMainWindow->debugger()->executing() && !pMainWindow->debugger()->inferiorRunning())
|
||||
if (pMainWindow->debugger()->executing() && !pMainWindow->debugger()->inferiorRunning()) {
|
||||
if (mParentPageControl)
|
||||
s = getWordAtPosition(this,p, pBeginPos,pEndPos, WordPurpose::wpEvaluation); // debugging
|
||||
else if (!mCompletionPopup->isVisible()
|
||||
} else if (!mCompletionPopup->isVisible()
|
||||
&& !mHeaderCompletionPopup->isVisible()) {
|
||||
expression = getExpressionAtPosition(p);
|
||||
s = expression.join(""); // information during coding
|
||||
|
|
|
@ -114,7 +114,6 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
mFullInitialized{false},
|
||||
mSearchInFilesDialog{nullptr},
|
||||
mSearchDialog{nullptr},
|
||||
mReplaceDialog{nullptr},
|
||||
mQuitting{false},
|
||||
mClosingProject{false},
|
||||
mCheckSyntaxInBack{false},
|
||||
|
@ -1070,8 +1069,6 @@ int MainWindow::calIconSize(const QString &fontName, int fontPointSize)
|
|||
|
||||
void MainWindow::hideAllSearchDialogs()
|
||||
{
|
||||
if (mReplaceDialog)
|
||||
mReplaceDialog->hide();
|
||||
if (mSearchDialog)
|
||||
mSearchDialog->hide();
|
||||
if (mSearchInFilesDialog)
|
||||
|
@ -1084,12 +1081,6 @@ void MainWindow::prepareSearchDialog()
|
|||
mSearchDialog = new SearchDialog(this);
|
||||
}
|
||||
|
||||
void MainWindow::prepareReplaceDialog()
|
||||
{
|
||||
if (!mReplaceDialog)
|
||||
mReplaceDialog = new ReplaceDialog(this);
|
||||
}
|
||||
|
||||
void MainWindow::prepareSearchInFilesDialog()
|
||||
{
|
||||
if (mSearchInFilesDialog==nullptr) {
|
||||
|
@ -6296,10 +6287,12 @@ void MainWindow::on_actionFind_triggered()
|
|||
Editor *e = mEditorList->getEditor();
|
||||
if (!e)
|
||||
return;
|
||||
QString s = e->wordAtCursor();
|
||||
hideAllSearchDialogs();
|
||||
prepareSearchDialog();
|
||||
mSearchDialog->find(s);
|
||||
if (e->selAvail())
|
||||
mSearchDialog->find(e->selText());
|
||||
else
|
||||
mSearchDialog->find(e->wordAtCursor());
|
||||
}
|
||||
|
||||
void MainWindow::on_actionFind_in_files_triggered()
|
||||
|
@ -6308,8 +6301,10 @@ void MainWindow::on_actionFind_in_files_triggered()
|
|||
prepareSearchInFilesDialog();
|
||||
Editor *e = mEditorList->getEditor();
|
||||
if (e) {
|
||||
QString s = e->wordAtCursor();
|
||||
mSearchInFilesDialog->findInFiles(s);
|
||||
if (e->selAvail())
|
||||
mSearchInFilesDialog->findInFiles(e->selText());
|
||||
else
|
||||
mSearchInFilesDialog->findInFiles(e->wordAtCursor());
|
||||
} else {
|
||||
mSearchInFilesDialog->findInFiles("");
|
||||
}
|
||||
|
@ -6321,10 +6316,12 @@ void MainWindow::on_actionReplace_triggered()
|
|||
if (!e)
|
||||
return;
|
||||
|
||||
QString s = e->wordAtCursor();
|
||||
hideAllSearchDialogs();
|
||||
prepareReplaceDialog();
|
||||
mReplaceDialog->replace(s);
|
||||
prepareSearchDialog();
|
||||
if (e->selAvail())
|
||||
mSearchDialog->replace(e->selText());
|
||||
else
|
||||
mSearchDialog->replace(e->wordAtCursor());
|
||||
}
|
||||
|
||||
void MainWindow::on_actionFind_Next_triggered()
|
||||
|
|
|
@ -67,7 +67,6 @@ class CPUDialog;
|
|||
class QPlainTextEdit;
|
||||
class SearchInFileDialog;
|
||||
class SearchDialog;
|
||||
class ReplaceDialog;
|
||||
class Project;
|
||||
struct ProjectModelNode;
|
||||
class ProjectUnit;
|
||||
|
@ -276,7 +275,6 @@ private:
|
|||
int calIconSize(const QString &fontName, int fontPointSize);
|
||||
void hideAllSearchDialogs();
|
||||
void prepareSearchDialog();
|
||||
void prepareReplaceDialog();
|
||||
void prepareSearchInFilesDialog();
|
||||
void prepareProjectForCompile();
|
||||
void closeProject(bool refreshEditor);
|
||||
|
@ -818,7 +816,6 @@ private:
|
|||
CPUDialog *mCPUDialog;
|
||||
SearchInFileDialog *mSearchInFilesDialog;
|
||||
SearchDialog *mSearchDialog;
|
||||
ReplaceDialog *mReplaceDialog;
|
||||
bool mQuitting;
|
||||
bool mClosingProject;
|
||||
QElapsedTimer mParserTimer;
|
||||
|
|
|
@ -6754,55 +6754,55 @@
|
|||
<name>ReplaceDialog</name>
|
||||
<message>
|
||||
<source>Replace</source>
|
||||
<translation type="unfinished">Substituir</translation>
|
||||
<translation type="obsolete">Substituir</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Text to Find:</source>
|
||||
<translation type="unfinished">Texto a procurar:</translation>
|
||||
<translation type="obsolete">Texto a procurar:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Replace with:</source>
|
||||
<translation type="unfinished">Substituir por:</translation>
|
||||
<translation type="obsolete">Substituir por:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Scope:</source>
|
||||
<translation type="unfinished">Escopo:</translation>
|
||||
<translation type="obsolete">Escopo:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Global</source>
|
||||
<translation type="unfinished">Global</translation>
|
||||
<translation type="obsolete">Global</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Selection</source>
|
||||
<translation type="unfinished">Seleção</translation>
|
||||
<translation type="obsolete">Seleção</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Origin:</source>
|
||||
<translation type="unfinished">Origem:</translation>
|
||||
<translation type="obsolete">Origem:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>From cursor</source>
|
||||
<translation type="unfinished">A partir do cursor</translation>
|
||||
<translation type="obsolete">A partir do cursor</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Entire scope</source>
|
||||
<translation type="unfinished">Escopo inteiro</translation>
|
||||
<translation type="obsolete">Escopo inteiro</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Options:</source>
|
||||
<translation type="unfinished">Opções:</translation>
|
||||
<translation type="obsolete">Opções:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Whole words only</source>
|
||||
<translation type="unfinished">Apenas palavras inteiras</translation>
|
||||
<translation type="obsolete">Apenas palavras inteiras</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Wrap Around</source>
|
||||
<translation type="unfinished">Wrap Around</translation>
|
||||
<translation type="obsolete">Wrap Around</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Regular Expression</source>
|
||||
<translation type="unfinished">Expressão regular</translation>
|
||||
<translation type="obsolete">Expressão regular</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Prompt on replace</source>
|
||||
|
@ -6810,43 +6810,27 @@
|
|||
</message>
|
||||
<message>
|
||||
<source>Case Sensitive</source>
|
||||
<translation type="unfinished">Sensibilidade a maiúsculas/minúsculas</translation>
|
||||
<translation type="obsolete">Sensibilidade a maiúsculas/minúsculas</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Find Previous</source>
|
||||
<translation type="unfinished">Procurar anterior</translation>
|
||||
<translation type="obsolete">Procurar anterior</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Find Next</source>
|
||||
<translation type="unfinished">Procurar outro</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Replace All</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Close</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Beginning of file has been reached. </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Do you want to continue from file's end?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
<translation type="obsolete">Procurar outro</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>End of file has been reached. </source>
|
||||
<translation type="unfinished">Encontrado fim de arquivo.</translation>
|
||||
<translation type="obsolete">Encontrado fim de arquivo.</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Do you want to continue from file's beginning?</source>
|
||||
<translation type="unfinished">Quer continuar a partir do início do arquivo?</translation>
|
||||
<translation type="obsolete">Quer continuar a partir do início do arquivo?</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Continue Search</source>
|
||||
<translation type="unfinished">Continuar a procura</translation>
|
||||
<translation type="obsolete">Continuar a procura</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
|
@ -6861,7 +6845,7 @@
|
|||
</message>
|
||||
<message>
|
||||
<source>Replace with:</source>
|
||||
<translation type="vanished">Substituir por:</translation>
|
||||
<translation>Substituir por:</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Options:</source>
|
||||
|
@ -6949,7 +6933,7 @@
|
|||
</message>
|
||||
<message>
|
||||
<source>Replace</source>
|
||||
<translation type="vanished">Substituir</translation>
|
||||
<translation>Substituir</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Find in files</source>
|
||||
|
@ -7003,6 +6987,14 @@
|
|||
<source>Do you want to continue from file's end?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Replace All</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Search</source>
|
||||
<translation type="unfinished">Procurar</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SearchInFileDialog</name>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -6331,101 +6331,6 @@
|
|||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>ReplaceDialog</name>
|
||||
<message>
|
||||
<source>Replace</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Text to Find:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Replace with:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Scope:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Global</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Selection</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Origin:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>From cursor</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Entire scope</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Options:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Whole words only</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Wrap Around</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Regular Expression</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Case Sensitive</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Find Previous</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Find Next</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Replace All</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Close</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Beginning of file has been reached. </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Do you want to continue from file's end?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>End of file has been reached. </source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Do you want to continue from file's beginning?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Continue Search</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SearchDialog</name>
|
||||
<message>
|
||||
|
@ -6516,6 +6421,22 @@
|
|||
<source>Do you want to continue from file's end?</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Replace with:</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Replace</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Replace All</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Search</source>
|
||||
<translation type="unfinished"></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>SearchInFileDialog</name>
|
||||
|
|
|
@ -530,7 +530,7 @@ QString getSizeString(int size)
|
|||
}
|
||||
|
||||
void saveComboHistory(QComboBox* cb,const QString& text) {
|
||||
QString s = text.trimmed();
|
||||
QString s = text;
|
||||
if (s.isEmpty())
|
||||
return;
|
||||
int i = cb->findText(s);
|
||||
|
|
|
@ -15,9 +15,20 @@ SearchDialog::SearchDialog(QWidget *parent) :
|
|||
ui(new Ui::SearchDialog),
|
||||
mSearchOptions()
|
||||
{
|
||||
setWindowFlag(Qt::WindowContextHelpButtonHint,false);
|
||||
ui->setupUi(this);
|
||||
mBasicSearchEngine= std::make_shared<QSynedit::BasicSearcher>();
|
||||
mRegexSearchEngine= std::make_shared<QSynedit::RegexSearcher>();
|
||||
mTabBar=new QTabBar(this);
|
||||
mTabBar->setExpanding(false);
|
||||
mSearchTabIdx = mTabBar->addTab(tr("Search"));
|
||||
mReplaceTabIdx = mTabBar->addTab(tr("Replace"));
|
||||
ui->dialogLayout->insertWidget(0,mTabBar);
|
||||
|
||||
mTabBar->setCurrentIndex(mSearchTabIdx);
|
||||
connect(mTabBar, &QTabBar::currentChanged, this,
|
||||
&SearchDialog::onTabBarCurrentChanged);
|
||||
onTabBarCurrentChanged(mSearchTabIdx);
|
||||
mBasicSearchEngine = std::make_shared<QSynedit::BasicSearcher>();
|
||||
mRegexSearchEngine = std::make_shared<QSynedit::RegexSearcher>();
|
||||
}
|
||||
|
||||
SearchDialog::~SearchDialog()
|
||||
|
@ -27,62 +38,39 @@ SearchDialog::~SearchDialog()
|
|||
|
||||
void SearchDialog::find(const QString &text)
|
||||
{
|
||||
mTabBar->setCurrentIndex(mSearchTabIdx);
|
||||
ui->cbFind->setCurrentText(text);
|
||||
ui->cbFind->setFocus();
|
||||
show();
|
||||
}
|
||||
|
||||
void SearchDialog::replace(const QString &text)
|
||||
{
|
||||
mTabBar->setCurrentIndex(mReplaceTabIdx);
|
||||
ui->cbFind->setCurrentText(text);
|
||||
ui->cbFind->setFocus();
|
||||
//ui->cbReplace->setCurrentText("");
|
||||
show();
|
||||
}
|
||||
|
||||
void SearchDialog::findNext()
|
||||
{
|
||||
doSearch(false);
|
||||
if (ui->chkCloseAfterSearch)
|
||||
if (ui->chkCloseAfterSearch->isChecked())
|
||||
close();
|
||||
}
|
||||
|
||||
void SearchDialog::findPrevious()
|
||||
{
|
||||
doSearch(true);
|
||||
if (ui->chkCloseAfterSearch)
|
||||
if (ui->chkCloseAfterSearch->isChecked())
|
||||
close();
|
||||
}
|
||||
|
||||
void SearchDialog::doSearch(bool backward)
|
||||
{
|
||||
saveComboHistory(ui->cbFind,ui->cbFind->currentText());
|
||||
|
||||
mSearchOptions&=0;
|
||||
|
||||
// Apply options
|
||||
if (backward) {
|
||||
mSearchOptions.setFlag(QSynedit::ssoBackwards);
|
||||
}
|
||||
|
||||
if (ui->chkRegExp->isChecked()) {
|
||||
mSearchOptions.setFlag(QSynedit::ssoRegExp);
|
||||
}
|
||||
if (ui->chkCaseSensetive->isChecked()) {
|
||||
mSearchOptions.setFlag(QSynedit::ssoMatchCase);
|
||||
}
|
||||
if (ui->chkWholeWord->isChecked()) {
|
||||
mSearchOptions.setFlag(QSynedit::ssoWholeWord);
|
||||
}
|
||||
if (ui->chkWrapAround->isChecked()) {
|
||||
mSearchOptions.setFlag(QSynedit::ssoWrapAround);
|
||||
}
|
||||
|
||||
// Apply scope, when enabled
|
||||
if (ui->grpScope->isEnabled()) {
|
||||
if (ui->rbSelection->isChecked()) {
|
||||
mSearchOptions.setFlag(QSynedit::ssoSelectedOnly);
|
||||
}
|
||||
}
|
||||
|
||||
// Apply origin, when enabled
|
||||
if (ui->grpOrigin->isEnabled()) {
|
||||
if (ui->rbEntireScope->isChecked()) {
|
||||
mSearchOptions.setFlag(QSynedit::ssoEntireScope);
|
||||
}
|
||||
}
|
||||
prepareOptions(backward);
|
||||
|
||||
Editor *editor = pMainWindow->editorList()->getEditor();
|
||||
if (editor) {
|
||||
|
@ -130,10 +118,113 @@ void SearchDialog::doSearch(bool backward)
|
|||
}
|
||||
}
|
||||
|
||||
void SearchDialog::doReplace(bool replaceAll)
|
||||
{
|
||||
saveComboHistory(ui->cbFind,ui->cbFind->currentText());
|
||||
saveComboHistory(ui->cbReplace,ui->cbReplace->currentText());
|
||||
prepareOptions(false);
|
||||
Editor *editor = pMainWindow->editorList()->getEditor();
|
||||
if (editor) {
|
||||
QSynedit::PSynSearchBase searchEngine;
|
||||
if (mSearchOptions.testFlag(QSynedit::ssoRegExp)) {
|
||||
searchEngine = mRegexSearchEngine;
|
||||
} else {
|
||||
searchEngine = mBasicSearchEngine;
|
||||
}
|
||||
editor->searchReplace(
|
||||
ui->cbFind->currentText(),
|
||||
ui->cbReplace->currentText(),
|
||||
mSearchOptions,
|
||||
searchEngine,
|
||||
[&replaceAll](const QString& /*sSearch*/,
|
||||
const QString& /*sReplace*/, int /*Line*/, int /*ch*/, int /*wordLen*/){
|
||||
if (replaceAll) {
|
||||
return QSynedit::SearchAction::ReplaceAll;
|
||||
} else {
|
||||
return QSynedit::SearchAction::ReplaceAndExit;
|
||||
}
|
||||
},
|
||||
[this](){
|
||||
QString msg = tr("End of file has been reached. ")
|
||||
+tr("Do you want to continue from file's beginning?");
|
||||
QWidget *p;
|
||||
if (isVisible()) {
|
||||
p=this;
|
||||
} else {
|
||||
p=pMainWindow;
|
||||
}
|
||||
return QMessageBox::question(p,
|
||||
tr("Continue Search"),
|
||||
msg,
|
||||
QMessageBox::Yes|QMessageBox::No,
|
||||
QMessageBox::Yes) == QMessageBox::Yes;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void SearchDialog::prepareOptions(bool backward)
|
||||
{
|
||||
mSearchOptions&=0;
|
||||
|
||||
// Apply options
|
||||
if (backward) {
|
||||
mSearchOptions.setFlag(QSynedit::ssoBackwards);
|
||||
}
|
||||
|
||||
if (ui->chkRegExp->isChecked()) {
|
||||
mSearchOptions.setFlag(QSynedit::ssoRegExp);
|
||||
}
|
||||
if (ui->chkCaseSensetive->isChecked()) {
|
||||
mSearchOptions.setFlag(QSynedit::ssoMatchCase);
|
||||
}
|
||||
if (ui->chkWholeWord->isChecked()) {
|
||||
mSearchOptions.setFlag(QSynedit::ssoWholeWord);
|
||||
}
|
||||
if (ui->chkWrapAround->isChecked()) {
|
||||
mSearchOptions.setFlag(QSynedit::ssoWrapAround);
|
||||
}
|
||||
|
||||
// Apply scope, when enabled
|
||||
if (ui->grpScope->isEnabled()) {
|
||||
if (ui->rbSelection->isChecked()) {
|
||||
mSearchOptions.setFlag(QSynedit::ssoSelectedOnly);
|
||||
}
|
||||
}
|
||||
|
||||
// Apply origin, when enabled
|
||||
if (ui->grpOrigin->isEnabled()) {
|
||||
if (ui->rbEntireScope->isChecked()) {
|
||||
mSearchOptions.setFlag(QSynedit::ssoEntireScope);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void SearchDialog::onTabBarCurrentChanged(int currentIndex)
|
||||
{
|
||||
if(currentIndex==mSearchTabIdx) {
|
||||
ui->lbReplace->setVisible(false);
|
||||
ui->cbReplace->setVisible(false);
|
||||
ui->chkCloseAfterSearch->setVisible(true);
|
||||
ui->btnReplace->setVisible(false);
|
||||
ui->btnReplaceAll->setVisible(false);
|
||||
} else {
|
||||
ui->lbReplace->setVisible(true);
|
||||
ui->cbReplace->setVisible(true);
|
||||
ui->chkCloseAfterSearch->setVisible(false);
|
||||
ui->btnReplace->setVisible(true);
|
||||
ui->btnReplaceAll->setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
void SearchDialog::on_cbFind_currentTextChanged(const QString &value)
|
||||
{
|
||||
ui->btnNext->setEnabled(!value.isEmpty());
|
||||
ui->btnPrevious->setEnabled(!value.isEmpty());
|
||||
ui->btnReplace->setEnabled(!value.isEmpty());
|
||||
ui->btnReplaceAll->setEnabled(!value.isEmpty());
|
||||
}
|
||||
|
||||
void SearchDialog::on_btnClose_clicked()
|
||||
|
@ -143,10 +234,23 @@ void SearchDialog::on_btnClose_clicked()
|
|||
|
||||
void SearchDialog::on_btnNext_clicked()
|
||||
{
|
||||
doSearch(false);
|
||||
findNext();
|
||||
}
|
||||
|
||||
void SearchDialog::on_btnPrevious_clicked()
|
||||
{
|
||||
doSearch(true);
|
||||
findPrevious();
|
||||
}
|
||||
|
||||
|
||||
void SearchDialog::on_btnReplace_clicked()
|
||||
{
|
||||
doReplace(false);
|
||||
}
|
||||
|
||||
|
||||
void SearchDialog::on_btnReplaceAll_clicked()
|
||||
{
|
||||
doReplace(true);
|
||||
close();
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define SEARCHDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QTabBar>
|
||||
#include <qsynedit/searcher/baseseacher.h>
|
||||
|
||||
namespace Ui {
|
||||
|
@ -16,22 +17,35 @@ public:
|
|||
explicit SearchDialog(QWidget *parent = nullptr);
|
||||
~SearchDialog();
|
||||
void find(const QString& text);
|
||||
void replace(const QString& text);
|
||||
void findNext();
|
||||
void findPrevious();
|
||||
private:
|
||||
void doSearch(bool backward);
|
||||
|
||||
void doReplace(bool replaceAll);
|
||||
|
||||
void prepareOptions(bool backward);
|
||||
private slots:
|
||||
void onTabBarCurrentChanged(int currentIndex);
|
||||
|
||||
void on_cbFind_currentTextChanged(const QString &arg1);
|
||||
|
||||
void on_btnClose_clicked();
|
||||
|
||||
void on_btnNext_clicked();
|
||||
|
||||
|
||||
void on_btnPrevious_clicked();
|
||||
|
||||
void on_btnReplace_clicked();
|
||||
|
||||
void on_btnReplaceAll_clicked();
|
||||
|
||||
private:
|
||||
Ui::SearchDialog *ui;
|
||||
QTabBar * mTabBar;
|
||||
int mSearchTabIdx;
|
||||
int mReplaceTabIdx;
|
||||
QSynedit::SearchOptions mSearchOptions;
|
||||
QSynedit::PSynSearchBase mBasicSearchEngine;
|
||||
QSynedit::PSynSearchBase mRegexSearchEngine;
|
||||
|
|
|
@ -13,7 +13,34 @@
|
|||
<property name="windowTitle">
|
||||
<string>Find</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<layout class="QVBoxLayout" name="dialogLayout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_5" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>5</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_4" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
|
@ -34,7 +61,7 @@
|
|||
</property>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<layout class="QGridLayout" name="gridLayout_3">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
|
@ -47,14 +74,14 @@
|
|||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lblFind">
|
||||
<property name="text">
|
||||
<string>Text to Find:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="cbFind">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
|
@ -70,6 +97,26 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="cbReplace">
|
||||
<property name="editable">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="insertPolicy">
|
||||
<enum>QComboBox::InsertAtTop</enum>
|
||||
</property>
|
||||
<property name="sizeAdjustPolicy">
|
||||
<enum>QComboBox::AdjustToContentsOnFirstShow</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbReplace">
|
||||
<property name="text">
|
||||
<string>Replace with:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
@ -179,12 +226,18 @@
|
|||
<property name="bottomMargin">
|
||||
<number>7</number>
|
||||
</property>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="chkWrapAround">
|
||||
<property name="text">
|
||||
<string>Wrap Around</string>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="txtRegExpHelp">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<property name="text">
|
||||
<string notr="true"><html><head/><body><p><a href="https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-language-quick-reference"><span style=" text-decoration: underline; color:#0000ff;">(?)</span></a></p></body></html></string>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
|
@ -202,6 +255,13 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="chkCloseAfterSearch">
|
||||
<property name="text">
|
||||
<string>Close after search</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="chkWholeWord">
|
||||
<property name="text">
|
||||
|
@ -216,28 +276,28 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLabel" name="txtRegExpHelp">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<item row="3" column="0">
|
||||
<widget class="QCheckBox" name="chkWrapAround">
|
||||
<property name="text">
|
||||
<string notr="true"><html><head/><body><p><a href="https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-language-quick-reference"><span style=" text-decoration: underline; color:#0000ff;">(?)</span></a></p></body></html></string>
|
||||
<string>Wrap Around</string>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QCheckBox" name="chkCloseAfterSearch">
|
||||
<property name="text">
|
||||
<string>Close after search</string>
|
||||
<item row="5" column="0">
|
||||
<spacer name="verticalSpacer_4">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
</widget>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -293,6 +353,20 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnReplace">
|
||||
<property name="text">
|
||||
<string>Replace</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnReplaceAll">
|
||||
<property name="text">
|
||||
<string>Replace All</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer_2">
|
||||
<property name="orientation">
|
||||
|
@ -334,6 +408,9 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
|
|
@ -41,4 +41,9 @@ void BaseSearcher::setOptions(const SearchOptions &options)
|
|||
{
|
||||
mOptions = options;
|
||||
}
|
||||
|
||||
bool BaseSearcher::isDelimitChar(const QChar& ch) const
|
||||
{
|
||||
return !(ch == '_' || ch.isLetterOrNumber());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,6 +49,8 @@ public:
|
|||
virtual QString replace(const QString& aOccurrence, const QString& aReplacement) = 0;
|
||||
SearchOptions options() const;
|
||||
virtual void setOptions(const SearchOptions &options);
|
||||
protected:
|
||||
bool isDelimitChar(const QChar& ch) const;
|
||||
|
||||
private:
|
||||
QString mPattern;
|
||||
|
|
|
@ -79,8 +79,4 @@ QString BasicSearcher::replace(const QString &, const QString &aReplacement)
|
|||
return aReplacement;
|
||||
}
|
||||
|
||||
bool BasicSearcher::isDelimitChar(QChar ch)
|
||||
{
|
||||
return !(ch == '_' || ch.isLetterOrNumber());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,8 +33,6 @@ public:
|
|||
int resultCount() override;
|
||||
int findAll(const QString &text) override;
|
||||
QString replace(const QString &aOccurrence, const QString &aReplacement) override;
|
||||
private:
|
||||
bool isDelimitChar(QChar ch);
|
||||
private:
|
||||
QList<int> mResults;
|
||||
};
|
||||
|
|
|
@ -53,9 +53,21 @@ int RegexSearcher::findAll(const QString &text)
|
|||
QRegularExpressionMatchIterator it = mRegex.globalMatch(text);
|
||||
while (it.hasNext()) {
|
||||
QRegularExpressionMatch match = it.next();
|
||||
if (options().testFlag(ssoWholeWord)) {
|
||||
int start = match.capturedStart();
|
||||
int end = match.capturedStart()+match.capturedLength();
|
||||
if (((start<=0) || isDelimitChar(text[start-1]))
|
||||
&&
|
||||
( (end>=text.length()) || isDelimitChar(text[end]) )
|
||||
) {
|
||||
mLengths.append(match.capturedLength());
|
||||
mResults.append(match.capturedStart());
|
||||
}
|
||||
} else {
|
||||
mLengths.append(match.capturedLength());
|
||||
mResults.append(match.capturedStart());
|
||||
}
|
||||
}
|
||||
return mResults.size();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue