Commit 184d7bf0 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Rename actions + minor optimization

parent 655e4dde
Pipeline #143549 passed with stages
in 2 minutes and 36 seconds
......@@ -31,7 +31,7 @@ QTextDocument::FindFlags FindUtils::convertTextEditFindFlags(TextEditFindBarBase
return flags;
}
int FindUtils::replaceAll(QTextDocument *document, const TextFindWidget *findWidget, const TextReplaceWidget *replaceWidget)
int FindUtils::replaceAll(QTextDocument *document, const TextFindWidget *findWidget, const QString &replaceWidget)
{
QTextCursor c(document);
c.beginEditBlock();
......@@ -46,7 +46,7 @@ int FindUtils::replaceAll(QTextDocument *document, const TextFindWidget *findWid
}
if (!c.isNull()) {
// find() selects found text, and insertText() replaces selection
c.insertText(replaceWidget->replaceLineEdit()->text());
c.insertText(replaceWidget);
count++;
}
}
......
......@@ -27,7 +27,7 @@ namespace FindUtils
*
* @return number of replacements done
*/
Q_REQUIRED_RESULT int replaceAll(QTextDocument *document, const TextFindWidget *findWidget, const TextReplaceWidget *replaceWidget);
Q_REQUIRED_RESULT int replaceAll(QTextDocument *document, const TextFindWidget *findWidget, const QString &replaceWidget);
Q_REQUIRED_RESULT QString normalize(QStringView str);
Q_REQUIRED_RESULT QChar normalize(QChar c);
......
......@@ -98,8 +98,8 @@ TextFindWidget::TextFindWidget(QWidget *parent)
mWholeWordAct = optionsMenu->addAction(i18n("Whole word"));
mWholeWordAct->setCheckable(true);
mRegExpAct = optionsMenu->addAction(i18n("Regular Expression"));
mRegExpAct->setCheckable(true);
mRegularExpressionAct = optionsMenu->addAction(i18n("Regular Expression"));
mRegularExpressionAct->setCheckable(true);
mRespectDiacriticAct = optionsMenu->addAction(i18n("Respect Diacritic and Accents"));
mRespectDiacriticAct->setCheckable(true);
......@@ -112,7 +112,7 @@ TextFindWidget::TextFindWidget(QWidget *parent)
connect(mCaseSensitiveAct, &QAction::toggled, this, &TextFindWidget::updateSearchOptions);
connect(mWholeWordAct, &QAction::toggled, this, &TextFindWidget::updateSearchOptions);
connect(mRespectDiacriticAct, &QAction::toggled, this, &TextFindWidget::updateSearchOptions);
connect(mRegExpAct, &QAction::toggled, this, &TextFindWidget::updateSearchOptions);
connect(mRegularExpressionAct, &QAction::toggled, this, &TextFindWidget::updateSearchOptions);
connect(mSearch, &QLineEdit::textChanged, this, &TextFindWidget::slotAutoSearch);
connect(mSearch, &QLineEdit::returnPressed, this, &TextFindWidget::findNext);
}
......@@ -161,7 +161,7 @@ QLineEdit *TextFindWidget::searchLineEdit() const
bool TextFindWidget::isRegularExpression() const
{
return mRegExpAct->isChecked();
return mRegularExpressionAct->isChecked();
}
QString TextFindWidget::searchText() const
......
......@@ -49,7 +49,7 @@ private:
QLineEdit *const mSearch;
QAction *mCaseSensitiveAct = nullptr;
QAction *mWholeWordAct = nullptr;
QAction *mRegExpAct = nullptr;
QAction *mRegularExpressionAct = nullptr;
QAction *mRespectDiacriticAct = nullptr;
QPushButton *mFindPrevBtn = nullptr;
......
......@@ -110,6 +110,6 @@ void PlainTextEditFindBar::slotReplaceText()
void PlainTextEditFindBar::slotReplaceAllText()
{
const int count = FindUtils::replaceAll(d->mView->document(), mFindWidget, mReplaceWidget);
const int count = FindUtils::replaceAll(d->mView->document(), mFindWidget, mReplaceWidget->replaceLineEdit()->text());
Q_EMIT displayMessageIndicator(i18np("%1 replacement made", "%1 replacements made", count));
}
......@@ -101,6 +101,6 @@ void RichTextEditFindBar::slotReplaceText()
void RichTextEditFindBar::slotReplaceAllText()
{
const int count = FindUtils::replaceAll(d->mView->document(), mFindWidget, mReplaceWidget);
const int count = FindUtils::replaceAll(d->mView->document(), mFindWidget, mReplaceWidget->replaceLineEdit()->text());
Q_EMIT displayMessageIndicator(i18np("%1 replacement made", "%1 replacements made", count));
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment