summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2020-03-15 18:12:39 +0100
committerLars Knoll <lars.knoll@qt.io>2020-03-17 08:35:50 +0100
commitdee55af0a5359bb3b57a89cf3065ffca9d8506da (patch)
treeae849c37c5b43e4c2818d506077bacce5f28629f
parentbefd198c15b7a2b95f539372d2557063b6b397a6 (diff)
Remove QRegExpValidator
As QRegExp will be moved to a compat library in Qt 6. Change-Id: I181aec45bd798f49d2c50a0e7fb64782e004b854 Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
-rw-r--r--src/corelib/text/qregexp.cpp2
-rw-r--r--src/gui/doc/snippets/code/src_gui_util_qvalidator.cpp45
-rw-r--r--src/gui/util/qvalidator.cpp135
-rw-r--r--src/gui/util/qvalidator.h30
-rw-r--r--src/tools/uic/qclass_lib_map.h2
-rw-r--r--tests/auto/gui/util/CMakeLists.txt1
-rw-r--r--tests/auto/gui/util/qregexpvalidator/.gitignore1
-rw-r--r--tests/auto/gui/util/qregexpvalidator/CMakeLists.txt12
-rw-r--r--tests/auto/gui/util/qregexpvalidator/qregexpvalidator.pro4
-rw-r--r--tests/auto/gui/util/qregexpvalidator/tst_qregexpvalidator.cpp93
-rw-r--r--tests/auto/gui/util/util.pro1
11 files changed, 7 insertions, 319 deletions
diff --git a/src/corelib/text/qregexp.cpp b/src/corelib/text/qregexp.cpp
index 9301a7e573..3b6cdb133a 100644
--- a/src/corelib/text/qregexp.cpp
+++ b/src/corelib/text/qregexp.cpp
@@ -686,7 +686,7 @@ QT_BEGIN_NAMESPACE
the position in the string where the match was made (or -1 if
there was no match).
- \sa QString, QStringList, QRegExpValidator, QSortFilterProxyModel,
+ \sa QString, QStringList, QSortFilterProxyModel,
{tools/regexp}{Regular Expression Example}
*/
diff --git a/src/gui/doc/snippets/code/src_gui_util_qvalidator.cpp b/src/gui/doc/snippets/code/src_gui_util_qvalidator.cpp
index cc73ad9a19..1297ad8afe 100644
--- a/src/gui/doc/snippets/code/src_gui_util_qvalidator.cpp
+++ b/src/gui/doc/snippets/code/src_gui_util_qvalidator.cpp
@@ -99,51 +99,6 @@ s = "50";
v.validate(s, pos); // returns Acceptable
//! [2]
-
-//! [3]
-// regexp: optional '-' followed by between 1 and 3 digits
-QRegExp rx("-?\\d{1,3}");
-QValidator *validator = new QRegExpValidator(rx, this);
-
-QLineEdit *edit = new QLineEdit(this);
-edit->setValidator(validator);
-//! [3]
-
-
-//! [4]
-// integers 1 to 9999
-QRegExp rx("[1-9]\\d{0,3}");
-// the validator treats the regexp as "^[1-9]\\d{0,3}$"
-QRegExpValidator v(rx, 0);
-QString s;
-int pos = 0;
-
-s = "0"; v.validate(s, pos); // returns Invalid
-s = "12345"; v.validate(s, pos); // returns Invalid
-s = "1"; v.validate(s, pos); // returns Acceptable
-
-rx.setPattern("\\S+"); // one or more non-whitespace characters
-v.setRegExp(rx);
-s = "myfile.txt"; v.validate(s, pos); // Returns Acceptable
-s = "my file.txt"; v.validate(s, pos); // Returns Invalid
-
-// A, B or C followed by exactly five digits followed by W, X, Y or Z
-rx.setPattern("[A-C]\\d{5}[W-Z]");
-v.setRegExp(rx);
-s = "a12345Z"; v.validate(s, pos); // Returns Invalid
-s = "A12345Z"; v.validate(s, pos); // Returns Acceptable
-s = "B12"; v.validate(s, pos); // Returns Intermediate
-
-// match most 'readme' files
-rx.setPattern("read\\S?me(\.(txt|asc|1st))?");
-rx.setCaseSensitive(false);
-v.setRegExp(rx);
-s = "readme"; v.validate(s, pos); // Returns Acceptable
-s = "README.1ST"; v.validate(s, pos); // Returns Acceptable
-s = "read me.txt"; v.validate(s, pos); // Returns Invalid
-s = "readm"; v.validate(s, pos); // Returns Intermediate
-//! [4]
-
//! [5]
// regexp: optional '-' followed by between 1 and 3 digits
QRegularExpression rx("-?\\d{1,3}");
diff --git a/src/gui/util/qvalidator.cpp b/src/gui/util/qvalidator.cpp
index 54cbb28ffa..b01b09c0f9 100644
--- a/src/gui/util/qvalidator.cpp
+++ b/src/gui/util/qvalidator.cpp
@@ -58,7 +58,7 @@ QT_BEGIN_NAMESPACE
The class itself is abstract. Two subclasses, \l QIntValidator and
\l QDoubleValidator, provide basic numeric-range checking, and \l
- QRegExpValidator provides general checking using a custom regular
+ QRegularExpressionValidator provides general checking using a custom regular
expression.
If the built-in validators aren't sufficient, you can subclass
@@ -114,7 +114,7 @@ QT_BEGIN_NAMESPACE
QValidator is typically used with QLineEdit, QSpinBox and
QComboBox.
- \sa QIntValidator, QDoubleValidator, QRegExpValidator, {Line Edits Example}
+ \sa QIntValidator, QDoubleValidator, QRegularExpressionValidator, {Line Edits Example}
*/
@@ -192,13 +192,6 @@ QT_BEGIN_NAMESPACE
\internal
*/
-/*!
- \fn void QRegExpValidator::regExpChanged(const QRegExp &regExp)
-
- This signal is emitted after the regExp property changed.
- \internal
-*/
-
class QValidatorPrivate : public QObjectPrivate{
Q_DECLARE_PUBLIC(QValidator)
public:
@@ -328,7 +321,7 @@ void QValidator::fixup(QString &) const
is not set by default, the validator will accept group separators. It is thus
recommended to use QLocale::toInt() to obtain the numeric value.
- \sa QDoubleValidator, QRegExpValidator, QLocale::toInt(), {Line Edits Example}
+ \sa QDoubleValidator, QRegularExpressionValidator, QLocale::toInt(), {Line Edits Example}
*/
/*!
@@ -534,8 +527,6 @@ QValidator::QValidator(QValidatorPrivate &d, QObject *parent)
{
}
-#ifndef QT_NO_REGEXP
-
class QDoubleValidatorPrivate : public QValidatorPrivate
{
Q_DECLARE_PUBLIC(QDoubleValidator)
@@ -577,7 +568,7 @@ public:
is not set by default, the validator will accept group separators. It is thus
recommended to use QLocale::toDouble() to obtain the numeric value.
- \sa QIntValidator, QRegExpValidator, QLocale::toDouble(), {Line Edits Example}
+ \sa QIntValidator, QRegularExpressionValidator, QLocale::toDouble(), {Line Edits Example}
*/
/*!
@@ -818,122 +809,6 @@ QDoubleValidator::Notation QDoubleValidator::notation() const
return d->notation;
}
-/*!
- \class QRegExpValidator
- \brief The QRegExpValidator class is used to check a string
- against a regular expression.
- \inmodule QtGui
-
- QRegExpValidator uses a regular expression (regexp) to
- determine whether an input string is \l Acceptable, \l
- Intermediate, or \l Invalid. The regexp can either be supplied
- when the QRegExpValidator is constructed, or at a later time.
-
- When QRegExpValidator determines whether a string is \l Acceptable
- or not, the regexp is treated as if it begins with the start of string
- assertion (\b{^}) and ends with the end of string assertion
- (\b{$}); the match is against the entire input string, or from
- the given position if a start position greater than zero is given.
-
- If a string is a prefix of an \l Acceptable string, it is considered
- \l Intermediate. For example, "" and "A" are \l Intermediate for the
- regexp \b{[A-Z][0-9]} (whereas "_" would be \l Invalid).
-
- For a brief introduction to Qt's regexp engine, see \l QRegExp.
-
- Example of use:
- \snippet code/src_gui_util_qvalidator.cpp 3
-
- Below we present some examples of validators. In practice they would
- normally be associated with a widget as in the example above.
-
- \snippet code/src_gui_util_qvalidator.cpp 4
-
- \sa QRegExp, QIntValidator, QDoubleValidator, {Settings Editor Example}
-*/
-
-/*!
- Constructs a validator with a \a parent object that accepts
- any string (including an empty one) as valid.
-*/
-
-QRegExpValidator::QRegExpValidator(QObject *parent)
- : QRegExpValidator(QRegExp(QString::fromLatin1(".*")), parent)
-{
-}
-
-/*!
- Constructs a validator with a \a parent object that
- accepts all strings that match the regular expression \a rx.
-
- The match is made against the entire string; e.g. if the regexp is
- \b{[A-Fa-f0-9]+} it will be treated as \b{^[A-Fa-f0-9]+$}.
-*/
-
-QRegExpValidator::QRegExpValidator(const QRegExp& rx, QObject *parent)
- : QValidator(parent), r(rx)
-{
-}
-
-
-/*!
- Destroys the validator.
-*/
-
-QRegExpValidator::~QRegExpValidator()
-{
-}
-
-/*!
- Returns \l Acceptable if \a input is matched by the regular
- expression for this validator, \l Intermediate if it has matched
- partially (i.e. could be a valid match if additional valid
- characters are added), and \l Invalid if \a input is not matched.
-
- Additionally, if \a input is not matched, the \a pos parameter is set to
- the length of the \a input parameter.
-
- For example, if the regular expression is \b{\\w\\d\\d}
- (word-character, digit, digit) then "A57" is \l Acceptable,
- "E5" is \l Intermediate, and "+9" is \l Invalid.
-
- \sa QRegExp::exactMatch()
-*/
-
-QValidator::State QRegExpValidator::validate(QString &input, int& pos) const
-{
- QRegExp copy = r;
- if (copy.exactMatch(input)) {
- return Acceptable;
- } else {
- if (copy.matchedLength() == input.size()) {
- return Intermediate;
- } else {
- pos = input.size();
- return Invalid;
- }
- }
-}
-
-/*!
- \property QRegExpValidator::regExp
- \brief the regular expression used for validation
-
- By default, this property contains a regular expression with the pattern \c{.*}
- that matches any string.
-*/
-
-void QRegExpValidator::setRegExp(const QRegExp& rx)
-{
- if (r != rx) {
- r = rx;
- emit regExpChanged(r);
- emit changed();
- }
-}
-
-#endif
-
#if QT_CONFIG(regularexpression)
/*!
@@ -964,7 +839,7 @@ void QRegExpValidator::setRegExp(const QRegExp& rx)
\snippet code/src_gui_util_qvalidator.cpp 6
- \sa QRegularExpression, QIntValidator, QDoubleValidator, QRegExpValidator
+ \sa QRegularExpression, QIntValidator, QDoubleValidator
*/
class QRegularExpressionValidatorPrivate : public QValidatorPrivate
diff --git a/src/gui/util/qvalidator.h b/src/gui/util/qvalidator.h
index f0e72e3814..38e2e6c130 100644
--- a/src/gui/util/qvalidator.h
+++ b/src/gui/util/qvalidator.h
@@ -44,7 +44,6 @@
#include <QtGui/qtguiglobal.h>
#include <QtCore/qobject.h>
#include <QtCore/qstring.h>
-#include <QtCore/qregexp.h>
#if QT_CONFIG(regularexpression)
# include <QtCore/qregularexpression.h>
#endif
@@ -120,8 +119,6 @@ private:
int t;
};
-#ifndef QT_NO_REGEXP
-
class QDoubleValidatorPrivate;
class Q_GUI_EXPORT QDoubleValidator : public QValidator
@@ -170,33 +167,6 @@ private:
int dec;
};
-
-class Q_GUI_EXPORT QRegExpValidator : public QValidator
-{
- Q_OBJECT
- Q_PROPERTY(QRegExp regExp READ regExp WRITE setRegExp NOTIFY regExpChanged)
-
-public:
- explicit QRegExpValidator(QObject *parent = nullptr);
- explicit QRegExpValidator(const QRegExp& rx, QObject *parent = nullptr);
- ~QRegExpValidator();
-
- virtual QValidator::State validate(QString& input, int& pos) const override;
-
- void setRegExp(const QRegExp& rx);
- const QRegExp& regExp() const { return r; }
-
-Q_SIGNALS:
- void regExpChanged(const QRegExp& regExp);
-
-private:
- Q_DISABLE_COPY(QRegExpValidator)
-
- QRegExp r;
-};
-
-#endif // QT_NO_REGEXP
-
#if QT_CONFIG(regularexpression)
class QRegularExpressionValidatorPrivate;
diff --git a/src/tools/uic/qclass_lib_map.h b/src/tools/uic/qclass_lib_map.h
index df7ea27e20..1ca431287f 100644
--- a/src/tools/uic/qclass_lib_map.h
+++ b/src/tools/uic/qclass_lib_map.h
@@ -941,7 +941,7 @@ QT_CLASS_LIB(QToolButton, QtWidgets, qtoolbutton.h)
QT_CLASS_LIB(QValidator, QtGui, qvalidator.h)
QT_CLASS_LIB(QIntValidator, QtGui, qvalidator.h)
QT_CLASS_LIB(QDoubleValidator, QtGui, qvalidator.h)
-QT_CLASS_LIB(QRegExpValidator, QtGui, qvalidator.h)
+QT_CLASS_LIB(QRegularExpressionValidator, QtGui, qvalidator.h)
QT_CLASS_LIB(QScriptEngineDebugger, QtScriptTools, qscriptenginedebugger.h)
QT_CLASS_LIB(QDesignerComponents, QtDesigner, qdesigner_components.h)
QT_CLASS_LIB(QExtensionFactory, QtDesigner, default_extensionfactory.h)
diff --git a/tests/auto/gui/util/CMakeLists.txt b/tests/auto/gui/util/CMakeLists.txt
index 4e0a6b7e25..1c4a53265d 100644
--- a/tests/auto/gui/util/CMakeLists.txt
+++ b/tests/auto/gui/util/CMakeLists.txt
@@ -3,7 +3,6 @@
add_subdirectory(qdesktopservices)
add_subdirectory(qdoublevalidator)
add_subdirectory(qintvalidator)
-add_subdirectory(qregexpvalidator)
add_subdirectory(qregularexpressionvalidator)
add_subdirectory(qshadergenerator)
add_subdirectory(qshadergraph)
diff --git a/tests/auto/gui/util/qregexpvalidator/.gitignore b/tests/auto/gui/util/qregexpvalidator/.gitignore
deleted file mode 100644
index cff9b076b2..0000000000
--- a/tests/auto/gui/util/qregexpvalidator/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-tst_qregexpvalidator
diff --git a/tests/auto/gui/util/qregexpvalidator/CMakeLists.txt b/tests/auto/gui/util/qregexpvalidator/CMakeLists.txt
deleted file mode 100644
index 4f7d7da0c2..0000000000
--- a/tests/auto/gui/util/qregexpvalidator/CMakeLists.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-# Generated from qregexpvalidator.pro.
-
-#####################################################################
-## tst_qregexpvalidator Test:
-#####################################################################
-
-add_qt_test(tst_qregexpvalidator
- SOURCES
- tst_qregexpvalidator.cpp
- PUBLIC_LIBRARIES
- Qt::Gui
-)
diff --git a/tests/auto/gui/util/qregexpvalidator/qregexpvalidator.pro b/tests/auto/gui/util/qregexpvalidator/qregexpvalidator.pro
deleted file mode 100644
index 8f1de5b747..0000000000
--- a/tests/auto/gui/util/qregexpvalidator/qregexpvalidator.pro
+++ /dev/null
@@ -1,4 +0,0 @@
-CONFIG += testcase
-TARGET = tst_qregexpvalidator
-SOURCES += tst_qregexpvalidator.cpp
-QT += testlib
diff --git a/tests/auto/gui/util/qregexpvalidator/tst_qregexpvalidator.cpp b/tests/auto/gui/util/qregexpvalidator/tst_qregexpvalidator.cpp
deleted file mode 100644
index fbb4f0b4ea..0000000000
--- a/tests/auto/gui/util/qregexpvalidator/tst_qregexpvalidator.cpp
+++ /dev/null
@@ -1,93 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-
-#include <QtTest/QtTest>
-#include <qregexp.h>
-
-
-#include <qvalidator.h>
-
-class tst_QRegExpValidator : public QObject
-{
- Q_OBJECT
-
-private slots:
- void validate_data();
- void validate();
-};
-
-void tst_QRegExpValidator::validate_data()
-{
-
- QTest::addColumn<QString>("rx");
- QTest::addColumn<QString>("value");
- QTest::addColumn<int>("state");
-
- QTest::newRow( "data0" ) << QString("[1-9]\\d{0,3}") << QString("0") << 0;
- QTest::newRow( "data1" ) << QString("[1-9]\\d{0,3}") << QString("12345") << 0;
- QTest::newRow( "data2" ) << QString("[1-9]\\d{0,3}") << QString("1") << 2;
-
- QTest::newRow( "data3" ) << QString("\\S+") << QString("myfile.txt") << 2;
- QTest::newRow( "data4" ) << QString("\\S+") << QString("my file.txt") << 0;
-
- QTest::newRow( "data5" ) << QString("[A-C]\\d{5}[W-Z]") << QString("a12345Z") << 0;
- QTest::newRow( "data6" ) << QString("[A-C]\\d{5}[W-Z]") << QString("A12345Z") << 2;
- QTest::newRow( "data7" ) << QString("[A-C]\\d{5}[W-Z]") << QString("B12") << 1;
-
- QTest::newRow( "data8" ) << QString("read\\S?me(\\.(txt|asc|1st))?") << QString("readme") << 2;
- QTest::newRow( "data9" ) << QString("read\\S?me(\\.(txt|asc|1st))?") << QString("read me.txt") << 0;
- QTest::newRow( "data10" ) << QString("read\\S?me(\\.(txt|asc|1st))?") << QString("readm") << 1;
-}
-
-void tst_QRegExpValidator::validate()
-{
- QFETCH( QString, rx );
- QFETCH( QString, value );
- QFETCH( int, state );
-
- QRegExpValidator rv( 0 );
- QSignalSpy spy(&rv, SIGNAL(regExpChanged(QRegExp)));
- QSignalSpy changedSpy(&rv, SIGNAL(changed()));
-
- rv.setRegExp( QRegExp( rx ) );
- int pos = -1;
-
- QCOMPARE( (int)rv.validate( value, pos ), state );
-
- if (state == QValidator::Invalid)
- QCOMPARE(pos, value.length());
- else
- QCOMPARE(pos, -1); // untouched on Acceptable or Intermediate
-
- QCOMPARE(spy.count(), 1);
- QCOMPARE(changedSpy.count(), 1);
-}
-
-QTEST_APPLESS_MAIN(tst_QRegExpValidator)
-#include "tst_qregexpvalidator.moc"
diff --git a/tests/auto/gui/util/util.pro b/tests/auto/gui/util/util.pro
index 2789ffb55d..961424cc35 100644
--- a/tests/auto/gui/util/util.pro
+++ b/tests/auto/gui/util/util.pro
@@ -3,7 +3,6 @@ SUBDIRS= \
qdesktopservices \
qdoublevalidator \
qintvalidator \
- qregexpvalidator \
qregularexpressionvalidator \
qshadergenerator \
qshadergraph \