Skip to content
Permalink
Browse files
QRegExp -> QRegularExpression
  • Loading branch information
nyalldawson committed Jul 20, 2021
1 parent 965bc1f commit ae6f4ade1c8d5e5cbe25a37ad4ad571217079478
@@ -21,7 +21,7 @@
#define QGSDOUBLEVALIDATOR_H

#include <limits>
#include <QRegExpValidator>
#include <QRegularExpressionValidator>
#include <QLocale>
#include "qgis_gui.h"
#include "qgis_sip.h"
@@ -29,18 +29,18 @@ QgsExpressionHighlighter::QgsExpressionHighlighter( QTextDocument *parent )
const auto constKeywordPatterns = keywordPatterns;
for ( const QString &pattern : constKeywordPatterns )
{
rule.pattern = QRegExp( pattern, Qt::CaseInsensitive );
rule.pattern = QRegularExpression( pattern, QRegularExpression::CaseInsensitiveOption );
rule.format = keywordFormat;
highlightingRules.append( rule );
}

quotationFormat.setForeground( Qt::darkGreen );
rule.pattern = QRegExp( "\'[^\'\r\n]*\'" );
rule.pattern = QRegularExpression( "\'[^\'\r\n]*\'" );
rule.format = quotationFormat;
highlightingRules.append( rule );

columnNameFormat.setForeground( Qt::darkRed );
rule.pattern = QRegExp( "\"[^\"\r\n]*\"" );
rule.pattern = QRegularExpression( "\"[^\"\r\n]*\"" );
rule.format = columnNameFormat;
highlightingRules.append( rule );
}
@@ -54,7 +54,7 @@ void QgsExpressionHighlighter::addFields( const QStringList &fieldList )
{
if ( field.isEmpty() ) // this really happened :)
continue;
rule.pattern = QRegExp( "\\b" + field + "\\b" );
rule.pattern = QRegularExpression( "\\b" + field + "\\b" );
rule.format = columnNameFormat;
highlightingRules.append( rule );
}
@@ -65,15 +65,16 @@ void QgsExpressionHighlighter::highlightBlock( const QString &text )
const auto constHighlightingRules = highlightingRules;
for ( const HighlightingRule &rule : constHighlightingRules )
{
QRegExp expression( rule.pattern );
int index = expression.indexIn( text );
while ( index >= 0 )
QRegularExpression expression( rule.pattern );
QRegularExpressionMatch match = expression.match( text );
while ( match.hasMatch() )
{
int length = expression.matchedLength();
int index = match.capturedStart();
int length = match.capturedLength();
if ( length == 0 )
break; // avoid infinite loops
setFormat( index, length, rule.format );
index = expression.indexIn( text, index + length );
match = expression.match( text, index + length );
}
}
}
@@ -21,6 +21,7 @@
#include <QHash>
#include <QTextCharFormat>
#include <QStringList>
#include <QRegularExpression>
#include "qgis_gui.h"

class QTextDocument;
@@ -43,7 +44,7 @@ class GUI_EXPORT QgsExpressionHighlighter : public QSyntaxHighlighter
private:
struct HighlightingRule
{
QRegExp pattern;
QRegularExpression pattern;
QTextCharFormat format;
};
QVector<HighlightingRule> highlightingRules;
@@ -88,6 +88,7 @@
#include <QMenu>
#include <QScreen>
#include <QRegularExpressionValidator>
#include <QRegularExpression>

QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanvas *canvas, QWidget *parent, Qt::WindowFlags fl )
: QgsOptionsDialogBase( QStringLiteral( "RasterLayerProperties" ), parent, fl )
@@ -1674,7 +1675,7 @@ void QgsRasterLayerProperties::pbnImportTransparentPixelValues_clicked()
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
QStringList myTokens = myInputLine.split( QRegExp( "\\s+" ), QString::SkipEmptyParts );
#else
QStringList myTokens = myInputLine.split( QRegExp( "\\s+" ), Qt::SkipEmptyParts );
QStringList myTokens = myInputLine.split( QRegularExpression( "\\s+" ), Qt::SkipEmptyParts );
#endif
if ( myTokens.count() != 4 )
{
@@ -1711,7 +1712,7 @@ void QgsRasterLayerProperties::pbnImportTransparentPixelValues_clicked()
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
QStringList myTokens = myInputLine.split( QRegExp( "\\s+" ), QString::SkipEmptyParts );
#else
QStringList myTokens = myInputLine.split( QRegExp( "\\s+" ), Qt::SkipEmptyParts );
QStringList myTokens = myInputLine.split( QRegularExpression( "\\s+" ), Qt::SkipEmptyParts );
#endif
if ( myTokens.count() != 3 && myTokens.count() != 2 ) // 2 for QGIS < 1.9 compatibility
{
@@ -18,6 +18,7 @@
#include <QTextStream>
#include <QMessageBox>
#include <QFileDialog>
#include <QRegularExpression>

#include "qgssettings.h"
#include "qgsrastertransparencywidget.h"
@@ -353,7 +354,7 @@ void QgsRasterTransparencyWidget::pbnImportTransparentPixelValues_clicked()
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
QStringList myTokens = myInputLine.split( QRegExp( "\\s+" ), QString::SkipEmptyParts );
#else
QStringList myTokens = myInputLine.split( QRegExp( "\\s+" ), Qt::SkipEmptyParts );
QStringList myTokens = myInputLine.split( QRegularExpression( "\\s+" ), Qt::SkipEmptyParts );
#endif
if ( myTokens.count() != 4 )
{
@@ -390,7 +391,7 @@ void QgsRasterTransparencyWidget::pbnImportTransparentPixelValues_clicked()
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 0)
QStringList myTokens = myInputLine.split( QRegExp( "\\s+" ), QString::SkipEmptyParts );
#else
QStringList myTokens = myInputLine.split( QRegExp( "\\s+" ), Qt::SkipEmptyParts );
QStringList myTokens = myInputLine.split( QRegularExpression( "\\s+" ), Qt::SkipEmptyParts );
#endif
if ( myTokens.count() != 3 && myTokens.count() != 2 ) // 2 for QGIS < 1.9 compatibility
{

0 comments on commit ae6f4ad

Please sign in to comment.