From 938f81c6012dd1556c8c0442b961e0e6256b83db Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 18 Jun 2020 09:44:44 +0200 Subject: [PATCH] More Qt 6 porting Task-number: QTCREATORBUG-24098 Change-Id: I8d118e75021996127344e75dffe263cebd95a5b8 Reviewed-by: Christian Stenger --- src/libs/utils/consoleprocess.cpp | 6 +-- src/libs/utils/htmldocextractor.cpp | 64 +++++++++++++---------------- src/libs/utils/templateengine.cpp | 2 +- 3 files changed, 32 insertions(+), 40 deletions(-) diff --git a/src/libs/utils/consoleprocess.cpp b/src/libs/utils/consoleprocess.cpp index 265610cc190..b0b684428ae 100644 --- a/src/libs/utils/consoleprocess.cpp +++ b/src/libs/utils/consoleprocess.cpp @@ -34,11 +34,11 @@ #include #include -#include #include #include #include #include +#include #include #include #include @@ -283,8 +283,8 @@ static QString quoteWinArgument(const QString &arg) QString ret(arg); // Quotes are escaped and their preceding backslashes are doubled. - ret.replace(QRegExp(QLatin1String("(\\\\*)\"")), QLatin1String("\\1\\1\\\"")); - if (ret.contains(QRegExp(QLatin1String("\\s")))) { + ret.replace(QRegularExpression("(\\\\*)\""), "\\1\\1\\\""); + if (ret.contains(QRegularExpression("\\s"))) { // The argument must not end with a \ since this would be interpreted // as escaping the quote -- rather put the \ behind the quote: e.g. // rather use "foo"\ than "foo\" diff --git a/src/libs/utils/htmldocextractor.cpp b/src/libs/utils/htmldocextractor.cpp index ac3246d2817..7eacb6f237a 100644 --- a/src/libs/utils/htmldocextractor.cpp +++ b/src/libs/utils/htmldocextractor.cpp @@ -26,17 +26,9 @@ #include "htmldocextractor.h" #include -#include +#include -using namespace Utils; - -namespace { - QRegExp createMinimalExp(const QString &pattern) { - QRegExp exp(pattern); - exp.setMinimal(true); - return exp; - } -} +namespace Utils { HtmlDocExtractor::HtmlDocExtractor() = default; @@ -100,7 +92,7 @@ QString HtmlDocExtractor::getFunctionDescription(const QString &html, startMark.append(QLatin1String("[overload1]")); } else { QString complement = mark.right(mark.length() - parenthesis); - complement.remove(QRegExp(QLatin1String("[\\(\\), ]"))); + complement.remove(QRegularExpression("[\\(\\), ]")); startMark.append(complement); } } @@ -115,10 +107,10 @@ QString HtmlDocExtractor::getFunctionDescription(const QString &html, // So I try to find the link to this property in the list of properties, extract its // anchor and then follow by the name found. const QString &pattern = - QString::fromLatin1("%1").arg(cleanMark); - QRegExp exp = createMinimalExp(pattern); - if (exp.indexIn(html) != -1) { - const QString &prop = exp.cap(1); + QString("%1").arg(cleanMark); + const QRegularExpressionMatch match = QRegularExpression(pattern).match(html); + if (match.hasMatch()) { + const QString &prop = match.captured(1); contents = getClassOrNamespaceMemberDescription(html, prop + QLatin1String("-prop"), prop); @@ -278,33 +270,32 @@ void HtmlDocExtractor::processOutput(QString *html) const void HtmlDocExtractor::stripAllHtml(QString *html) { - html->remove(createMinimalExp(QLatin1String("<.*>"))); + html->remove(QRegularExpression("<.*?>")); } void HtmlDocExtractor::stripHeadings(QString *html) { - html->remove(createMinimalExp(QLatin1String("|"))); + html->remove(QRegularExpression("|")); } void HtmlDocExtractor::stripLinks(QString *html) { - html->remove(createMinimalExp(QLatin1String("|"))); + html->remove(QRegularExpression("|")); } void HtmlDocExtractor::stripHorizontalLines(QString *html) { - html->remove(createMinimalExp(QLatin1String(""))); + html->remove(QRegularExpression("")); } void HtmlDocExtractor::stripDivs(QString *html) { - html->remove(createMinimalExp(QLatin1String("||"))); + html->remove(QRegularExpression("||")); } void HtmlDocExtractor::stripTagsStyles(QString *html) { - const QRegExp &exp = createMinimalExp(QLatin1String("<(.*\\s+)class=\".*\">")); - html->replace(exp, QLatin1String("<\\1>")); + html->replace(QRegularExpression("<(.*?\\s+)class=\".*?\">"), "<\\1>"); } void HtmlDocExtractor::stripTeletypes(QString *html) @@ -315,7 +306,7 @@ void HtmlDocExtractor::stripTeletypes(QString *html) void HtmlDocExtractor::stripImagens(QString *html) { - html->remove(createMinimalExp(QLatin1String(""))); + html->remove(QRegularExpression("")); } void HtmlDocExtractor::stripBold(QString *html) @@ -331,34 +322,35 @@ void HtmlDocExtractor::stripEmptyParagraphs(QString *html) void HtmlDocExtractor::replaceNonStyledHeadingsForBold(QString *html) { - const QRegExp &hStart = createMinimalExp(QLatin1String("")); - const QRegExp &hEnd = createMinimalExp(QLatin1String("")); + const QRegularExpression hStart(""); + const QRegularExpression hEnd(""); html->replace(hStart, QLatin1String("

")); html->replace(hEnd, QLatin1String("

")); } void HtmlDocExtractor::replaceTablesForSimpleLines(QString *html) { - html->replace(createMinimalExp(QLatin1String("(?:

)?")), QLatin1String("

")); + html->replace(QRegularExpression("(?:

)?"), QLatin1String("

")); html->replace(QLatin1String(""), QLatin1String("

")); - html->remove(createMinimalExp(QLatin1String(""))); + html->remove(QRegularExpression("")); html->remove(QLatin1String("")); - html->remove(createMinimalExp(QLatin1String(""))); + html->remove(QRegularExpression("")); html->remove(QLatin1String("")); - html->remove(createMinimalExp(QLatin1String(".*"))); + html->remove(QRegularExpression(".*?")); html->replace(QLatin1String(" remove(createMinimalExp(QLatin1String("

"))); - html->remove(createMinimalExp(QLatin1String(""))); - html->remove(createMinimalExp(QLatin1String("(?:

)?"))); - html->replace(createMinimalExp(QLatin1String("")), - QLatin1String("    ")); + html->remove(QRegularExpression("

")); + html->remove(QRegularExpression("")); + html->remove(QRegularExpression("(?:

)?")); + html->replace(QRegularExpression(""), QLatin1String("    ")); html->replace(QLatin1String(""), QLatin1String("
")); } void HtmlDocExtractor::replaceListsForSimpleLines(QString *html) { - html->remove(createMinimalExp(QLatin1String("<(?:ul|ol).*>"))); - html->remove(createMinimalExp(QLatin1String(""))); + html->remove(QRegularExpression("<(?:ul|ol).*?>")); + html->remove(QRegularExpression("")); html->replace(QLatin1String("
  • "), QLatin1String("    ")); html->replace(QLatin1String("
  • "), QLatin1String("
    ")); } + +} // namespace Utils diff --git a/src/libs/utils/templateengine.cpp b/src/libs/utils/templateengine.cpp index e78af8bc36a..7dacdd740dc 100644 --- a/src/libs/utils/templateengine.cpp +++ b/src/libs/utils/templateengine.cpp @@ -138,7 +138,7 @@ bool PreprocessContext::process(const QString &in, QString *out, QString *errorM reset(); const QChar newLine = QLatin1Char('\n'); - const QStringList lines = in.split(newLine, QString::KeepEmptyParts); + const QStringList lines = in.split(newLine); const int lineCount = lines.size(); bool first = true; for (int l = 0; l < lineCount; l++) {