Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qt5+: Switch from QRegExp to QRegularExpression #301

Merged
merged 1 commit into from
Oct 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/gui/diamondcardprofileform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <QRegExp>
#include <QRegularExpression>
#include <QValidator>
#include <QRegExpValidator>
#include <QRegularExpressionValidator>
#include "gui.h"
#include "diamondcard.h"
#include "getprofilenameform.h"
Expand Down Expand Up @@ -66,9 +66,9 @@ void DiamondcardProfileForm::init()
user_config = NULL;
destroy_user_config = false;

QRegExp rxNoSpace("\\S*");
accountIdLineEdit->setValidator(new QRegExpValidator(rxNoSpace, this));
pinCodeLineEdit->setValidator(new QRegExpValidator(rxNoSpace, this));
QRegularExpression rxNoSpace("\\S*");
accountIdLineEdit->setValidator(new QRegularExpressionValidator(rxNoSpace, this));
pinCodeLineEdit->setValidator(new QRegularExpressionValidator(rxNoSpace, this));
}

void DiamondcardProfileForm::destroy()
Expand Down
1 change: 0 additions & 1 deletion src/gui/getaddressform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

#include "getaddressform.h"
#include <QMessageBox>
#include <QRegExp>
#include "sys_settings.h"
#include "gui.h"
#include "address_book.h"
Expand Down
10 changes: 5 additions & 5 deletions src/gui/getprofilenameform.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "getprofilenameform.h"
#include <QDir>
#include <QMessageBox>
#include <QRegExpValidator>
#include <QRegularExpressionValidator>
#include "user.h"
#include "protocol.h"

Expand Down Expand Up @@ -30,11 +30,11 @@ GetProfileNameForm::~GetProfileNameForm()
void GetProfileNameForm::init()
{
// Letters, digits, underscore, minus, "@" and period
QRegExp rxFilenameChars("[\\w\\-@\\.]*");
QRegularExpression rxFilenameChars("[\\w\\-@\\.]*");

// Set validators
// USER
profileLineEdit->setValidator(new QRegExpValidator(rxFilenameChars, this));
profileLineEdit->setValidator(new QRegularExpressionValidator(rxFilenameChars, this));

// Focus seems to default to OK button, despite tab order
profileLineEdit->setFocus();
Expand All @@ -47,8 +47,8 @@ void GetProfileNameForm::validate()
if (profileName.isEmpty()) return;

// Check for anything that was let through by the validator
QRegExp rxFilename("^[\\w\\-][\\w\\-@\\.]*$");
if (!rxFilename.exactMatch(profileName)) {
QRegularExpression rxFilename("^[\\w\\-][\\w\\-@\\.]*$");
if (!rxFilename.match(profileName).hasMatch()) {
QMessageBox::critical(this, PRODUCT_NAME,
tr("Invalid profile name: %1").arg(profileName)
// While this would be better suited as informativeText,
Expand Down
8 changes: 4 additions & 4 deletions src/gui/inviteform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include "util.h"
#include "audits/memman.h"
#include "sys_settings.h"
#include <QRegExp>
#include <QRegularExpression>
#include <QValidator>
#include <QRegExpValidator>
#include <QRegularExpressionValidator>

/*
Copyright (C) 2005-2009 Michel de Boer <[email protected]>
Expand Down Expand Up @@ -46,8 +46,8 @@ void InviteForm::init()
setDisabledIcon(addressToolButton, ":/icons/images/kontact_contacts-disabled.png");

// A QComboBox accepts a new line through copy/paste.
QRegExp rxNoNewLine("[^\\n\\r]*");
inviteComboBox->setValidator(new QRegExpValidator(rxNoNewLine, this));
QRegularExpression rxNoNewLine("[^\\n\\r]*");
inviteComboBox->setValidator(new QRegularExpressionValidator(rxNoNewLine, this));
}

void InviteForm::destroy()
Expand Down
8 changes: 4 additions & 4 deletions src/gui/mphoneform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
#include "util.h"
#include <QTimer>
#include <QCursor>
#include <QRegExp>
#include <QRegularExpression>
#include <QValidator>
#include <QSettings>
#include <QRegExpValidator>
#include <QRegularExpressionValidator>
#include "buddyform.h"
#include "diamondcardprofileform.h"
#include "osd.h"
Expand Down Expand Up @@ -194,8 +194,8 @@ void MphoneForm::init()
}

// A QComboBox accepts a new line through copy/paste.
QRegExp rxNoNewLine("[^\\n\\r]*");
callComboBox->setValidator(new QRegExpValidator(rxNoNewLine, this));
QRegularExpression rxNoNewLine("[^\\n\\r]*");
callComboBox->setValidator(new QRegularExpressionValidator(rxNoNewLine, this));

if (sys_config->get_gui_use_systray()) {
// Create system tray icon
Expand Down
8 changes: 4 additions & 4 deletions src/gui/numberconversionform.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "numberconversionform.h"

#include <QRegExpValidator>
#include <QRegularExpressionValidator>
#include "gui.h"

/*
Expand All @@ -26,10 +26,10 @@ NumberConversionForm::~NumberConversionForm()

void NumberConversionForm::init()
{
QRegExp rxNoAtSign("[^@]*");
QRegularExpression rxNoAtSign("[^@]*");

exprLineEdit->setValidator(new QRegExpValidator(rxNoAtSign, this));
replaceLineEdit->setValidator(new QRegExpValidator(rxNoAtSign, this));
exprLineEdit->setValidator(new QRegularExpressionValidator(rxNoAtSign, this));
replaceLineEdit->setValidator(new QRegularExpressionValidator(rxNoAtSign, this));
}

int NumberConversionForm::exec(QString &expr, QString &replace)
Expand Down
10 changes: 5 additions & 5 deletions src/gui/syssettingsform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
#include <QFileDialog>
#include <QFileInfo>
#include "twinkle_config.h"
#include <QRegExp>
#include <QRegularExpression>
#include <QValidator>
#include <QRegExpValidator>
#include <QRegularExpressionValidator>
#include "syssettingsform.h"
/*
* Constructs a SysSettingsForm as a child of 'parent', with the
Expand Down Expand Up @@ -85,9 +85,9 @@ void SysSettingsForm::init()
QIcon::Disabled);
openRingbackToolButton->setIcon(i);

QRegExp rxNumber("[0-9]+");
maxUdpSizeLineEdit->setValidator(new QRegExpValidator(rxNumber, this));
maxTcpSizeLineEdit->setValidator(new QRegExpValidator(rxNumber, this));
QRegularExpression rxNumber("[0-9]+");
maxUdpSizeLineEdit->setValidator(new QRegularExpressionValidator(rxNumber, this));
maxTcpSizeLineEdit->setValidator(new QRegularExpressionValidator(rxNumber, this));
}

void SysSettingsForm::showCategory( int index )
Expand Down
32 changes: 16 additions & 16 deletions src/gui/userprofileform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <QLabel>
#include <QComboBox>
#include <QSpinBox>
#include <QRegExp>
#include <QRegularExpression>
#include "sdp/sdp.h"
#include <QValidator>
#include "protocol.h"
Expand All @@ -31,7 +31,7 @@
#include <QStringList>
#include "twinkle_config.h"
#include <QListWidget>
#include <QRegExpValidator>
#include <QRegularExpressionValidator>
#include "numberconversionform.h"
#include "util.h"
#include "userprofileform.h"
Expand Down Expand Up @@ -147,31 +147,31 @@ void UserProfileForm::languageChange()

void UserProfileForm::init()
{
QRegExp rxNoSpace("\\S*");
QRegExp rxNoAtSign("[^@]*");
QRegExp rxQvalue("(0\\.[0-9]{0,3})|(1\\.0{0,3})");
QRegExp rxAkaOpValue("[a-zA-Z0-9]{0,32}");
QRegExp rxAkaAmfValue("[a-zA-Z0-9]{0,4}");
QRegularExpression rxNoSpace("\\S*");
QRegularExpression rxNoAtSign("[^@]*");
QRegularExpression rxQvalue("(0\\.[0-9]{0,3})|(1\\.0{0,3})");
QRegularExpression rxAkaOpValue("[a-zA-Z0-9]{0,32}");
QRegularExpression rxAkaAmfValue("[a-zA-Z0-9]{0,4}");

// Set validators
// USER
domainLineEdit->setValidator(new QRegExpValidator(rxNoSpace, this));
authAkaOpLineEdit->setValidator(new QRegExpValidator(rxAkaOpValue, this));
authAkaAmfLineEdit->setValidator(new QRegExpValidator(rxAkaAmfValue, this));
domainLineEdit->setValidator(new QRegularExpressionValidator(rxNoSpace, this));
authAkaOpLineEdit->setValidator(new QRegularExpressionValidator(rxAkaOpValue, this));
authAkaAmfLineEdit->setValidator(new QRegularExpressionValidator(rxAkaAmfValue, this));

// SIP SERVER
registrarLineEdit->setValidator(new QRegExpValidator(rxNoSpace, this));
regQvalueLineEdit->setValidator(new QRegExpValidator(rxQvalue, this));
proxyLineEdit->setValidator(new QRegExpValidator(rxNoSpace, this));
registrarLineEdit->setValidator(new QRegularExpressionValidator(rxNoSpace, this));
regQvalueLineEdit->setValidator(new QRegularExpressionValidator(rxQvalue, this));
proxyLineEdit->setValidator(new QRegularExpressionValidator(rxNoSpace, this));

// Voice mail
mwiServerLineEdit->setValidator(new QRegExpValidator(rxNoSpace, this));
mwiServerLineEdit->setValidator(new QRegularExpressionValidator(rxNoSpace, this));

// NAT
publicIPLineEdit->setValidator(new QRegExpValidator(rxNoSpace, this));
publicIPLineEdit->setValidator(new QRegularExpressionValidator(rxNoSpace, this));

// Address format
testConversionLineEdit->setValidator(new QRegExpValidator(rxNoAtSign, this));
testConversionLineEdit->setValidator(new QRegularExpressionValidator(rxNoAtSign, this));

#ifndef HAVE_SPEEX
// Speex & (Speex) Preprocessing
Expand Down
14 changes: 7 additions & 7 deletions src/gui/wizardform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

#include <QRegExp>
#include <QRegularExpression>
#include <QLineEdit>
#include <QLabel>
#include <QValidator>
#include <QComboBox>
#include <QTextStream>
#include "gui.h"
#include <QFile>
#include <QRegExpValidator>
#include <QRegularExpressionValidator>
#include "wizardform.h"

#define PROV_NONE QT_TRANSLATE_NOOP("WizardForm", "None (direct IP to IP calls)")
Expand Down Expand Up @@ -70,13 +70,13 @@ void WizardForm::languageChange()

void WizardForm::init()
{
QRegExp rxNoSpace("\\S*");
QRegularExpression rxNoSpace("\\S*");

// Set validators
usernameLineEdit->setValidator(new QRegExpValidator(rxNoSpace, this));
domainLineEdit->setValidator(new QRegExpValidator(rxNoSpace, this));
authNameLineEdit->setValidator(new QRegExpValidator(rxNoSpace, this));
proxyLineEdit->setValidator(new QRegExpValidator(rxNoSpace, this));
usernameLineEdit->setValidator(new QRegularExpressionValidator(rxNoSpace, this));
domainLineEdit->setValidator(new QRegularExpressionValidator(rxNoSpace, this));
authNameLineEdit->setValidator(new QRegularExpressionValidator(rxNoSpace, this));
proxyLineEdit->setValidator(new QRegularExpressionValidator(rxNoSpace, this));

initProviders();
serviceProviderComboBox->setCurrentIndex(serviceProviderComboBox->count() - 1);
Expand Down