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>
This commit is contained in:
Lars Knoll
2020-03-18 13:32:28 +01:00
parent 2e4915bdb9
commit 99a81e78d5
14 changed files with 40 additions and 40 deletions

View File

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