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
QString amount_rx = R"(^\d{0,8}[\.]\d{0,12}$)";
QRegExp rx;
QRegularExpression rx;
rx.setPattern(amount_rx);
QValidator *validator = new QRegExpValidator(rx, this);
QValidator *validator = new QRegularExpressionValidator(rx, this);
ui->lineFrom->setValidator(validator);
ui->lineTo->setValidator(validator);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -42,8 +42,8 @@ private:
Subaddress *m_subaddress;
QStringList m_hiddenAddresses;
QRegExp m_searchRegExp;
QRegExp m_searchCaseSensitiveRegExp;
QRegularExpression m_searchRegExp;
QRegularExpression m_searchCaseSensitiveRegExp;
bool m_showUsed = false;
bool m_showHidden = false;
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 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();
if (cacheFile.exists() && cacheLastModified > m) {
m = cacheLastModified;
@ -73,8 +73,7 @@ void WalletKeysFilesModel::findWallets() {
qDebug() << "wallet .keys search initiated";
auto now = high_resolution_clock::now();
QRegExp rx("*.keys");
rx.setPatternSyntax(QRegExp::Wildcard);
QRegularExpression rx(QRegularExpression::wildcardToRegularExpression("*.keys"));
QStringList walletPaths;
for(auto i = 0; i != m_walletDirectories.length(); i++) {

View file

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

View file

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

View file

@ -67,7 +67,7 @@ bool pixmapWrite(const QString &path, const QPixmap &pixmap) {
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"`
QStringList rtn;
QDir dir(baseDir);
@ -83,12 +83,16 @@ QStringList fileFind(const QRegExp &pattern, const QString &baseDir, int level,
const auto fn = fileInfo.fileName();
const auto path = fileInfo.filePath();
QRegularExpression re(QRegularExpression::anchoredPattern(pattern.pattern()));
QRegularExpressionMatch match = re.match(fn);
if (fileInfo.isDir()) {
if (level + 1 <= depth)
rtn << fileFind(pattern, path, level + 1, depth, maxPerDir);
}
else if (pattern.exactMatch(fn))
else if (match.hasMatch()) {
rtn << path;
}
}
return rtn;
}

View file

@ -4,7 +4,7 @@
#ifndef FEATHER_UTILS_H
#define FEATHER_UTILS_H
#include <QRegExp>
#include <QRegularExpression>
#include <QStandardItemModel>
#include <QApplication>
#include <QTextCharFormat>
@ -19,7 +19,7 @@ namespace Utils
QByteArray fileOpenQRC(const QString &path);
bool fileWrite(const QString &path, const QString &data);
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);
QString defaultWalletDir();

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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