TextEditor: Replace QRegExp by QRegularExpression

Task-number: QTCREATORBUG-24098
Change-Id: Id407154bd7d05bf5bbf07a804959e87452225c70
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Christian Stenger
2020-06-16 08:02:59 +02:00
parent 816a1df45a
commit 29e60f0741
3 changed files with 10 additions and 11 deletions

View File

@@ -172,8 +172,8 @@ void HighlighterSettings::assignDefaultDefinitionsPath()
bool HighlighterSettings::isIgnoredFilePattern(const QString &fileName) const
{
for (const QRegExp &regExp : m_ignoredFiles)
if (regExp.indexIn(fileName) != -1)
for (const QRegularExpression &regExp : m_ignoredFiles)
if (fileName.indexOf(regExp) != -1)
return true;
return false;
@@ -188,11 +188,10 @@ bool HighlighterSettings::equals(const HighlighterSettings &highlighterSettings)
void HighlighterSettings::setExpressionsFromList(const QStringList &patterns)
{
m_ignoredFiles.clear();
QRegExp regExp;
regExp.setCaseSensitivity(Qt::CaseInsensitive);
regExp.setPatternSyntax(QRegExp::Wildcard);
QRegularExpression regExp;
regExp.setPatternOptions(QRegularExpression::CaseInsensitiveOption);
for (const QString &pattern : patterns) {
regExp.setPattern(pattern);
regExp.setPattern(QRegularExpression::wildcardToRegularExpression(pattern));
m_ignoredFiles.append(regExp);
}
}
@@ -200,7 +199,7 @@ void HighlighterSettings::setExpressionsFromList(const QStringList &patterns)
QStringList HighlighterSettings::listFromExpressions() const
{
QStringList patterns;
for (const QRegExp &regExp : m_ignoredFiles)
for (const QRegularExpression &regExp : m_ignoredFiles)
patterns.append(regExp.pattern());
return patterns;
}

View File

@@ -28,7 +28,7 @@
#include <QString>
#include <QStringList>
#include <QList>
#include <QRegExp>
#include <QRegularExpression>
QT_BEGIN_NAMESPACE
class QSettings;
@@ -61,7 +61,7 @@ private:
QStringList listFromExpressions() const;
QString m_definitionFilesPath;
QList<QRegExp> m_ignoredFiles;
QList<QRegularExpression> m_ignoredFiles;
};
inline bool operator==(const HighlighterSettings &a, const HighlighterSettings &b)

View File

@@ -1836,7 +1836,7 @@ void TextEditorWidget::joinLines()
QString cutLine = cursor.selectedText();
// Collapse leading whitespaces to one or insert whitespace
cutLine.replace(QRegExp(QLatin1String("^\\s*")), QLatin1String(" "));
cutLine.replace(QRegularExpression(QLatin1String("^\\s*")), QLatin1String(" "));
cursor.movePosition(QTextCursor::Right, QTextCursor::KeepAnchor);
cursor.removeSelectedText();
@@ -7123,7 +7123,7 @@ void TextEditorWidget::autoIndent()
void TextEditorWidget::rewrapParagraph()
{
const int paragraphWidth = marginSettings().m_marginColumn;
const QRegExp anyLettersOrNumbers = QRegExp(QLatin1String("\\w"));
const QRegularExpression anyLettersOrNumbers("\\w");
const int tabSize = d->m_document->tabSettings().m_tabSize;
QTextCursor cursor = textCursor();