diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-03-18 13:32:28 +0100 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-03-20 11:39:42 +0000 |
commit | 99a81e78d5b2a55226161d7aa7483ab2cb918f8b (patch) | |
tree | e819eddf8833b69b4ad089dee7cca46eb5f6bf20 | |
parent | 2e4915bdb96bc1d5e5bed6f38e13b87db68a97c5 (diff) |
Port from QRegExpValidator to QRegularExpressionValidator
QRegExpValidator is going away in Qt6, so port over to the
version using QRegularExpression.
Change-Id: Iecd1ba1f0e5e01009ae43b79c1ccc73f0fc046b2
Reviewed-by: hjk <hjk@qt.io>
14 files changed, 40 insertions, 40 deletions
diff --git a/share/qtcreator/qml-type-descriptions/builtins.qmltypes b/share/qtcreator/qml-type-descriptions/builtins.qmltypes index ec31791827f..a7c009027c9 100644 --- a/share/qtcreator/qml-type-descriptions/builtins.qmltypes +++ b/share/qtcreator/qml-type-descriptions/builtins.qmltypes @@ -3223,15 +3223,15 @@ Module { Method { name: "deleteLater" } } Component { - name: "QRegExpValidator" + name: "QRegularExpressionValidator" prototype: "QValidator" exports: [ - "QtQuick/RegExpValidator 1.0" + "QtQuick/RegularExpressionValidator 2.14" ] exportMetaObjectRevisions: [ 0 ] - Property { name: "regExp"; type: "QRegExp" } + Property { name: "regularExpression"; type: "QRegularExpression" } } Component { name: "QValidator"; prototype: "QObject" } Component { diff --git a/src/libs/qmleditorwidgets/fontsizespinbox.cpp b/src/libs/qmleditorwidgets/fontsizespinbox.cpp index f127b5a677e..8dd86959dc3 100644 --- a/src/libs/qmleditorwidgets/fontsizespinbox.cpp +++ b/src/libs/qmleditorwidgets/fontsizespinbox.cpp @@ -26,7 +26,7 @@ #include "fontsizespinbox.h" #include <QLineEdit> -#include <QRegExpValidator> +#include <QRegularExpressionValidator> namespace QmlEditorWidgets { @@ -91,8 +91,7 @@ void FontSizeSpinBox::onEditingFinished() QValidator::State FontSizeSpinBox::validate (QString &input, int &p) const { - QRegExp rx(QLatin1String("\\d+\\s*(px|pt)")); - QRegExpValidator v(rx, nullptr); + QRegularExpressionValidator v(QRegularExpression(QLatin1String("\\d+\\s*(px|pt)")), nullptr); return v.validate(input, p); } diff --git a/src/plugins/android/avddialog.cpp b/src/plugins/android/avddialog.cpp index 78fcfe6b0f6..3e11cd18233 100644 --- a/src/plugins/android/avddialog.cpp +++ b/src/plugins/android/avddialog.cpp @@ -64,7 +64,7 @@ AvdDialog::AvdDialog(int minApiLevel, AndroidSdkManager *sdkManager, const QStri m_avdDialog.abiComboBox->addItems(abis); } - auto v = new QRegExpValidator(m_allowedNameChars, this); + auto v = new QRegularExpressionValidator(m_allowedNameChars, this); m_avdDialog.nameLineEdit->setValidator(v); m_avdDialog.nameLineEdit->installEventFilter(this); @@ -258,7 +258,7 @@ bool AvdDialog::eventFilter(QObject *obj, QEvent *event) if (obj == m_avdDialog.nameLineEdit && event->type() == QEvent::KeyPress) { auto ke = static_cast<QKeyEvent *>(event); const QString key = ke->text(); - if (!key.isEmpty() && !m_allowedNameChars.exactMatch(key)) { + if (!key.isEmpty() && !m_allowedNameChars.match(key).hasMatch()) { QPoint position = m_avdDialog.nameLineEdit->parentWidget()->mapToGlobal(m_avdDialog.nameLineEdit->geometry().bottomLeft()); position -= Utils::ToolTip::offsetFromPosition(); Utils::ToolTip::show(position, tr("Allowed characters are: a-z A-Z 0-9 and . _ -"), m_avdDialog.nameLineEdit); diff --git a/src/plugins/android/avddialog.h b/src/plugins/android/avddialog.h index ba3d75837cd..9813cc813ba 100644 --- a/src/plugins/android/avddialog.h +++ b/src/plugins/android/avddialog.h @@ -85,7 +85,7 @@ private: AndroidSdkManager *m_sdkManager; int m_minApiLevel; QTimer m_hideTipTimer; - QRegExp m_allowedNameChars; + QRegularExpression m_allowedNameChars; QList<DeviceDefinitionStruct> m_deviceDefinitionsList; AndroidConfig m_androidConfig; }; diff --git a/src/plugins/bineditor/bineditorplugin.cpp b/src/plugins/bineditor/bineditorplugin.cpp index c21f530ade1..c25d36d1a12 100644 --- a/src/plugins/bineditor/bineditorplugin.cpp +++ b/src/plugins/bineditor/bineditorplugin.cpp @@ -42,7 +42,7 @@ #include <QMessageBox> #include <QHBoxLayout> #include <QLineEdit> -#include <QRegExpValidator> +#include <QRegularExpressionValidator> #include <QToolBar> #include <coreplugin/actionmanager/actionmanager.h> @@ -363,7 +363,7 @@ public: setWidget(widget); m_file = new BinEditorDocument(widget); m_addressEdit = new QLineEdit; - auto addressValidator = new QRegExpValidator(QRegExp("[0-9a-fA-F]{1,16}"), m_addressEdit); + auto addressValidator = new QRegularExpressionValidator(QRegularExpression("[0-9a-fA-F]{1,16}"), m_addressEdit); m_addressEdit->setValidator(addressValidator); auto l = new QHBoxLayout; diff --git a/src/plugins/git/gerrit/gerritpushdialog.cpp b/src/plugins/git/gerrit/gerritpushdialog.cpp index ddd45134f79..63d05614bd6 100644 --- a/src/plugins/git/gerrit/gerritpushdialog.cpp +++ b/src/plugins/git/gerrit/gerritpushdialog.cpp @@ -37,7 +37,7 @@ #include <QDateTime> #include <QDir> #include <QPushButton> -#include <QRegExpValidator> +#include <QRegularExpressionValidator> #include <QVersionNumber> using namespace Git::Internal; @@ -156,7 +156,7 @@ GerritPushDialog::GerritPushDialog(const QString &workingDir, const QString &rev updateCommits(m_ui->localBranchComboBox->currentIndex()); onRemoteChanged(true); - QRegExpValidator *noSpaceValidator = new QRegExpValidator(QRegExp("^\\S+$"), this); + QRegularExpressionValidator *noSpaceValidator = new QRegularExpressionValidator(QRegularExpression("^\\S+$"), this); m_ui->reviewersLineEdit->setText(reviewerList); m_ui->reviewersLineEdit->setValidator(noSpaceValidator); m_ui->topicLineEdit->setValidator(noSpaceValidator); diff --git a/src/plugins/git/gitsubmiteditorwidget.cpp b/src/plugins/git/gitsubmiteditorwidget.cpp index 32ffe106f60..308b34fba69 100644 --- a/src/plugins/git/gitsubmiteditorwidget.cpp +++ b/src/plugins/git/gitsubmiteditorwidget.cpp @@ -33,7 +33,7 @@ #include <utils/theme/theme.h> #include <utils/utilsicons.h> -#include <QRegExpValidator> +#include <QRegularExpressionValidator> #include <QTextEdit> #include <QDir> @@ -52,7 +52,7 @@ GitSubmitEditorWidget::GitSubmitEditorWidget() : m_gitSubmitPanelUi.setupUi(m_gitSubmitPanel); new GitSubmitHighlighter(descriptionEdit()); - m_emailValidator = new QRegExpValidator(QRegExp("[^@ ]+@[^@ ]+\\.[a-zA-Z]+"), this); + m_emailValidator = new QRegularExpressionValidator(QRegularExpression("[^@ ]+@[^@ ]+\\.[a-zA-Z]+"), this); const QPixmap error = Utils::Icons::CRITICAL.pixmap(); m_gitSubmitPanelUi.invalidAuthorLabel->setPixmap(error); m_gitSubmitPanelUi.invalidEmailLabel->setToolTip(tr("Provide a valid email to commit.")); diff --git a/src/plugins/macros/savedialog.cpp b/src/plugins/macros/savedialog.cpp index 38b71883d7a..d85e5446700 100644 --- a/src/plugins/macros/savedialog.cpp +++ b/src/plugins/macros/savedialog.cpp @@ -28,7 +28,7 @@ #include <QLineEdit> #include <QCheckBox> -#include <QRegExpValidator> +#include <QRegularExpressionValidator> using namespace Macros::Internal; @@ -37,7 +37,7 @@ SaveDialog::SaveDialog(QWidget *parent) : ui(new Ui::SaveDialog) { ui->setupUi(this); - ui->name->setValidator(new QRegExpValidator(QRegExp(QLatin1String("\\w*")), this)); + ui->name->setValidator(new QRegularExpressionValidator(QRegularExpression(QLatin1String("\\w*")), this)); } SaveDialog::~SaveDialog() diff --git a/src/plugins/projectexplorer/customwizard/customwizardpage.cpp b/src/plugins/projectexplorer/customwizard/customwizardpage.cpp index a17a242c736..3c10eef37cf 100644 --- a/src/plugins/projectexplorer/customwizard/customwizardpage.cpp +++ b/src/plugins/projectexplorer/customwizard/customwizardpage.cpp @@ -42,7 +42,7 @@ #include <QVBoxLayout> #include <QLineEdit> #include <QLabel> -#include <QRegExpValidator> +#include <QRegularExpressionValidator> #include <QComboBox> #include <QTextEdit> #include <QSpacerItem> @@ -284,9 +284,9 @@ QWidget *CustomWizardFieldPage::registerLineEdit(const QString &fieldName, const QString validationRegExp = field.controlAttributes.value(QLatin1String("validator")); if (!validationRegExp.isEmpty()) { - QRegExp re(validationRegExp); + QRegularExpression re(validationRegExp); if (re.isValid()) - lineEdit->setValidator(new QRegExpValidator(re, lineEdit)); + lineEdit->setValidator(new QRegularExpressionValidator(re, lineEdit)); else qWarning("Invalid custom wizard field validator regular expression %s.", qPrintable(validationRegExp)); } diff --git a/src/plugins/remotelinux/genericlinuxdeviceconfigurationwidget.cpp b/src/plugins/remotelinux/genericlinuxdeviceconfigurationwidget.cpp index a184bb2fd3b..5def09d3c88 100644 --- a/src/plugins/remotelinux/genericlinuxdeviceconfigurationwidget.cpp +++ b/src/plugins/remotelinux/genericlinuxdeviceconfigurationwidget.cpp @@ -187,8 +187,8 @@ void GenericLinuxDeviceConfigurationWidget::initGui() m_ui->keyFileLineEdit->setExpectedKind(PathChooser::File); m_ui->keyFileLineEdit->setHistoryCompleter(QLatin1String("Ssh.KeyFile.History")); m_ui->keyFileLineEdit->lineEdit()->setMinimumWidth(0); - QRegExpValidator * const portsValidator - = new QRegExpValidator(QRegExp(PortList::regularExpression()), this); + QRegularExpressionValidator * const portsValidator + = new QRegularExpressionValidator(QRegularExpression(PortList::regularExpression()), this); m_ui->portsLineEdit->setValidator(portsValidator); const SshConnectionParameters &sshParams = device()->sshParameters(); diff --git a/src/plugins/scxmleditor/common/structure.cpp b/src/plugins/scxmleditor/common/structure.cpp index 08164e0aa30..96f8e29fd4c 100644 --- a/src/plugins/scxmleditor/common/structure.cpp +++ b/src/plugins/scxmleditor/common/structure.cpp @@ -42,7 +42,7 @@ #include <QLabel> #include <QLineEdit> #include <QRegExp> -#include <QRegExpValidator> +#include <QRegularExpressionValidator> #include <QToolBar> #include <QToolButton> #include <QUndoStack> @@ -63,9 +63,9 @@ QWidget *TreeItemDelegate::createEditor(QWidget *parent, const QStyleOptionViewI if (index.isValid()) { auto edit = new QLineEdit(parent); edit->setFocusPolicy(Qt::StrongFocus); - QRegExp rx("^(?!xml)[_a-z][a-z0-9-._]*$"); - rx.setCaseSensitivity(Qt::CaseInsensitive); - edit->setValidator(new QRegExpValidator(rx, parent)); + QRegularExpression rx("^(?!xml)[_a-z][a-z0-9-._]*$"); + rx.setPatternOptions(QRegularExpression::CaseInsensitiveOption); + edit->setValidator(new QRegularExpressionValidator(rx, parent)); return edit; } return QStyledItemDelegate::createEditor(parent, option, index); diff --git a/src/plugins/scxmleditor/plugin_interface/scattributeitemdelegate.cpp b/src/plugins/scxmleditor/plugin_interface/scattributeitemdelegate.cpp index 78735dcf5ac..61f86671d0e 100644 --- a/src/plugins/scxmleditor/plugin_interface/scattributeitemdelegate.cpp +++ b/src/plugins/scxmleditor/plugin_interface/scattributeitemdelegate.cpp @@ -28,7 +28,7 @@ #include <QComboBox> #include <QLineEdit> #include <QRegExp> -#include <QRegExpValidator> +#include <QRegularExpressionValidator> using namespace ScxmlEditor::PluginInterface; @@ -51,9 +51,10 @@ QWidget *SCAttributeItemDelegate::createEditor(QWidget *parent, const QStyleOpti if (index.column() == 0) { auto edit = new QLineEdit(parent); edit->setFocusPolicy(Qt::StrongFocus); - QRegExp rx("^(?!xml)[_a-z][a-z0-9-._]*$"); - rx.setCaseSensitivity(Qt::CaseInsensitive); - edit->setValidator(new QRegExpValidator(rx, parent)); + QRegularExpression rx("^(?!xml)[_a-z][a-z0-9-._]*$"); + rx.setPatternOptions(QRegularExpression::CaseInsensitiveOption); + + edit->setValidator(new QRegularExpressionValidator(rx, parent)); return edit; } } diff --git a/tests/auto/qml/codemodel/importscheck/004_cppOnly copy/QtQuick.2/plugins.qmltypes b/tests/auto/qml/codemodel/importscheck/004_cppOnly copy/QtQuick.2/plugins.qmltypes index cadef103707..8a8bc257d70 100644 --- a/tests/auto/qml/codemodel/importscheck/004_cppOnly copy/QtQuick.2/plugins.qmltypes +++ b/tests/auto/qml/codemodel/importscheck/004_cppOnly copy/QtQuick.2/plugins.qmltypes @@ -4160,14 +4160,14 @@ Module { exportMetaObjectRevisions: [0] } Component { - name: "QRegExpValidator" + name: "QRegularExpressionValidator" prototype: "QValidator" - exports: ["QtQuick/RegExpValidator 2.0"] + exports: ["QtQuick/RegularExpressionValidator 2.14"] exportMetaObjectRevisions: [0] - Property { name: "regExp"; type: "QRegExp" } + Property { name: "regularExpression"; type: "QRegularExpression" } Signal { - name: "regExpChanged" - Parameter { name: "regExp"; type: "QRegExp" } + name: "regularExpressionChanged" + Parameter { name: "regularExpression"; type: "QRegularExpression" } } } Component { diff --git a/tests/auto/qml/codemodel/importscheck/base/QtQuick.2/plugins.qmltypes b/tests/auto/qml/codemodel/importscheck/base/QtQuick.2/plugins.qmltypes index cadef103707..8a8bc257d70 100644 --- a/tests/auto/qml/codemodel/importscheck/base/QtQuick.2/plugins.qmltypes +++ b/tests/auto/qml/codemodel/importscheck/base/QtQuick.2/plugins.qmltypes @@ -4160,14 +4160,14 @@ Module { exportMetaObjectRevisions: [0] } Component { - name: "QRegExpValidator" + name: "QRegularExpressionValidator" prototype: "QValidator" - exports: ["QtQuick/RegExpValidator 2.0"] + exports: ["QtQuick/RegularExpressionValidator 2.14"] exportMetaObjectRevisions: [0] - Property { name: "regExp"; type: "QRegExp" } + Property { name: "regularExpression"; type: "QRegularExpression" } Signal { - name: "regExpChanged" - Parameter { name: "regExp"; type: "QRegExp" } + name: "regularExpressionChanged" + Parameter { name: "regularExpression"; type: "QRegularExpression" } } } Component { |