]> Nutra Git (v1) - gamesguru/feather.git/commitdiff
Qt6: remove QRegExp
authortobtoht <thotbot@protonmail.com>
Fri, 4 Mar 2022 10:05:20 +0000 (11:05 +0100)
committertobtoht <thotbot@protonmail.com>
Fri, 4 Mar 2022 10:05:20 +0000 (11:05 +0100)
20 files changed:
src/CalcWidget.cpp
src/SendWidget.cpp
src/dialog/PaymentRequestDialog.cpp
src/libwalletqt/WalletManager.cpp
src/model/AddressBookProxyModel.cpp
src/model/AddressBookProxyModel.h
src/model/SubaddressProxyModel.cpp
src/model/SubaddressProxyModel.h
src/model/WalletKeysFilesModel.cpp
src/utils/TorManager.cpp
src/utils/TorManager.h
src/utils/Utils.cpp
src/utils/Utils.h
src/utils/networking.h
src/utils/nodes.h
src/utils/os/tails.cpp
src/utils/xmrig.cpp
src/utils/xmrig.h
src/widgets/RestoreHeightWidget.cpp
src/wizard/PageSetRestoreHeight.cpp

index 69050d758f5b0f63bea230c8a07e46befa4c666c..6e0bef7fa2b23f461d67bc407165fa74203c3d21 100644 (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);
 
index ee54473dfbf3685c1ad773b4216c19f6d4307bfa..920ec8a8fa133aa03041057bec6ca95511ae62f8 100644 (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);
index bac57cd2436613c79db5f3f02c52d1785c3e2e21..6eeb3b08b0a840b087830c798382eb68ad67f1c6 100644 (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);
index 07172f7d03274f768948a4a6c3b1121b6a835d23..eabba9661c56f4421c300f0bfa47e4d9e026d269 100644 (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;
index fbc13befb9cd501e98d05b581017c221292cf3d8..2e90678982c8287fcc98b16c37dbcbbedd56b4be 100644 (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
index 52244e3e685a492c24761cda757159c1f9d41dc2..464925036049b420827aa374cad005f46b574247 100644 (file)
@@ -22,7 +22,7 @@ public slots:
     }
 
 private:
-    QRegExp m_searchRegExp;
+    QRegularExpression m_searchRegExp;
 };
 
 #endif //FEATHER_ADDRESSBOOKPROXYMODEL_H
index 25e7a26eb608139b704ce75dbbdb5d99e75da93e..1462b4072573c0fc78e4a31945fd49e62fae759f 100644 (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);
index 9de57c0e8b25e0572f481a32f32bd1bd96eb86c6..65a8964aa2e5b518b90945a700a73880faf32e26 100644 (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;
index ec4da23c48a21ffc3a68100b41f42495a222b3d8..4fe4bdcb7ff62b6ee7600179f3ee930941cc449f 100644 (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++) {
index b3ddf080bca8d353e6cb6fe2196470e24035592f..5df79e3c9da76bf2e92656ed0303515b53ba5b5c 100644 (file)
@@ -4,7 +4,6 @@
 #include "utils/TorManager.h"
 
 #include <QScreen>
-#include <QDesktopWidget>
 #include <QDesktopServices>
 #include <QRegularExpression>
 
index a196d15df8b2d5d1e57596f5b09763bd9c07f179..aef48cb838fac994a0bfdc5ffe9d87d69d0d94b9 100644 (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"
index 96e525c1660463954bc64d24f978c1ef1d8225d3..157f415235dd9334c0eba974be9f008fed8a7831 100644 (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;
 }
index 1749160d6ebd7dbc418cf7ebcdd7aba8a021aed3..349bf2fc6f89d153c76468d154a5d6f5d8d0af21 100644 (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();
index 41e96b04d47628e54f65121601ceb38dd9fab73f..9aab733a52d07d6dfc2b7c7ee27010762a6d0aee 100644 (file)
@@ -4,7 +4,7 @@
 #ifndef FEATHER_NETWORKING_H
 #define FEATHER_NETWORKING_H
 
-#include <QRegExp>
+#include <QRegularExpression>
 #include <QtNetwork>
 #include <QNetworkAccessManager>
 #include <QNetworkReply>
index 1cbb29882993fc92c61f49b2a8f8500e452bc7ac..0477842f1c1648ea614602559936445b2a2b8530 100644 (file)
@@ -5,7 +5,7 @@
 #define FEATHER_NODES_H
 
 #include <QTimer>
-#include <QRegExp>
+#include <QRegularExpression>
 #include <QApplication>
 #include <QtNetwork>
 #include <QNetworkAccessManager>
index 45caf6c144c20b7090a5ce43f47860e4b5ee5cad..d53d79be5b4b8cb32e3145d0a8e7fa9ef3f7ea5c 100644 (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 "";
 }
index e623fe521c37f2dc3b9c3d2b1753e9994a9bfcf3..534a5248440f491c24330aec027c6c2082897fd3 100644 (file)
@@ -2,7 +2,6 @@
 // SPDX-FileCopyrightText: 2020-2022 The Monero Project
 
 #include <QScreen>
-#include <QDesktopWidget>
 #include <QDesktopServices>
 
 #include "utils/Utils.h"
index a3f75e642ae03482d78bbbcc7e1aff3c52f92283..c914084aa8917173e90b817d446755103674e0cb 100644 (file)
@@ -7,7 +7,7 @@
 #include <cstdio>
 #include <cstdlib>
 #include <iostream>
-#include <QRegExp>
+#include <QRegularExpression>
 #include <QtNetwork>
 #include <QApplication>
 #include <QMainWindow>
index f6c7cd713fa98d7de458cdfc2df2ffcbb9434fc2..1b4c225e1bf6fc9626e978e5c6cafc9a8edabeb2 100644 (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);
index 8f6690a8aa389c80b5cb31eeff6d0242e1a8ce78..b5f44ca5666ddbd682b70373d9776ff0c7d9c0fe 100644 (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");