Changeset View
Changeset View
Standalone View
Standalone View
src/texteditor/plaintexteditor/plaintexteditfindbar.cpp
Show All 13 Lines | 1 | /* | |||
---|---|---|---|---|---|
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to | ||
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | Boston, MA 02110-1301, USA. | 17 | Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #include "plaintexteditfindbar.h" | 20 | #include "plaintexteditfindbar.h" | ||
21 | #include "texteditor/commonwidget/textfindreplacewidget.h" | 21 | #include "texteditor/commonwidget/textfindreplacewidget.h" | ||
22 | #include "texteditor/commonwidget/findutils.h" | ||||
22 | 23 | | |||
23 | #include <KMessageBox> | 24 | #include <KMessageBox> | ||
24 | #include <KColorScheme> | 25 | #include <KColorScheme> | ||
26 | #include <KLocalizedString> | ||||
25 | 27 | | |||
26 | #include <QLineEdit> | 28 | #include <QLineEdit> | ||
27 | #include <QRegularExpression> | 29 | #include <QRegularExpression> | ||
28 | #include <QPlainTextEdit> | 30 | #include <QPlainTextEdit> | ||
29 | 31 | | |||
30 | using namespace KPIMTextEdit; | 32 | using namespace KPIMTextEdit; | ||
31 | 33 | | |||
32 | class KPIMTextEdit::PlainTextEditFindBarPrivate | 34 | class KPIMTextEdit::PlainTextEditFindBarPrivate | ||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Line(s) | 106 | if (d->mView->textCursor().hasSelection()) { | |||
117 | } | 119 | } | ||
118 | } else { | 120 | } else { | ||
119 | searchText(false, false); | 121 | searchText(false, false); | ||
120 | } | 122 | } | ||
121 | } | 123 | } | ||
122 | 124 | | |||
123 | void PlainTextEditFindBar::slotReplaceAllText() | 125 | void PlainTextEditFindBar::slotReplaceAllText() | ||
124 | { | 126 | { | ||
125 | QString newText; | 127 | const int count = FindUtils::replaceAll(d->mView->document(), mFindWidget, mReplaceWidget); | ||
126 | if (mFindWidget->isRegularExpression()) { | 128 | Q_EMIT displayMessageIndicator(i18np("%1 replacement made", "%1 replacements made", count)); | ||
127 | newText = d->mView->toPlainText().replace(mFindWidget->searchRegExp(), mReplaceWidget->replaceLineEdit()->text()); | | |||
128 | } else { | | |||
129 | newText = d->mView->toPlainText().replace(mFindWidget->searchText(), mReplaceWidget->replaceLineEdit()->text()); | | |||
130 | } | | |||
131 | d->mView->selectAll(); | | |||
132 | d->mView->insertPlainText(newText); | | |||
133 | } | 129 | } |