Qt6: remove QRegExp

This commit is contained in:
tobtoht 2022-03-04 11:05:20 +01:00
parent f5fe91eb5c
commit fc0d5c2021
No known key found for this signature in database
GPG key ID: 1CADD27F41F45C3C
20 changed files with 42 additions and 44 deletions

View file

@ -26,9 +26,9 @@ CalcWidget::CalcWidget(QWidget *parent)
// validator/locale for input // validator/locale for input
QString amount_rx = R"(^\d{0,8}[\.]\d{0,12}$)"; QString amount_rx = R"(^\d{0,8}[\.]\d{0,12}$)";
QRegExp rx; QRegularExpression rx;
rx.setPattern(amount_rx); rx.setPattern(amount_rx);
QValidator *validator = new QRegExpValidator(rx, this); QValidator *validator = new QRegularExpressionValidator(rx, this);
ui->lineFrom->setValidator(validator); ui->lineFrom->setValidator(validator);
ui->lineTo->setValidator(validator); ui->lineTo->setValidator(validator);

View file

@ -24,9 +24,9 @@ SendWidget::SendWidget(QSharedPointer<AppContext> ctx, QWidget *parent)
ui->setupUi(this); ui->setupUi(this);
QString amount_rx = R"(^\d{0,8}[\.,]\d{0,12}|(all)$)"; QString amount_rx = R"(^\d{0,8}[\.,]\d{0,12}|(all)$)";
QRegExp rx; QRegularExpression rx;
rx.setPattern(amount_rx); rx.setPattern(amount_rx);
QValidator *validator = new QRegExpValidator(rx, this); QValidator *validator = new QRegularExpressionValidator(rx, this);
ui->lineAmount->setValidator(validator); ui->lineAmount->setValidator(validator);
connect(m_ctx.get(), &AppContext::initiateTransaction, this, &SendWidget::onInitiateTransaction); connect(m_ctx.get(), &AppContext::initiateTransaction, this, &SendWidget::onInitiateTransaction);

View file

@ -7,7 +7,7 @@
#include <QClipboard> #include <QClipboard>
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
#include <QRegExpValidator> #include <QRegularExpressionValidator>
#include "WalletManager.h" #include "WalletManager.h"
@ -20,9 +20,9 @@ PaymentRequestDialog::PaymentRequestDialog(QWidget *parent, QSharedPointer<AppCo
ui->setupUi(this); ui->setupUi(this);
QString amount_rx = R"(^\d{0,8}[\.]\d{0,12}|(all)$)"; QString amount_rx = R"(^\d{0,8}[\.]\d{0,12}|(all)$)";
QRegExp rx; QRegularExpression rx;
rx.setPattern(amount_rx); rx.setPattern(amount_rx);
QValidator *validator = new QRegExpValidator(rx, this); QValidator *validator = new QRegularExpressionValidator(rx, this);
ui->line_amountXMR->setValidator(validator); ui->line_amountXMR->setValidator(validator);
connect(ui->line_amountXMR, &QLineEdit::textChanged, this, &PaymentRequestDialog::updatePaymentRequest); connect(ui->line_amountXMR, &QLineEdit::textChanged, this, &PaymentRequestDialog::updatePaymentRequest);

View file

@ -218,8 +218,8 @@ QString WalletManager::displayAmount(quint64 amount, bool trailing_zeroes, int d
} }
if (!trailing_zeroes) { if (!trailing_zeroes) {
amountStr.remove(QRegExp("0+$")); amountStr.remove(QRegularExpression("0+$"));
amountStr.remove(QRegExp("\\.$")); amountStr.remove(QRegularExpression("\\.$"));
} }
return amountStr; return amountStr;

View file

@ -8,8 +8,7 @@ AddressBookProxyModel::AddressBookProxyModel(QObject *parent)
: QSortFilterProxyModel(parent), : QSortFilterProxyModel(parent),
m_searchRegExp("") m_searchRegExp("")
{ {
m_searchRegExp.setCaseSensitivity(Qt::CaseInsensitive); m_searchRegExp.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
m_searchRegExp.setPatternSyntax(QRegExp::RegExp);
} }
bool AddressBookProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const bool AddressBookProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const

View file

@ -22,7 +22,7 @@ public slots:
} }
private: private:
QRegExp m_searchRegExp; QRegularExpression m_searchRegExp;
}; };
#endif //FEATHER_ADDRESSBOOKPROXYMODEL_H #endif //FEATHER_ADDRESSBOOKPROXYMODEL_H

View file

@ -10,9 +10,7 @@ SubaddressProxyModel::SubaddressProxyModel(QObject *parent, Subaddress *subaddre
, m_searchCaseSensitiveRegExp("") , m_searchCaseSensitiveRegExp("")
, m_hidePrimary(hidePrimary) , m_hidePrimary(hidePrimary)
{ {
m_searchRegExp.setCaseSensitivity(Qt::CaseInsensitive); m_searchRegExp.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
m_searchRegExp.setPatternSyntax(QRegExp::FixedString);
m_searchCaseSensitiveRegExp.setPatternSyntax(QRegExp::FixedString);
} }
bool SubaddressProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const bool SubaddressProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const
@ -33,7 +31,7 @@ bool SubaddressProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &so
return false; return false;
} }
if (!m_searchRegExp.isEmpty()) { if (!m_searchRegExp.pattern().isEmpty()) {
return address.contains(m_searchCaseSensitiveRegExp) || label.contains(m_searchRegExp); return address.contains(m_searchCaseSensitiveRegExp) || label.contains(m_searchRegExp);
} }
return (m_showUsed || !isUsed); return (m_showUsed || !isUsed);

View file

@ -42,8 +42,8 @@ private:
Subaddress *m_subaddress; Subaddress *m_subaddress;
QStringList m_hiddenAddresses; QStringList m_hiddenAddresses;
QRegExp m_searchRegExp; QRegularExpression m_searchRegExp;
QRegExp m_searchCaseSensitiveRegExp; QRegularExpression m_searchCaseSensitiveRegExp;
bool m_showUsed = false; bool m_showUsed = false;
bool m_showHidden = false; bool m_showHidden = false;
bool m_hidePrimary; bool m_hidePrimary;

View file

@ -22,7 +22,7 @@ WalletKeysFile::WalletKeysFile(const QFileInfo &info, int networkType, QString a
qint64 WalletKeysFile::getModified(const QFileInfo &info) { qint64 WalletKeysFile::getModified(const QFileInfo &info) {
qint64 m = info.lastModified().toSecsSinceEpoch(); qint64 m = info.lastModified().toSecsSinceEpoch();
QFileInfo cacheFile = QFileInfo(info.absoluteFilePath().replace(QRegExp(".keys$"), "")); QFileInfo cacheFile = QFileInfo(info.absoluteFilePath().replace(QRegularExpression(".keys$"), ""));
qint64 cacheLastModified = cacheFile.lastModified().toSecsSinceEpoch(); qint64 cacheLastModified = cacheFile.lastModified().toSecsSinceEpoch();
if (cacheFile.exists() && cacheLastModified > m) { if (cacheFile.exists() && cacheLastModified > m) {
m = cacheLastModified; m = cacheLastModified;
@ -73,8 +73,7 @@ void WalletKeysFilesModel::findWallets() {
qDebug() << "wallet .keys search initiated"; qDebug() << "wallet .keys search initiated";
auto now = high_resolution_clock::now(); auto now = high_resolution_clock::now();
QRegExp rx("*.keys"); QRegularExpression rx(QRegularExpression::wildcardToRegularExpression("*.keys"));
rx.setPatternSyntax(QRegExp::Wildcard);
QStringList walletPaths; QStringList walletPaths;
for(auto i = 0; i != m_walletDirectories.length(); i++) { for(auto i = 0; i != m_walletDirectories.length(); i++) {

View file

@ -4,7 +4,6 @@
#include "utils/TorManager.h" #include "utils/TorManager.h"
#include <QScreen> #include <QScreen>
#include <QDesktopWidget>
#include <QDesktopServices> #include <QDesktopServices>
#include <QRegularExpression> #include <QRegularExpression>

View file

@ -7,7 +7,7 @@
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <iostream> #include <iostream>
#include <QRegExp> #include <QRegularExpression>
#include <QtNetwork> #include <QtNetwork>
#include "utils/childproc.h" #include "utils/childproc.h"
#include "utils/SemanticVersion.h" #include "utils/SemanticVersion.h"

View file

@ -67,7 +67,7 @@ bool pixmapWrite(const QString &path, const QPixmap &pixmap) {
return false; return false;
} }
QStringList fileFind(const QRegExp &pattern, const QString &baseDir, int level, int depth, const int maxPerDir) { QStringList fileFind(const QRegularExpression &pattern, const QString &baseDir, int level, int depth, const int maxPerDir) {
// like `find /foo -name -maxdepth 2 "*.jpg"` // like `find /foo -name -maxdepth 2 "*.jpg"`
QStringList rtn; QStringList rtn;
QDir dir(baseDir); QDir dir(baseDir);
@ -83,13 +83,17 @@ QStringList fileFind(const QRegExp &pattern, const QString &baseDir, int level,
const auto fn = fileInfo.fileName(); const auto fn = fileInfo.fileName();
const auto path = fileInfo.filePath(); const auto path = fileInfo.filePath();
QRegularExpression re(QRegularExpression::anchoredPattern(pattern.pattern()));
QRegularExpressionMatch match = re.match(fn);
if (fileInfo.isDir()) { if (fileInfo.isDir()) {
if (level + 1 <= depth) if (level + 1 <= depth)
rtn << fileFind(pattern, path, level + 1, depth, maxPerDir); rtn << fileFind(pattern, path, level + 1, depth, maxPerDir);
} }
else if (pattern.exactMatch(fn)) else if (match.hasMatch()) {
rtn << path; rtn << path;
} }
}
return rtn; return rtn;
} }

View file

@ -4,7 +4,7 @@
#ifndef FEATHER_UTILS_H #ifndef FEATHER_UTILS_H
#define FEATHER_UTILS_H #define FEATHER_UTILS_H
#include <QRegExp> #include <QRegularExpression>
#include <QStandardItemModel> #include <QStandardItemModel>
#include <QApplication> #include <QApplication>
#include <QTextCharFormat> #include <QTextCharFormat>
@ -19,7 +19,7 @@ namespace Utils
QByteArray fileOpenQRC(const QString &path); QByteArray fileOpenQRC(const QString &path);
bool fileWrite(const QString &path, const QString &data); bool fileWrite(const QString &path, const QString &data);
bool pixmapWrite(const QString &path, const QPixmap &pixmap); bool pixmapWrite(const QString &path, const QPixmap &pixmap);
QStringList fileFind(const QRegExp &pattern, const QString &baseDir, int level, int depth, int maxPerDir); QStringList fileFind(const QRegularExpression &pattern, const QString &baseDir, int level, int depth, int maxPerDir);
bool dirExists(const QString &path); bool dirExists(const QString &path);
QString defaultWalletDir(); QString defaultWalletDir();

View file

@ -4,7 +4,7 @@
#ifndef FEATHER_NETWORKING_H #ifndef FEATHER_NETWORKING_H
#define FEATHER_NETWORKING_H #define FEATHER_NETWORKING_H
#include <QRegExp> #include <QRegularExpression>
#include <QtNetwork> #include <QtNetwork>
#include <QNetworkAccessManager> #include <QNetworkAccessManager>
#include <QNetworkReply> #include <QNetworkReply>

View file

@ -5,7 +5,7 @@
#define FEATHER_NODES_H #define FEATHER_NODES_H
#include <QTimer> #include <QTimer>
#include <QRegExp> #include <QRegularExpression>
#include <QApplication> #include <QApplication>
#include <QtNetwork> #include <QtNetwork>
#include <QNetworkAccessManager> #include <QNetworkAccessManager>

View file

@ -1,7 +1,7 @@
// SPDX-License-Identifier: BSD-3-Clause // SPDX-License-Identifier: BSD-3-Clause
// SPDX-FileCopyrightText: 2020-2022 The Monero Project // SPDX-FileCopyrightText: 2020-2022 The Monero Project
#include <QRegExp> #include <QRegularExpression>
#include <QMessageBox> #include <QMessageBox>
#include "tails.h" #include "tails.h"
@ -50,10 +50,10 @@ QString TailsOS::version()
return ""; return "";
QByteArray data = Utils::fileOpen("/etc/os-release"); QByteArray data = Utils::fileOpen("/etc/os-release");
QRegExp re(R"(TAILS_VERSION_ID="(\d+.\d+))"); QRegularExpression re(R"(TAILS_VERSION_ID="(\d+.\d+))");
int pos = re.indexIn(data); QRegularExpressionMatch match = re.match(data);
if (pos >= 0) { if (match.hasMatch()) {
return re.cap(1); return match.captured(1);
} }
return ""; return "";
} }

View file

@ -2,7 +2,6 @@
// SPDX-FileCopyrightText: 2020-2022 The Monero Project // SPDX-FileCopyrightText: 2020-2022 The Monero Project
#include <QScreen> #include <QScreen>
#include <QDesktopWidget>
#include <QDesktopServices> #include <QDesktopServices>
#include "utils/Utils.h" #include "utils/Utils.h"

View file

@ -7,7 +7,7 @@
#include <cstdio> #include <cstdio>
#include <cstdlib> #include <cstdlib>
#include <iostream> #include <iostream>
#include <QRegExp> #include <QRegularExpression>
#include <QtNetwork> #include <QtNetwork>
#include <QApplication> #include <QApplication>
#include <QMainWindow> #include <QMainWindow>

View file

@ -15,12 +15,12 @@ RestoreHeightWidget::RestoreHeightWidget(QWidget *parent)
{ {
ui->setupUi(this); ui->setupUi(this);
QRegExp yearRe(R"(\d{2,4}-\d{1,2}-\d{1,2})"); QRegularExpression yearRe(R"(\d{2,4}-\d{1,2}-\d{1,2})");
QValidator *yearValidator = new QRegExpValidator(yearRe, this); QValidator *yearValidator = new QRegularExpressionValidator(yearRe, this);
ui->line_creationDate->setValidator(yearValidator); ui->line_creationDate->setValidator(yearValidator);
QRegExp heightRe(R"(\d{7})"); QRegularExpression heightRe(R"(\d{7})");
QValidator *heightValidator = new QRegExpValidator(heightRe, this); QValidator *heightValidator = new QRegularExpressionValidator(heightRe, this);
ui->line_restoreHeight->setValidator(heightValidator); ui->line_restoreHeight->setValidator(heightValidator);
connect(ui->line_creationDate, &QLineEdit::textEdited, this, &RestoreHeightWidget::onCreationDateChanged); connect(ui->line_creationDate, &QLineEdit::textEdited, this, &RestoreHeightWidget::onCreationDateChanged);

View file

@ -14,12 +14,12 @@ PageSetRestoreHeight::PageSetRestoreHeight(WizardFields *fields, QWidget *parent
{ {
ui->setupUi(this); ui->setupUi(this);
QRegExp yearRe(R"(\d{2,4}-\d{1,2}-\d{1,2})"); QRegularExpression yearRe(R"(\d{2,4}-\d{1,2}-\d{1,2})");
QValidator *yearValidator = new QRegExpValidator(yearRe, this); QValidator *yearValidator = new QRegularExpressionValidator(yearRe, this);
ui->line_creationDate->setValidator(yearValidator); ui->line_creationDate->setValidator(yearValidator);
QRegExp heightRe(R"(\d{7})"); QRegularExpression heightRe(R"(\d{7})");
QValidator *heightValidator = new QRegExpValidator(heightRe, this); QValidator *heightValidator = new QRegularExpressionValidator(heightRe, this);
ui->line_restoreHeight->setValidator(heightValidator); ui->line_restoreHeight->setValidator(heightValidator);
QPixmap pixmap = QPixmap(":/assets/images/unpaid.png"); QPixmap pixmap = QPixmap(":/assets/images/unpaid.png");