Commit 1fa583d9 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Rename method + const'ify variables

parent f16f822f
Pipeline #138878 passed with stages
in 2 minutes and 56 seconds
......@@ -23,7 +23,7 @@ int FindUtils::replaceAll(QTextDocument *document, const TextFindWidget *findWid
// Ignoring FindBackward when replacing all
QTextDocument::FindFlags flags = findWidget->searchOptions() & ~QTextDocument::FindBackward;
if (findWidget->isRegularExpression()) {
c = document->find(findWidget->searchRegExp(), c, flags);
c = document->find(findWidget->searchRegularExpression(), c, flags);
} else {
c = document->find(findWidget->searchText(), c, flags);
}
......
......@@ -144,7 +144,7 @@ void TextEditFindBarBase::messageInfo(bool backward, bool isAutoSearch, bool fou
bool TextEditFindBarBase::searchText(bool backward, bool isAutoSearch)
{
mLastSearchStr = mFindWidget->searchText();
mLastSearchRegExp = mFindWidget->searchRegExp();
mLastSearchRegExp = mFindWidget->searchRegularExpression();
QTextDocument::FindFlags searchOptions = mFindWidget->searchOptions();
if (backward) {
searchOptions |= QTextDocument::FindBackward;
......@@ -183,7 +183,7 @@ void TextEditFindBarBase::slotUpdateSearchOptions()
{
const QTextDocument::FindFlags searchOptions = mFindWidget->searchOptions();
mLastSearchStr = mFindWidget->searchText();
mLastSearchRegExp = mFindWidget->searchRegExp();
mLastSearchRegExp = mFindWidget->searchRegularExpression();
if (mFindWidget->isRegularExpression()) {
searchInDocument(mLastSearchRegExp, searchOptions);
} else {
......
......@@ -20,6 +20,9 @@ using namespace KPIMTextEdit;
TextReplaceWidget::TextReplaceWidget(QWidget *parent)
: QWidget(parent)
, mReplace(new QLineEdit(this))
, mReplaceBtn(new QPushButton(i18n("Replace"), this))
, mReplaceAllBtn(new QPushButton(i18n("Replace All"), this))
{
auto lay = new QHBoxLayout(this);
auto label = new QLabel(i18nc("Replace text", "Replace:"), this);
......@@ -28,15 +31,12 @@ TextReplaceWidget::TextReplaceWidget(QWidget *parent)
const int marg2 = lay->contentsMargins().right();
lay->setContentsMargins(marg1, 0, marg2, 0);
mReplace = new QLineEdit(this);
mReplace->setClearButtonEnabled(true);
lay->addWidget(mReplace);
mReplaceBtn = new QPushButton(i18n("Replace"), this);
connect(mReplaceBtn, &QPushButton::clicked, this, &TextReplaceWidget::replaceText);
lay->addWidget(mReplaceBtn);
mReplaceAllBtn = new QPushButton(i18n("Replace All"), this);
connect(mReplaceAllBtn, &QPushButton::clicked, this, &TextReplaceWidget::replaceAllText);
lay->addWidget(mReplaceAllBtn);
}
......@@ -56,6 +56,7 @@ void TextReplaceWidget::slotSearchStringEmpty(bool isEmpty)
TextFindWidget::TextFindWidget(QWidget *parent)
: QWidget(parent)
, mSearch(new QLineEdit(this))
{
auto lay = new QHBoxLayout(this);
const int marg1 = lay->contentsMargins().left();
......@@ -64,7 +65,6 @@ TextFindWidget::TextFindWidget(QWidget *parent)
auto label = new QLabel(i18nc("Find text", "F&ind:"), this);
lay->addWidget(label);
mSearch = new QLineEdit(this);
mSearch->setToolTip(i18n("Text to search for"));
mSearch->setClearButtonEnabled(true);
label->setBuddy(mSearch);
......@@ -157,7 +157,7 @@ QString TextFindWidget::searchText() const
return mSearch->text();
}
QRegularExpression TextFindWidget::searchRegExp() const
QRegularExpression TextFindWidget::searchRegularExpression() const
{
QRegularExpression reg;
if (!mCaseSensitiveAct->isChecked()) {
......
......@@ -28,7 +28,7 @@ public:
void setFoundMatch(bool match);
Q_REQUIRED_RESULT bool isRegularExpression() const;
Q_REQUIRED_RESULT QRegularExpression searchRegExp() const;
Q_REQUIRED_RESULT QRegularExpression searchRegularExpression() const;
Q_REQUIRED_RESULT QString searchText() const;
......@@ -44,7 +44,7 @@ Q_SIGNALS:
void searchStringEmpty(bool);
private:
QLineEdit *mSearch = nullptr;
QLineEdit *const mSearch;
QAction *mCaseSensitiveAct = nullptr;
QAction *mWholeWordAct = nullptr;
QAction *mRegExpAct = nullptr;
......@@ -70,8 +70,8 @@ Q_SIGNALS:
void replaceAllText();
private:
QLineEdit *mReplace = nullptr;
QPushButton *mReplaceBtn = nullptr;
QPushButton *mReplaceAllBtn = nullptr;
QLineEdit *const mReplace;
QPushButton *const mReplaceBtn;
QPushButton *const mReplaceAllBtn;
};
}
......@@ -76,7 +76,7 @@ void PlainTextEditFindBar::slotReplaceText()
{
if (d->mView->textCursor().hasSelection()) {
if (mFindWidget->isRegularExpression()) {
if (d->mView->textCursor().selectedText().contains(mFindWidget->searchRegExp())) {
if (d->mView->textCursor().selectedText().contains(mFindWidget->searchRegularExpression())) {
d->mView->textCursor().insertText(mReplaceWidget->replaceLineEdit()->text());
// search next after replace text.
searchText(false, false);
......
......@@ -76,7 +76,7 @@ void RichTextEditFindBar::slotReplaceText()
// FIXME!
if (d->mView->textCursor().hasSelection()) {
if (mFindWidget->isRegularExpression()) {
if (d->mView->textCursor().selectedText().contains(mFindWidget->searchRegExp())) {
if (d->mView->textCursor().selectedText().contains(mFindWidget->searchRegularExpression())) {
d->mView->textCursor().insertText(mReplaceWidget->replaceLineEdit()->text());
// search next after replace text.
searchText(false, false);
......
Markdown is supported
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