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:
0--- a/src/qt/utilitydialog.cpp
1+++ b/src/qt/utilitydialog.cpp
2@@ -23,6 +23,7 @@
3 #include <QLabel>
4 #include <QMainWindow>
5 #include <QRegularExpression>
6+#include <QString>
7 #include <QTextCursor>
8 #include <QTextTable>
9 #include <QVBoxLayout>
10@@ -44,8 +45,8 @@ HelpMessageDialog::HelpMessageDialog(QWidget *parent, bool about) :
11 /// HTML-format the license message from the core
12 QString licenseInfoHTML = QString::fromStdString(LicenseInfo());
13 // Make URLs clickable
14- QRegularExpression uri("<(.*)>", QRegularExpression::InvertedGreedinessOption);
15- licenseInfoHTML.replace(uri, "<a href=\"\\1\">\\1</a>");
16+ QRegularExpression uri(QStringLiteral("<(.*)>"), QRegularExpression::InvertedGreedinessOption);
17+ licenseInfoHTML.replace(uri, QStringLiteral("<a href=\"\\1\">\\1</a>"));
18 // Replace newlines with HTML breaks
19 licenseInfoHTML.replace("\n", "<br>");
20
Still reviewing guiutil.cpp
changes.
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:
0--- a/src/qt/guiutil.cpp
1+++ b/src/qt/guiutil.cpp
2@@ -311,7 +311,7 @@ QString getSaveFileName(QWidget *parent, const QString &caption, const QString &
3 QString result = QDir::toNativeSeparators(QFileDialog::getSaveFileName(parent, caption, myDir, filter, &selectedFilter));
4
5 /* Extract first suffix from filter pattern "Description (*.foo)" or "Description (*.foo *.bar ...) */
6- QRegularExpression filter_re(".* \\(\\*\\.(.*)[ \\)]");
7+ QRegularExpression filter_re(QStringLiteral(".* \\(\\*\\.(.*)[ \\)]"), QRegularExpression::InvertedGreedinessOption);
8 QString selectedSuffix;
9 QRegularExpressionMatch m = filter_re.match(selectedFilter);
10 if(m.hasMatch())
Echoing: #585 (comment)
Agree.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
No conflicts as of last run.