mirror of
				https://github.com/qgis/QGIS.git
				synced 2025-11-04 00:04:25 -05:00 
			
		
		
		
	Migrate remaining(*) uses of QRegExp in src/providers
(*) the stagnant GRASS provider hasn't been ported, no interest on my side
This commit is contained in:
		
							parent
							
								
									3a07af0ef1
								
							
						
					
					
						commit
						adb5362463
					
				@ -30,6 +30,7 @@
 | 
				
			|||||||
#include <QListWidgetItem>
 | 
					#include <QListWidgetItem>
 | 
				
			||||||
#include <QMessageBox>
 | 
					#include <QMessageBox>
 | 
				
			||||||
#include <QFileDialog>
 | 
					#include <QFileDialog>
 | 
				
			||||||
 | 
					#include <QRegularExpression>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
enum
 | 
					enum
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -351,10 +352,8 @@ void QgsGeoNodeSourceSelect::loadGeonodeConnection()
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
void QgsGeoNodeSourceSelect::filterChanged( const QString &text )
 | 
					void QgsGeoNodeSourceSelect::filterChanged( const QString &text )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  QRegExp::PatternSyntax mySyntax = QRegExp::PatternSyntax( QRegExp::RegExp );
 | 
					  QRegularExpression regExp( text, QRegularExpression::CaseInsensitiveOption );
 | 
				
			||||||
  Qt::CaseSensitivity myCaseSensitivity = Qt::CaseInsensitive;
 | 
					  mModelProxy->setFilterRegularExpression( regExp );
 | 
				
			||||||
  QRegExp myRegExp( text, myCaseSensitivity, mySyntax );
 | 
					 | 
				
			||||||
  mModelProxy->setFilterRegExp( myRegExp );
 | 
					 | 
				
			||||||
  mModelProxy->sort( mModelProxy->sortColumn(), mModelProxy->sortOrder() );
 | 
					  mModelProxy->sort( mModelProxy->sortColumn(), mModelProxy->sortOrder() );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -62,7 +62,7 @@
 | 
				
			|||||||
#include <qvariant.h>
 | 
					#include <qvariant.h>
 | 
				
			||||||
#include <qdatetime.h>
 | 
					#include <qdatetime.h>
 | 
				
			||||||
#include <qmetatype.h>
 | 
					#include <qmetatype.h>
 | 
				
			||||||
#include <qregexp.h>
 | 
					#include <qregularexpression.h>
 | 
				
			||||||
#include <qshareddata.h>
 | 
					#include <qshareddata.h>
 | 
				
			||||||
#include <qsqlerror.h>
 | 
					#include <qsqlerror.h>
 | 
				
			||||||
#include <qsqlfield.h>
 | 
					#include <qsqlfield.h>
 | 
				
			||||||
@ -3903,9 +3903,10 @@ bool QOCISpatialDriver::open( const QString &db,
 | 
				
			|||||||
  {
 | 
					  {
 | 
				
			||||||
    QString versionStr;
 | 
					    QString versionStr;
 | 
				
			||||||
    versionStr = QString( reinterpret_cast<const QChar *>( vertxt ) );
 | 
					    versionStr = QString( reinterpret_cast<const QChar *>( vertxt ) );
 | 
				
			||||||
    QRegExp vers( QLatin1String( "([0-9]+)\\.[0-9\\.]+[0-9]" ) );
 | 
					    QRegularExpression vers( QLatin1String( "([0-9]+)\\.[0-9\\.]+[0-9]" ) );
 | 
				
			||||||
    if ( vers.indexIn( versionStr ) >= 0 )
 | 
					    QRegularExpressionMatch match = vers.match( versionStr );
 | 
				
			||||||
      d->serverVersion = vers.cap( 1 ).toInt();
 | 
					    if ( match.hasMatch() )
 | 
				
			||||||
 | 
					      d->serverVersion = match.captured( 1 ).toInt();
 | 
				
			||||||
    if ( d->serverVersion == 0 )
 | 
					    if ( d->serverVersion == 0 )
 | 
				
			||||||
      d->serverVersion = -1;
 | 
					      d->serverVersion = -1;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
				
			|||||||
@ -26,10 +26,6 @@
 | 
				
			|||||||
#include "qgscoordinatereferencesystem.h"
 | 
					#include "qgscoordinatereferencesystem.h"
 | 
				
			||||||
#include "qgsxmlutils.h"
 | 
					#include "qgsxmlutils.h"
 | 
				
			||||||
#include "qgsvectorlayer.h"
 | 
					#include "qgsvectorlayer.h"
 | 
				
			||||||
 | 
					 | 
				
			||||||
#include <QMessageBox>
 | 
					 | 
				
			||||||
#include <QRegularExpression>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
#include "qgsvectorlayerexporter.h"
 | 
					#include "qgsvectorlayerexporter.h"
 | 
				
			||||||
#include "qgspostgresprovider.h"
 | 
					#include "qgspostgresprovider.h"
 | 
				
			||||||
#include "qgspostgresconn.h"
 | 
					#include "qgspostgresconn.h"
 | 
				
			||||||
@ -43,12 +39,15 @@
 | 
				
			|||||||
#include "qgslogger.h"
 | 
					#include "qgslogger.h"
 | 
				
			||||||
#include "qgsfeedback.h"
 | 
					#include "qgsfeedback.h"
 | 
				
			||||||
#include "qgssettings.h"
 | 
					#include "qgssettings.h"
 | 
				
			||||||
 | 
					#include "qgsstringutils.h"
 | 
				
			||||||
#include "qgsjsonutils.h"
 | 
					#include "qgsjsonutils.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "qgspostgresprovider.h"
 | 
					#include "qgspostgresprovider.h"
 | 
				
			||||||
#include "qgsprovidermetadata.h"
 | 
					#include "qgsprovidermetadata.h"
 | 
				
			||||||
#include "qgspostgresproviderconnection.h"
 | 
					#include "qgspostgresproviderconnection.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#include <QMessageBox>
 | 
				
			||||||
 | 
					#include <QRegularExpression>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const QString QgsPostgresProvider::POSTGRES_KEY = QStringLiteral( "postgres" );
 | 
					const QString QgsPostgresProvider::POSTGRES_KEY = QStringLiteral( "postgres" );
 | 
				
			||||||
const QString QgsPostgresProvider::POSTGRES_DESCRIPTION = QStringLiteral( "PostgreSQL/PostGIS data provider" );
 | 
					const QString QgsPostgresProvider::POSTGRES_DESCRIPTION = QStringLiteral( "PostgreSQL/PostGIS data provider" );
 | 
				
			||||||
@ -1463,13 +1462,13 @@ bool QgsPostgresProvider::hasSufficientPermsAndCapabilities()
 | 
				
			|||||||
    // get a new alias for the subquery
 | 
					    // get a new alias for the subquery
 | 
				
			||||||
    int index = 0;
 | 
					    int index = 0;
 | 
				
			||||||
    QString alias;
 | 
					    QString alias;
 | 
				
			||||||
    QRegExp regex;
 | 
					    QRegularExpression regex;
 | 
				
			||||||
    do
 | 
					    do
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      alias = QStringLiteral( "subQuery_%1" ).arg( QString::number( index++ ) );
 | 
					      alias = QStringLiteral( "subQuery_%1" ).arg( QString::number( index++ ) );
 | 
				
			||||||
      QString pattern = QStringLiteral( "(\\\"?)%1\\1" ).arg( QRegExp::escape( alias ) );
 | 
					      QString pattern = QStringLiteral( "(\\\"?)%1\\1" ).arg( QgsStringUtils::qRegExpEscape( alias ) );
 | 
				
			||||||
      regex.setPattern( pattern );
 | 
					      regex.setPattern( pattern );
 | 
				
			||||||
      regex.setCaseSensitivity( Qt::CaseInsensitive );
 | 
					      regex.setPatternOptions( QRegularExpression::CaseInsensitiveOption );
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    while ( mQuery.contains( regex ) );
 | 
					    while ( mQuery.contains( regex ) );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -2057,8 +2056,8 @@ bool QgsPostgresProvider::parseDomainCheckConstraint( QStringList &enumValues, c
 | 
				
			|||||||
      //we assume that the constraint is of the following form:
 | 
					      //we assume that the constraint is of the following form:
 | 
				
			||||||
      //(VALUE = ANY (ARRAY['a'::text, 'b'::text, 'c'::text, 'd'::text]))
 | 
					      //(VALUE = ANY (ARRAY['a'::text, 'b'::text, 'c'::text, 'd'::text]))
 | 
				
			||||||
      //normally, PostgreSQL creates that if the constraint has been specified as 'VALUE in ('a', 'b', 'c', 'd')
 | 
					      //normally, PostgreSQL creates that if the constraint has been specified as 'VALUE in ('a', 'b', 'c', 'd')
 | 
				
			||||||
 | 
					      const thread_local QRegularExpression definitionRegExp( "VALUE\\s*=\\s*ANY\\s*\\(\\s*ARRAY\\s*\\[" );
 | 
				
			||||||
      int anyPos = checkDefinition.indexOf( QRegExp( "VALUE\\s*=\\s*ANY\\s*\\(\\s*ARRAY\\s*\\[" ) );
 | 
					      int anyPos = checkDefinition.indexOf( definitionRegExp );
 | 
				
			||||||
      int arrayPosition = checkDefinition.lastIndexOf( QLatin1String( "ARRAY[" ) );
 | 
					      int arrayPosition = checkDefinition.lastIndexOf( QLatin1String( "ARRAY[" ) );
 | 
				
			||||||
      int closingBracketPos = checkDefinition.indexOf( ']', arrayPosition + 6 );
 | 
					      int closingBracketPos = checkDefinition.indexOf( ']', arrayPosition + 6 );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -4758,13 +4757,14 @@ QString QgsPostgresProvider::getNextString( const QString &txt, int &i, const QS
 | 
				
			|||||||
  jumpSpace( txt, i );
 | 
					  jumpSpace( txt, i );
 | 
				
			||||||
  if ( i < txt.length() && txt.at( i ) == '"' )
 | 
					  if ( i < txt.length() && txt.at( i ) == '"' )
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
    QRegExp stringRe( "^\"((?:\\\\.|[^\"\\\\])*)\".*" );
 | 
					    const thread_local QRegularExpression stringRe( QRegularExpression::anchoredPattern( "^\"((?:\\\\.|[^\"\\\\])*)\".*" ) );
 | 
				
			||||||
    if ( !stringRe.exactMatch( txt.mid( i ) ) )
 | 
					    const QRegularExpressionMatch match = stringRe.match( txt.mid( i ) );
 | 
				
			||||||
 | 
					    if ( !match.hasMatch() )
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
      QgsMessageLog::logMessage( tr( "Cannot find end of double quoted string: %1" ).arg( txt ), tr( "PostGIS" ) );
 | 
					      QgsMessageLog::logMessage( tr( "Cannot find end of double quoted string: %1" ).arg( txt ), tr( "PostGIS" ) );
 | 
				
			||||||
      return QString();
 | 
					      return QString();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    i += stringRe.cap( 1 ).length() + 2;
 | 
					    i += match.captured( 1 ).length() + 2;
 | 
				
			||||||
    jumpSpace( txt, i );
 | 
					    jumpSpace( txt, i );
 | 
				
			||||||
    if ( !QStringView{txt}.mid( i ).startsWith( sep ) && i < txt.length() )
 | 
					    if ( !QStringView{txt}.mid( i ).startsWith( sep ) && i < txt.length() )
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
@ -4772,7 +4772,7 @@ QString QgsPostgresProvider::getNextString( const QString &txt, int &i, const QS
 | 
				
			|||||||
      return QString();
 | 
					      return QString();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
    i += sep.length();
 | 
					    i += sep.length();
 | 
				
			||||||
    return stringRe.cap( 1 ).replace( QLatin1String( "\\\"" ), QLatin1String( "\"" ) ).replace( QLatin1String( "\\\\" ), QLatin1String( "\\" ) );
 | 
					    return match.captured( 1 ).replace( QLatin1String( "\\\"" ), QLatin1String( "\"" ) ).replace( QLatin1String( "\\\\" ), QLatin1String( "\\" ) );
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
  {
 | 
					  {
 | 
				
			||||||
 | 
				
			|||||||
@ -42,6 +42,7 @@
 | 
				
			|||||||
#include <QMessageBox>
 | 
					#include <QMessageBox>
 | 
				
			||||||
#include <QFileDialog>
 | 
					#include <QFileDialog>
 | 
				
			||||||
#include <QPainter>
 | 
					#include <QPainter>
 | 
				
			||||||
 | 
					#include <QRegularExpression>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
enum
 | 
					enum
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@ -751,10 +752,8 @@ void QgsWFSSourceSelect::buildQueryButtonClicked()
 | 
				
			|||||||
void QgsWFSSourceSelect::filterChanged( const QString &text )
 | 
					void QgsWFSSourceSelect::filterChanged( const QString &text )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  QgsDebugMsgLevel( "WFS FeatureType filter changed to :" + text, 2 );
 | 
					  QgsDebugMsgLevel( "WFS FeatureType filter changed to :" + text, 2 );
 | 
				
			||||||
  QRegExp::PatternSyntax mySyntax = QRegExp::PatternSyntax( QRegExp::RegExp );
 | 
					  QRegularExpression regExp( text, QRegularExpression::CaseInsensitiveOption );
 | 
				
			||||||
  Qt::CaseSensitivity myCaseSensitivity = Qt::CaseInsensitive;
 | 
					  mModelProxy->setFilterRegularExpression( regExp );
 | 
				
			||||||
  QRegExp myRegExp( text, myCaseSensitivity, mySyntax );
 | 
					 | 
				
			||||||
  mModelProxy->setFilterRegExp( myRegExp );
 | 
					 | 
				
			||||||
  mModelProxy->sort( mModelProxy->sortColumn(), mModelProxy->sortOrder() );
 | 
					  mModelProxy->sort( mModelProxy->sortColumn(), mModelProxy->sortOrder() );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user