Replace use of QRegExp

This commit is contained in:
Jonas Kvinge
2020-07-20 00:57:42 +02:00
parent eb270df835
commit 0b7b7656b2
15 changed files with 105 additions and 85 deletions

View File

@@ -36,7 +36,8 @@
#include <QIcon>
#include <QImage>
#include <QPixmap>
#include <QRegExp>
#include <QRegularExpression>
#include <QRegularExpressionMatch>
#include <QStyle>
#include <QHostAddress>
#include <QSsl>
@@ -344,16 +345,18 @@ void LocalRedirectServer::WriteTemplate() const {
page_file.open(QIODevice::ReadOnly);
QString page_data = QString::fromUtf8(page_file.readAll());
QRegExp tr_regexp("tr\\(\"([^\"]+)\"\\)");
QRegularExpression tr_regexp("tr\\(\"([^\"]+)\"\\)");
int offset = 0;
forever {
offset = tr_regexp.indexIn(page_data, offset);
QRegularExpressionMatch re_match = tr_regexp.match(page_data, offset);
if (!re_match.hasMatch()) break;
offset = re_match.capturedStart();
if (offset == -1) {
break;
}
page_data.replace(offset, tr_regexp.matchedLength(), tr(tr_regexp.cap(1).toUtf8()));
offset += tr_regexp.matchedLength();
page_data.replace(offset, re_match.capturedLength(), tr(re_match.captured(1).toUtf8()));
offset += re_match.capturedLength();
}
QBuffer image_buffer;