KTextWidgets
kreplace.cpp
121KReplace::KReplace(const QString &pattern, const QString &replacement, long options, QWidget *parent)
180 KMessageBox::information(parentWidget(), i18np("1 replacement done.", "%1 replacements done.", d->m_replacements));
184static int replaceHelper(QString &text, const QString &replacement, int index, long options, const QRegularExpressionMatch *match, int length)
223 d->index = KFind::find(d->text, d->pattern, d->index, d->options, &d->matchedLength, d->options & KFind::RegularExpression ? &d->m_match : nullptr);
238 replaceHelper(rep, d->m_replacement, 0, d->options, d->options & KFind::RegularExpression ? &d->m_match : nullptr, d->matchedLength);
268int KReplace::replace(QString &text, const QString &pattern, const QString &replacement, int index, long options, int *replacedLength)
272 index = KFind::find(text, pattern, index, options, &matchedLength, options & KFind::RegularExpression ? &match : nullptr);
275 *replacedLength = replaceHelper(text, replacement, index, options, options & KFind::RegularExpression ? &match : nullptr, matchedLength);
330 const int replacedLength = replaceHelper(text, m_replacement, index, options, &m_match, matchedLength);
337 // qDebug() << "after replace() signal: d->index=" << d->index << " replacedLength=" << replacedLength;
345 // when replacing the empty pattern, move on. See also kjs/regexp.cpp for how this should be done for regexps.
371 if (!forceAsking && (d->options & KFind::FromCursor) == 0 && (d->options & KReplaceDialog::PromptOnReplace) == 0) {
393 (d->options & KFind::FindBackwards) ? i18n("Do you want to restart search from the end?") : i18n("Do you want to restart search at the beginning?");
void optionsChanged()
This signal is sent whenever one of the option checkboxes is toggled.
void textFound(const QString &text, int matchingIndex, int matchedLength)
Connect to this signal to implement highlighting of found text during the find operation.
virtual void resetCounts()
Call this to reset the numMatches count (and the numReplacements count for a KReplace).
Definition kfind.cpp:684
virtual bool validateMatch(const QString &text, int index, int matchedlength)
Virtual method, which allows applications to add extra checks for validating a candidate match.
Definition kfind.cpp:691
@ PromptOnReplace
Should the user be prompted before the replace operation?
Definition kreplacedialog.h:54
void resetCounts() override
Call this to reset the numMatches & numReplacements counts.
Definition kreplace.cpp:355
QDialog * replaceNextDialog(bool create=false)
Return (or create) the dialog that shows the "find next?" prompt.
Definition kreplace.cpp:140
bool shouldRestart(bool forceAsking=false, bool showNumMatches=true) const override
Returns true if we should restart the search from scratch.
Definition kreplace.cpp:363
void displayFinalDialog() const override
Displays the final dialog telling the user how many replacements were made.
Definition kreplace.cpp:173
KReplace(const QString &pattern, const QString &replacement, long options, QWidget *parent=nullptr)
Only use this constructor if you don't use KFindDialog, or if you use it as a modal dialog.
Definition kreplace.cpp:121
QString i18np(const char *singular, const char *plural, const TYPE &arg...)
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QString i18n(const char *text, const TYPE &arg...)
PrimaryAction
void information(QWidget *parent, const QString &text, const QString &title=QString(), const QString &dontShowAgainName=QString(), Options options=Notify)
ButtonCode questionTwoActions(QWidget *parent, const QString &text, const QString &title, const KGuiItem &primaryAction, const KGuiItem &secondaryAction, const QString &dontAskAgainName=QString(), Options options=Notify)
void clicked(bool checked)
void addWidget(QWidget *widget, int stretch, Qt::Alignment alignment)
virtual void accept()
void finished(int result)
virtual void reject()
ActionRole
void accepted()
QPushButton * addButton(StandardButton button)
void rejected()
void setStandardButtons(StandardButtons buttons)
void setText(const QString &)
Q_EMITQ_EMIT
Q_OBJECTQ_OBJECT
QObject * parent() const const
bool isEmpty() const const
qsizetype length() const const
QString mid(qsizetype position, qsizetype n) const const
QString number(double n, char format, int precision)
QString & replace(QChar before, QChar after, Qt::CaseSensitivity cs)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
Q_D(Todo)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:06:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:06:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.