diff --git a/src/CalcWidget.cpp b/src/CalcWidget.cpp index 69050d7..6e0bef7 100644 --- a/src/CalcWidget.cpp +++ b/src/CalcWidget.cpp @@ -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); diff --git a/src/SendWidget.cpp b/src/SendWidget.cpp index ee54473..920ec8a 100644 --- a/src/SendWidget.cpp +++ b/src/SendWidget.cpp @@ -24,9 +24,9 @@ SendWidget::SendWidget(QSharedPointer 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); diff --git a/src/dialog/PaymentRequestDialog.cpp b/src/dialog/PaymentRequestDialog.cpp index bac57cd..6eeb3b0 100644 --- a/src/dialog/PaymentRequestDialog.cpp +++ b/src/dialog/PaymentRequestDialog.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include "WalletManager.h" @@ -20,9 +20,9 @@ PaymentRequestDialog::PaymentRequestDialog(QWidget *parent, QSharedPointersetupUi(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); diff --git a/src/libwalletqt/WalletManager.cpp b/src/libwalletqt/WalletManager.cpp index 07172f7..eabba96 100644 --- a/src/libwalletqt/WalletManager.cpp +++ b/src/libwalletqt/WalletManager.cpp @@ -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; diff --git a/src/model/AddressBookProxyModel.cpp b/src/model/AddressBookProxyModel.cpp index fbc13be..2e90678 100644 --- a/src/model/AddressBookProxyModel.cpp +++ b/src/model/AddressBookProxyModel.cpp @@ -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 diff --git a/src/model/AddressBookProxyModel.h b/src/model/AddressBookProxyModel.h index 52244e3..4649250 100644 --- a/src/model/AddressBookProxyModel.h +++ b/src/model/AddressBookProxyModel.h @@ -22,7 +22,7 @@ public slots: } private: - QRegExp m_searchRegExp; + QRegularExpression m_searchRegExp; }; #endif //FEATHER_ADDRESSBOOKPROXYMODEL_H diff --git a/src/model/SubaddressProxyModel.cpp b/src/model/SubaddressProxyModel.cpp index 25e7a26..1462b40 100644 --- a/src/model/SubaddressProxyModel.cpp +++ b/src/model/SubaddressProxyModel.cpp @@ -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); diff --git a/src/model/SubaddressProxyModel.h b/src/model/SubaddressProxyModel.h index 9de57c0..65a8964 100644 --- a/src/model/SubaddressProxyModel.h +++ b/src/model/SubaddressProxyModel.h @@ -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; diff --git a/src/model/WalletKeysFilesModel.cpp b/src/model/WalletKeysFilesModel.cpp index ec4da23..4fe4bdc 100644 --- a/src/model/WalletKeysFilesModel.cpp +++ b/src/model/WalletKeysFilesModel.cpp @@ -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++) { diff --git a/src/utils/TorManager.cpp b/src/utils/TorManager.cpp index b3ddf08..5df79e3 100644 --- a/src/utils/TorManager.cpp +++ b/src/utils/TorManager.cpp @@ -4,7 +4,6 @@ #include "utils/TorManager.h" #include -#include #include #include diff --git a/src/utils/TorManager.h b/src/utils/TorManager.h index a196d15..aef48cb 100644 --- a/src/utils/TorManager.h +++ b/src/utils/TorManager.h @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include "utils/childproc.h" #include "utils/SemanticVersion.h" diff --git a/src/utils/Utils.cpp b/src/utils/Utils.cpp index 96e525c..157f415 100644 --- a/src/utils/Utils.cpp +++ b/src/utils/Utils.cpp @@ -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; } diff --git a/src/utils/Utils.h b/src/utils/Utils.h index 1749160..349bf2f 100644 --- a/src/utils/Utils.h +++ b/src/utils/Utils.h @@ -4,7 +4,7 @@ #ifndef FEATHER_UTILS_H #define FEATHER_UTILS_H -#include +#include #include #include #include @@ -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(); diff --git a/src/utils/networking.h b/src/utils/networking.h index 41e96b0..9aab733 100644 --- a/src/utils/networking.h +++ b/src/utils/networking.h @@ -4,7 +4,7 @@ #ifndef FEATHER_NETWORKING_H #define FEATHER_NETWORKING_H -#include +#include #include #include #include diff --git a/src/utils/nodes.h b/src/utils/nodes.h index 1cbb298..0477842 100644 --- a/src/utils/nodes.h +++ b/src/utils/nodes.h @@ -5,7 +5,7 @@ #define FEATHER_NODES_H #include -#include +#include #include #include #include diff --git a/src/utils/os/tails.cpp b/src/utils/os/tails.cpp index 45caf6c..d53d79b 100644 --- a/src/utils/os/tails.cpp +++ b/src/utils/os/tails.cpp @@ -1,7 +1,7 @@ // SPDX-License-Identifier: BSD-3-Clause // SPDX-FileCopyrightText: 2020-2022 The Monero Project -#include +#include #include #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 ""; } diff --git a/src/utils/xmrig.cpp b/src/utils/xmrig.cpp index e623fe5..534a524 100644 --- a/src/utils/xmrig.cpp +++ b/src/utils/xmrig.cpp @@ -2,7 +2,6 @@ // SPDX-FileCopyrightText: 2020-2022 The Monero Project #include -#include #include #include "utils/Utils.h" diff --git a/src/utils/xmrig.h b/src/utils/xmrig.h index a3f75e6..c914084 100644 --- a/src/utils/xmrig.h +++ b/src/utils/xmrig.h @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/widgets/RestoreHeightWidget.cpp b/src/widgets/RestoreHeightWidget.cpp index f6c7cd7..1b4c225 100644 --- a/src/widgets/RestoreHeightWidget.cpp +++ b/src/widgets/RestoreHeightWidget.cpp @@ -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); diff --git a/src/wizard/PageSetRestoreHeight.cpp b/src/wizard/PageSetRestoreHeight.cpp index 8f6690a..b5f44ca 100644 --- a/src/wizard/PageSetRestoreHeight.cpp +++ b/src/wizard/PageSetRestoreHeight.cpp @@ -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");