summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGiuseppe D'Angelo <[email protected]>2024-02-23 20:20:36 +0100
committerGiuseppe D'Angelo <[email protected]>2024-02-26 01:31:07 +0100
commit3ec9331c341767b1430eb2b14df02383226e25e8 (patch)
tree3ae1b7d8e3c094d1c465980995ca9435cb289f7f
parent08349ef0fe3902504987d12ebe0ed9674ed1e486 (diff)
Text widgets: document find() behavior with QRegularExpression
The various find() overloads that take a QRE *ignore* the case sensitivity option set on the QRE object itself. They instead apply the case sensitivity passed in the flags (see QTextDocument::find). I think it was an historic mishap, but it's too late to change now. Amend the documentation. Change-Id: I526650d89a98777c7bb839b27d2f2e536a43ca4f Pick-to: 6.7 6.6 6.5 6.2 5.15 Fixes: QTBUG-88721 Reviewed-by: Samuel Gaist <[email protected]>
-rw-r--r--src/gui/text/qtextdocument.cpp4
-rw-r--r--src/widgets/widgets/qplaintextedit.cpp7
-rw-r--r--src/widgets/widgets/qtextedit.cpp7
3 files changed, 14 insertions, 4 deletions
diff --git a/src/gui/text/qtextdocument.cpp b/src/gui/text/qtextdocument.cpp
index 38279b30645..fc172c5057f 100644
--- a/src/gui/text/qtextdocument.cpp
+++ b/src/gui/text/qtextdocument.cpp
@@ -1509,6 +1509,10 @@ static bool findInBlock(const QTextBlock &block, const QRegularExpression &expr,
If the \a from position is 0 (the default) the search begins from the beginning
of the document; otherwise it begins at the specified position.
+
+ \warning For historical reasons, the case sensitivity option set on
+ \a expr is ignored. Instead, the \a options are used to determine
+ if the search is case sensitive or not.
*/
QTextCursor QTextDocument::find(const QRegularExpression &expr, int from, FindFlags options) const
{
diff --git a/src/widgets/widgets/qplaintextedit.cpp b/src/widgets/widgets/qplaintextedit.cpp
index 087b7e4d210..dcba223cb03 100644
--- a/src/widgets/widgets/qplaintextedit.cpp
+++ b/src/widgets/widgets/qplaintextedit.cpp
@@ -2894,11 +2894,14 @@ bool QPlainTextEdit::find(const QString &exp, QTextDocument::FindFlags options)
\overload
Finds the next occurrence, matching the regular expression, \a exp, using the given
- \a options. The QTextDocument::FindCaseSensitively option is ignored for this overload,
- use QRegularExpression::CaseInsensitiveOption instead.
+ \a options.
Returns \c true if a match was found and changes the cursor to select the match;
otherwise returns \c false.
+
+ \warning For historical reasons, the case sensitivity option set on
+ \a exp is ignored. Instead, the \a options are used to determine
+ if the search is case sensitive or not.
*/
#if QT_CONFIG(regularexpression)
bool QPlainTextEdit::find(const QRegularExpression &exp, QTextDocument::FindFlags options)
diff --git a/src/widgets/widgets/qtextedit.cpp b/src/widgets/widgets/qtextedit.cpp
index 2bc7d06f11a..1a3d0f9e983 100644
--- a/src/widgets/widgets/qtextedit.cpp
+++ b/src/widgets/widgets/qtextedit.cpp
@@ -2593,11 +2593,14 @@ bool QTextEdit::find(const QString &exp, QTextDocument::FindFlags options)
\overload
Finds the next occurrence, matching the regular expression, \a exp, using the given
- \a options. The QTextDocument::FindCaseSensitively option is ignored for this overload,
- use QRegularExpression::CaseInsensitiveOption instead.
+ \a options.
Returns \c true if a match was found and changes the cursor to select the match;
otherwise returns \c false.
+
+ \warning For historical reasons, the case sensitivity option set on
+ \a exp is ignored. Instead, the \a options are used to determine
+ if the search is case sensitive or not.
*/
#if QT_CONFIG(regularexpression)
bool QTextEdit::find(const QRegularExpression &exp, QTextDocument::FindFlags options)