forked from qt-creator/qt-creator
Core: Replace some QRegExp by QRegularExpression
Task-number: QTCREATORBUG-24098 Change-Id: I25d90bfdb0c07cea0c076ad7b9f04886d751600a Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -33,7 +33,6 @@
|
|||||||
#include <utils/stringutils.h>
|
#include <utils/stringutils.h>
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QRegExp>
|
|
||||||
#include <QToolButton>
|
#include <QToolButton>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
|
||||||
|
@@ -653,7 +653,7 @@ static QString getUserFilePath(const QString &proposalFileName)
|
|||||||
static QString idFromDisplayName(const QString &displayName)
|
static QString idFromDisplayName(const QString &displayName)
|
||||||
{
|
{
|
||||||
QString id = displayName;
|
QString id = displayName;
|
||||||
id.remove(QRegExp(QLatin1String("&(?!&)")));
|
id.remove(QRegularExpression("&(?!&)"));
|
||||||
QChar *c = id.data();
|
QChar *c = id.data();
|
||||||
while (!c->isNull()) {
|
while (!c->isNull()) {
|
||||||
if (!c->isLetterOrNumber())
|
if (!c->isLetterOrNumber())
|
||||||
|
@@ -818,14 +818,15 @@ QString DocumentManager::getSaveFileName(const QString &title, const QString &pa
|
|||||||
// first one from the filter is appended.
|
// first one from the filter is appended.
|
||||||
if (selectedFilter && *selectedFilter != Utils::allFilesFilterString()) {
|
if (selectedFilter && *selectedFilter != Utils::allFilesFilterString()) {
|
||||||
// Mime database creates filter strings like this: Anything here (*.foo *.bar)
|
// Mime database creates filter strings like this: Anything here (*.foo *.bar)
|
||||||
QRegExp regExp(QLatin1String(".*\\s+\\((.*)\\)$"));
|
const QRegularExpression regExp(QLatin1String(".*\\s+\\((.*)\\)$"));
|
||||||
const int index = regExp.lastIndexIn(*selectedFilter);
|
QRegularExpressionMatchIterator matchIt = regExp.globalMatch(*selectedFilter);
|
||||||
if (index != -1) {
|
if (matchIt.hasNext()) {
|
||||||
bool suffixOk = false;
|
bool suffixOk = false;
|
||||||
QString caption = regExp.cap(1);
|
const QRegularExpressionMatch match = matchIt.next();
|
||||||
|
QString caption = match.captured(1);
|
||||||
caption.remove(QLatin1Char('*'));
|
caption.remove(QLatin1Char('*'));
|
||||||
const QVector<QStringRef> suffixes = caption.splitRef(QLatin1Char(' '));
|
const QVector<QStringRef> suffixes = caption.splitRef(QLatin1Char(' '));
|
||||||
foreach (const QStringRef &suffix, suffixes)
|
for (const QStringRef &suffix : suffixes)
|
||||||
if (fileName.endsWith(suffix)) {
|
if (fileName.endsWith(suffix)) {
|
||||||
suffixOk = true;
|
suffixOk = true;
|
||||||
break;
|
break;
|
||||||
|
@@ -95,13 +95,15 @@ static QVector<QString> splitInTwoLines(const QString &text,
|
|||||||
// to put them in the second line. First line is drawn with ellipsis,
|
// 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.
|
// second line gets ellipsis if it couldn't split off full words.
|
||||||
QVector<QString> splitLines(2);
|
QVector<QString> splitLines(2);
|
||||||
const QRegExp rx(QLatin1String("\\s+"));
|
const QRegularExpression rx(QLatin1String("\\s+"));
|
||||||
int splitPos = -1;
|
int splitPos = -1;
|
||||||
int nextSplitPos = text.length();
|
int nextSplitPos = text.length();
|
||||||
do {
|
do {
|
||||||
nextSplitPos = rx.lastIndexIn(text, nextSplitPos - text.length() - 1);
|
int offset = nextSplitPos - text.length() - 1;
|
||||||
|
nextSplitPos = text.lastIndexOf(rx, offset);
|
||||||
if (nextSplitPos != -1) {
|
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)
|
if (fontMetrics.horizontalAdvance(text.mid(splitCandidate)) <= availableWidth)
|
||||||
splitPos = splitCandidate;
|
splitPos = splitCandidate;
|
||||||
else
|
else
|
||||||
|
Reference in New Issue
Block a user