Example: migrate the arthur code sample to use QRegularExpression

Update the arthur code sample to use the new QRegularExpression class
in place of the deprecated QRegExp.

Change-Id: Ic7efd4466b4c0fa50170b80ebb22fcb3624399ce
Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com>
This commit is contained in:
Samuel Gaist 2017-01-21 21:52:20 +01:00
parent d2e713f3fd
commit beb98bdafc

View File

@ -59,6 +59,7 @@
#include <QFile>
#include <QTextBrowser>
#include <QBoxLayout>
#include <QRegularExpression>
extern QPixmap cached(const QString &img);
@ -339,14 +340,12 @@ void ArthurFrame::showSource()
foreach (QString keyword, ppKeywords)
contents.replace(keyword, QLatin1String("<font color=navy>") + keyword + QLatin1String("</font>"));
contents.replace(QRegExp("(\\d\\d?)"), QLatin1String("<font color=navy>\\1</font>"));
contents.replace(QRegularExpression("(\\d\\d?)"), QLatin1String("<font color=navy>\\1</font>"));
QRegExp commentRe("(//.+)\\n");
commentRe.setMinimal(true);
QRegularExpression commentRe("(//.+?)\\n");
contents.replace(commentRe, QLatin1String("<font color=red>\\1</font>\n"));
QRegExp stringLiteralRe("(\".+\")");
stringLiteralRe.setMinimal(true);
QRegularExpression stringLiteralRe("(\".+?\")");
contents.replace(stringLiteralRe, QLatin1String("<font color=green>\\1</font>"));
QString html = contents;