Replace use of QRegExp
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user