Remove all QRegExp dependencies from widgets

QRegExp is deprecated in Qt6 and will get moved to the Qt 5 compat
library. As such we need to remove all API and usages of QRegExp
in Qt.

Change-Id: I33fb56701d3d7c577f98a304c1d4e6f626fcb397
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
bb10
Lars Knoll 2020-03-15 14:27:00 +01:00
parent 66f06a930d
commit 70beac08af
10 changed files with 4 additions and 159 deletions

View File

@ -59,8 +59,6 @@
#include "qpushbutton.h"
#if QT_CONFIG(regularexpression)
#include <qregularexpression.h>
#else
#include <qregexp.h>
#endif
#if QT_CONFIG(settings)
#include "qsettings.h"

View File

@ -4352,7 +4352,7 @@ QStringList QFSCompleter::splitPath(const QString &path) const
return QStringList(completionPrefix());
QString pathCopy = QDir::toNativeSeparators(path);
QString sep = QDir::separator();
QChar sep = QDir::separator();
#if defined(Q_OS_WIN)
if (pathCopy == QLatin1String("\\") || pathCopy == QLatin1String("\\\\"))
return QStringList(pathCopy);
@ -4384,14 +4384,14 @@ QStringList QFSCompleter::splitPath(const QString &path) const
parts.append(QString());
#else
QStringList parts = pathCopy.split(sep);
if (pathCopy[0] == sep[0]) // read the "/" at the beginning as the split removed it
parts[0] = sep[0];
if (pathCopy[0] == sep) // read the "/" at the beginning as the split removed it
parts[0] = sep;
#endif
#if defined(Q_OS_WIN)
bool startsFromRoot = !parts.isEmpty() && parts[0].endsWith(QLatin1Char(':'));
#else
bool startsFromRoot = pathCopy[0] == sep[0];
bool startsFromRoot = pathCopy[0] == sep;
#endif
if (parts.count() == 1 || (parts.count() > 1 && !startsFromRoot)) {
const QFileSystemModel *dirModel;

View File

@ -2921,27 +2921,6 @@ bool QPlainTextEdit::find(const QString &exp, QTextDocument::FindFlags options)
return d->control->find(exp, options);
}
/*!
\fn bool QPlainTextEdit::find(const QRegExp &exp, QTextDocument::FindFlags options)
\since 5.3
\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 QRegExp::caseSensitivity instead.
Returns \c true if a match was found and changes the cursor to select the match;
otherwise returns \c false.
*/
#ifndef QT_NO_REGEXP
bool QPlainTextEdit::find(const QRegExp &exp, QTextDocument::FindFlags options)
{
Q_D(QPlainTextEdit);
return d->control->find(exp, options);
}
#endif
/*!
\fn bool QPlainTextEdit::find(const QRegularExpression &exp, QTextDocument::FindFlags options)

View File

@ -147,9 +147,6 @@ public:
bool centerOnScroll() const;
bool find(const QString &exp, QTextDocument::FindFlags options = QTextDocument::FindFlags());
#ifndef QT_NO_REGEXP
bool find(const QRegExp &exp, QTextDocument::FindFlags options = QTextDocument::FindFlags());
#endif
#if QT_CONFIG(regularexpression)
bool find(const QRegularExpression &exp, QTextDocument::FindFlags options = QTextDocument::FindFlags());
#endif

View File

@ -2609,27 +2609,6 @@ bool QTextEdit::find(const QString &exp, QTextDocument::FindFlags options)
return d->control->find(exp, options);
}
/*!
\fn bool QTextEdit::find(const QRegExp &exp, QTextDocument::FindFlags options)
\since 5.3
\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 QRegExp::caseSensitivity instead.
Returns \c true if a match was found and changes the cursor to select the match;
otherwise returns \c false.
*/
#ifndef QT_NO_REGEXP
bool QTextEdit::find(const QRegExp &exp, QTextDocument::FindFlags options)
{
Q_D(QTextEdit);
return d->control->find(exp, options);
}
#endif
/*!
\fn bool QTextEdit::find(const QRegularExpression &exp, QTextDocument::FindFlags options)

View File

@ -166,9 +166,6 @@ public:
void setWordWrapMode(QTextOption::WrapMode policy);
bool find(const QString &exp, QTextDocument::FindFlags options = QTextDocument::FindFlags());
#ifndef QT_NO_REGEXP
bool find(const QRegExp &exp, QTextDocument::FindFlags options = QTextDocument::FindFlags());
#endif
#if QT_CONFIG(regularexpression)
bool find(const QRegularExpression &exp, QTextDocument::FindFlags options = QTextDocument::FindFlags());
#endif

View File

@ -3145,19 +3145,6 @@ 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
#if QT_CONFIG(regularexpression)
bool QWidgetTextControl::find(const QRegularExpression &exp, QTextDocument::FindFlags options)
{

View File

@ -117,9 +117,6 @@ public:
QTextCharFormat currentCharFormat() const;
bool find(const QString &exp, QTextDocument::FindFlags options = { });
#ifndef QT_NO_REGEXP
bool find(const QRegExp &exp, QTextDocument::FindFlags options = { });
#endif
#if QT_CONFIG(regularexpression)
bool find(const QRegularExpression &exp, QTextDocument::FindFlags options = { });
#endif

View File

@ -135,11 +135,6 @@ private slots:
void insertAndScrollToBottom();
void inputMethodQueryImHints_data();
void inputMethodQueryImHints();
#ifndef QT_NO_REGEXP
void findWithRegExp();
void findBackwardWithRegExp();
void findWithRegExpReturnsFalseIfNoMoreResults();
#endif
#if QT_CONFIG(regularexpression)
void findWithRegularExpression();
void findBackwardWithRegularExpression();
@ -1562,45 +1557,6 @@ void tst_QPlainTextEdit::inputMethodQueryImHints()
QCOMPARE(static_cast<Qt::InputMethodHints>(value.toInt()), hints);
}
#ifndef QT_NO_REGEXP
void tst_QPlainTextEdit::findWithRegExp()
{
ed->setPlainText(QStringLiteral("arbitrary text"));
QRegExp rx("\\w{2}xt");
bool found = ed->find(rx);
QVERIFY(found);
QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text"));
}
void tst_QPlainTextEdit::findBackwardWithRegExp()
{
ed->setPlainText(QStringLiteral("arbitrary text"));
QTextCursor cursor = ed->textCursor();
cursor.movePosition(QTextCursor::End);
ed->setTextCursor(cursor);
QRegExp rx("a\\w*t");
bool found = ed->find(rx, QTextDocument::FindBackward);
QVERIFY(found);
QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("arbit"));
}
void tst_QPlainTextEdit::findWithRegExpReturnsFalseIfNoMoreResults()
{
ed->setPlainText(QStringLiteral("arbitrary text"));
QRegExp rx("t.xt");
ed->find(rx);
bool found = ed->find(rx);
QVERIFY(!found);
QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text"));
}
#endif
#if QT_CONFIG(regularexpression)
void tst_QPlainTextEdit::findWithRegularExpression()
{

View File

@ -194,12 +194,6 @@ private slots:
void countTextChangedOnRemove();
#ifndef QT_NO_REGEXP
void findWithRegExp();
void findBackwardWithRegExp();
void findWithRegExpReturnsFalseIfNoMoreResults();
#endif
#if QT_CONFIG(regularexpression)
void findWithRegularExpression();
void findBackwardWithRegularExpression();
@ -2609,45 +2603,6 @@ void tst_QTextEdit::countTextChangedOnRemove()
QCOMPARE(spy.count(), 1);
}
#ifndef QT_NO_REGEXP
void tst_QTextEdit::findWithRegExp()
{
ed->setHtml(QStringLiteral("arbitrary te<span style=\"color:#ff0000\">xt</span>"));
QRegExp rx("\\w{2}xt");
bool found = ed->find(rx);
QVERIFY(found);
QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text"));
}
void tst_QTextEdit::findBackwardWithRegExp()
{
ed->setPlainText(QStringLiteral("arbitrary text"));
QTextCursor cursor = ed->textCursor();
cursor.movePosition(QTextCursor::End);
ed->setTextCursor(cursor);
QRegExp rx("a\\w*t");
bool found = ed->find(rx, QTextDocument::FindBackward);
QVERIFY(found);
QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("arbit"));
}
void tst_QTextEdit::findWithRegExpReturnsFalseIfNoMoreResults()
{
ed->setPlainText(QStringLiteral("arbitrary text"));
QRegExp rx("t.xt");
ed->find(rx);
bool found = ed->find(rx);
QVERIFY(!found);
QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text"));
}
#endif
#if QT_CONFIG(regularexpression)
void tst_QTextEdit::findWithRegularExpression()
{