From f40c28f91514356155a42f44f9eb69c7faa83eec Mon Sep 17 00:00:00 2001 From: Christian Loose Date: Mon, 27 Jan 2014 12:27:38 +0100 Subject: Q(Plain)TextEdit: Add find() overload with QRegExp Add overloads to the find() methods in QPlainTextEdit and QTextEdit that find the next occurrence matching the passed regular expression. These are convenience methods that eliminate the need to use the document() method and the need to handle the QTextCursor return value. [ChangeLog][QtWidgets][QPlainTextEdit] Added find method overload using QRegExp [ChangeLog][QtWidgets][QTextEdit] Added find method overload using QRegExp Change-Id: Ia6139b771e3ae4ca02e4b8ea7fde19e5dc71b9d8 Reviewed-by: Marc Mutz --- src/widgets/widgets/qwidgettextcontrol.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/widgets/widgets/qwidgettextcontrol.cpp') diff --git a/src/widgets/widgets/qwidgettextcontrol.cpp b/src/widgets/widgets/qwidgettextcontrol.cpp index 9112e738da..06b513f3e0 100644 --- a/src/widgets/widgets/qwidgettextcontrol.cpp +++ b/src/widgets/widgets/qwidgettextcontrol.cpp @@ -2958,6 +2958,19 @@ bool QWidgetTextControl::find(const QString &exp, QTextDocument::FindFlags optio return true; } +#ifndef QT_NO_REGEXP +bool QWidgetTextControl::find(const QRegExp &exp, QTextDocument::FindFlags options) +{ + Q_D(QWidgetTextControl); + QTextCursor search = d->doc->find(exp, d->cursor, options); + if (search.isNull()) + return false; + + setTextCursor(search); + return true; +} +#endif + QString QWidgetTextControl::toPlainText() const { return document()->toPlainText(); -- cgit v1.2.3