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.6 6.5 6.2 5.15
Fixes: QTBUG-88721
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
(cherry picked from commit 3ec9331c341767b1430eb2b14df02383226e25e8)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Giuseppe D'Angelo 2024-02-23 20:20:36 +01:00 committed by Qt Cherry-pick Bot
parent a4c158effe
commit ecaf35b4c5
3 changed files with 14 additions and 4 deletions

View File

@ -1500,6 +1500,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
{

View File

@ -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)

View File

@ -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)