Picking up #585
Replaces occurrences of QRegExp usage with QRegularExpression as part of the roadmap for Qt6 integration.
fixes #578
Concept ACK.
Suggesting to apply clang-format-diff.py and use QStringLiteral macro:
--- a/src/qt/utilitydialog.cpp
+++ b/src/qt/utilitydialog.cpp
@@ -23,6 +23,7 @@
#include <QLabel>
#include <QMainWindow>
#include <QRegularExpression>
+#include <QString>
#include <QTextCursor>
#include <QTextTable>
#include <QVBoxLayout>
@@ -44,8 +45,8 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) :
/// HTML-format the license message from the core
QString licenseInfoHTML = QString::fromStdString(LicenseInfo());
// Make URLs clickable
- QRegularExpression uri("<(.*)>", QRegularExpression::InvertedGreedinessOption);
- licenseInfoHTML.replace(uri, "<a href=\"\\1\">\\1</a>");
+ QRegularExpression uri(QStringLiteral("<(.*)>"), QRegularExpression::InvertedGreedinessOption);
+ licenseInfoHTML.replace(uri, QStringLiteral("<a href=\"\\1\">\\1</a>"));
// Replace newlines with HTML breaks
licenseInfoHTML.replace("\n", "<br>");
Still reviewing guiutil.cpp changes.
Echoing: #585 (comment)
It seems the code is broken both in master and in this branch. It does not do what is supposed to do https://github.com/bitcoin-core/gui/blob/dd19c1a2c69f84c73b8d3734c34c011ad3b9e18f/src/qt/guiutil.cpp#L313
I mean, it fails to extract first suffix from filter pattern "Description (*.foo *.bar ...)".
However, all of the callers in our codebase do not use patterns with multiple suffixes.
I mean, it fails to extract first suffix from filter pattern "Description (*.foo *.bar ...)".
Ok, an inversion of greediness will help:
--- a/src/qt/guiutil.cpp
+++ b/src/qt/guiutil.cpp
@@ -311,7 +311,7 @@ QString getSaveFileName(QWidget *parent, const QString &caption, const QString &
QString result = QDir::toNativeSeparators(QFileDialog::getSaveFileName(parent, caption, myDir, filter, &selectedFilter));
/* Extract first suffix from filter pattern "Description (*.foo)" or "Description (*.foo *.bar ...) */
- QRegularExpression filter_re(".* \\(\\*\\.(.*)[ \\)]");
+ QRegularExpression filter_re(QStringLiteral(".* \\(\\*\\.(.*)[ \\)]"), QRegularExpression::InvertedGreedinessOption);
QString selectedSuffix;
QRegularExpressionMatch m = filter_re.match(selectedFilter);
if(m.hasMatch())
Echoing: #585 (comment)
Agree.
<!--e57a25ab6845829454e8d69fc972939a-->
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
<!--174a7506f384e20aa4161008e828411d-->
No conflicts as of last run.
Labeled "Up for grabs"...