Core: Replace some QRegExp by QRegularExpression

Task-number: QTCREATORBUG-24098
Change-Id: I25d90bfdb0c07cea0c076ad7b9f04886d751600a
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Stenger
2020-06-16 12:00:16 +02:00
parent b402215daf
commit 0795d5f42d
4 changed files with 12 additions and 10 deletions

View File

@@ -95,13 +95,15 @@ static QVector<QString> splitInTwoLines(const QString &text,
// to put them in the second line. First line is drawn with ellipsis,
// second line gets ellipsis if it couldn't split off full words.
QVector<QString> splitLines(2);
const QRegExp rx(QLatin1String("\\s+"));
const QRegularExpression rx(QLatin1String("\\s+"));
int splitPos = -1;
int nextSplitPos = text.length();
do {
nextSplitPos = rx.lastIndexIn(text, nextSplitPos - text.length() - 1);
int offset = nextSplitPos - text.length() - 1;
nextSplitPos = text.lastIndexOf(rx, offset);
if (nextSplitPos != -1) {
int splitCandidate = nextSplitPos + rx.matchedLength();
const QRegularExpressionMatch match = rx.match(text, offset);
int splitCandidate = nextSplitPos + match.capturedLength();
if (fontMetrics.horizontalAdvance(text.mid(splitCandidate)) <= availableWidth)
splitPos = splitCandidate;
else