Replace QRegExp with QRegularExpression

Reviewers: kbasan, msutcliffe

Reviewed By: kbasan, msutcliffe

Subscribers: jenkins

Differential Revision: https://dev.swift-project.org/D11
This commit is contained in:
Mathew Sutcliffe
2017-05-05 22:35:25 +01:00
parent 94fbfeefdb
commit d5ab73e1bc
17 changed files with 55 additions and 54 deletions

View File

@@ -37,7 +37,7 @@
#include <QPlainTextEdit>
#include <QPushButton>
#include <QRadioButton>
#include <QRegExp>
#include <QRegularExpression>
#include <QTabBar>
#include <QCompleter>
#include <Qt>
@@ -270,9 +270,9 @@ namespace BlackGui
flightPlan.setTakeoffTimePlanned(v);
}
static const QRegExp withUnit("\\D+");
thread_local const QRegularExpression withUnit("\\D+");
v = ui->le_CrusingAltitude->text().trimmed();
if (!v.isEmpty() && withUnit.indexIn(v) < 0)
if (!v.isEmpty() && !withUnit.match(v).hasMatch())
{
v += "ft";
ui->le_CrusingAltitude->setText(v);

View File

@@ -13,6 +13,8 @@
#include "blackmisc/logmessage.h"
#include "blackconfig/buildconfig.h"
#include <QRegularExpression>
using namespace BlackMisc;
using namespace BlackMisc::Simulation;
using namespace BlackMisc::Simulation::FsCommon;
@@ -176,7 +178,7 @@ namespace BlackGui
const QString raw = rawString.trimmed();
if (raw.isEmpty()) { return QStringList(); }
QStringList dirs;
const QStringList rawLines = raw.split(QRegExp("\n|\r\n|\r"));
const QStringList rawLines = raw.split(QRegularExpression("\n|\r\n|\r"));
for (const QString &l : rawLines)
{
const QString normalized = CFileUtils::normalizeFilePathToQtStandard(l);

View File

@@ -229,10 +229,10 @@ namespace BlackGui
void CWeatherComponent::setupInputValidators()
{
QRegExp reIcaoOrLatitude("^[a-zA-Z]{4}|-?\\d{1,2}[,.]?\\d+$", Qt::CaseInsensitive);
ui->le_LatOrIcao->setValidator(new QRegExpValidator(reIcaoOrLatitude, this));
QRegExp reLongitude("^-?\\d{1,2}[,.]?\\d+$", Qt::CaseInsensitive);
ui->le_Lon->setValidator(new QRegExpValidator(reLongitude, this));
QRegularExpression reIcaoOrLatitude("^[a-zA-Z]{4}|-?\\d{1,2}[,.]?\\d+$", QRegularExpression::CaseInsensitiveOption);
ui->le_LatOrIcao->setValidator(new QRegularExpressionValidator(reIcaoOrLatitude, this));
QRegularExpression reLongitude("^-?\\d{1,2}[,.]?\\d+$", QRegularExpression::CaseInsensitiveOption);
ui->le_Lon->setValidator(new QRegularExpressionValidator(reLongitude, this));
}
void CWeatherComponent::setupCompleter()

View File

@@ -39,7 +39,7 @@
#include <QMenu>
#include <QMessageBox>
#include <QProcess>
#include <QRegExp>
#include <QRegularExpression>
#include <QSplashScreen>
#include <QStyleFactory>
#include <QStringList>
@@ -244,7 +244,7 @@ namespace BlackGui
html += "</td></tr>\n";
}
html += "<tr><td>";
static const QRegExp reg("[ ]{2,}");
thread_local const QRegularExpression reg("[ ]{2,}");
html += lt.replace(reg, "</td><td>");
pendingTr = true;
}

View File

@@ -21,7 +21,7 @@
#include <QFlags>
#include <QFont>
#include <QIODevice>
#include <QRegExp>
#include <QRegularExpression>
#include <QStyleOption>
#include <QStylePainter>
#include <QTextStream>
@@ -101,9 +101,8 @@ namespace BlackGui
{
const QString s = this->style(fileNameFonts()).toLower();
if (!s.contains("color:")) return "red";
QRegExp rx("color:\\s*(#*\\w+);");
rx.indexIn(s);
const QString c = rx.cap(1);
thread_local const QRegularExpression rx("color:\\s*(#*\\w+);");
const QString c = rx.match(s).captured(1);
return c.isEmpty() ? "red" : c;
}