mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-06 00:07:29 -04:00
Switch QString ref functions to QStringView
This commit is contained in:
parent
08c1275e0e
commit
ce2bce52fd
@ -1434,7 +1434,11 @@ int main( int argc, char *argv[] )
|
||||
break;
|
||||
}
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2)
|
||||
coords[i] = myInitialExtent.midRef( posOld, pos - posOld ).toDouble( &ok );
|
||||
#else
|
||||
coords[i] = QStringView {myInitialExtent}.mid( posOld, pos - posOld ).toDouble( &ok );
|
||||
#endif
|
||||
if ( !ok )
|
||||
break;
|
||||
|
||||
@ -1443,7 +1447,13 @@ int main( int argc, char *argv[] )
|
||||
|
||||
// parse last coordinate
|
||||
if ( ok )
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2)
|
||||
coords[3] = myInitialExtent.midRef( posOld ).toDouble( &ok );
|
||||
#else
|
||||
coords[3] = QStringView {myInitialExtent}.mid( posOld ).toDouble( &ok );
|
||||
#endif
|
||||
}
|
||||
|
||||
if ( !ok )
|
||||
{
|
||||
|
@ -452,7 +452,11 @@ QString QgsExpression::replaceExpressionText( const QString &action, const QgsEx
|
||||
if ( exp.hasParserError() )
|
||||
{
|
||||
QgsDebugMsg( "Expression parser error: " + exp.parserErrorString() );
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2)
|
||||
expr_action += action.midRef( start, index - start );
|
||||
#else
|
||||
expr_action += QStringView {action}.mid( start, index - start );
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -467,7 +471,11 @@ QString QgsExpression::replaceExpressionText( const QString &action, const QgsEx
|
||||
if ( exp.hasEvalError() )
|
||||
{
|
||||
QgsDebugMsg( "Expression parser eval error: " + exp.evalErrorString() );
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2)
|
||||
expr_action += action.midRef( start, index - start );
|
||||
#else
|
||||
expr_action += QStringView {action}.mid( start, index - start );
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -475,7 +483,11 @@ QString QgsExpression::replaceExpressionText( const QString &action, const QgsEx
|
||||
expr_action += action.mid( start, pos - start ) + result.toString();
|
||||
}
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2)
|
||||
expr_action += action.midRef( index );
|
||||
#else
|
||||
expr_action += QStringView {action}.mid( index ).toString();
|
||||
#endif
|
||||
|
||||
return expr_action;
|
||||
}
|
||||
|
@ -75,7 +75,11 @@ QgsColorRamp *QgsGradientColorRamp::create( const QVariantMap &props )
|
||||
continue;
|
||||
|
||||
QColor c = QgsSymbolLayerUtils::decodeColor( stop.mid( i + 1 ) );
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2)
|
||||
stops.append( QgsGradientStop( stop.leftRef( i ).toDouble(), c ) );
|
||||
#else
|
||||
stops.append( QgsGradientStop( QStringView {stop}.left( i ).toDouble(), c ) );
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ QVariantMap QgsHstoreUtils::parse( const QString &string )
|
||||
while ( i < string.length() && string.at( i ).isSpace() )
|
||||
++i;
|
||||
|
||||
if ( string.midRef( i ).startsWith( sep ) )
|
||||
if ( QStringView{string}.mid( i ).startsWith( sep ) )
|
||||
{
|
||||
i += sep.length();
|
||||
}
|
||||
|
@ -2680,8 +2680,13 @@ QDomElement QgsOgcUtilsSQLStatementToFilter::toOgcFilter( const QgsSQLStatement:
|
||||
static QString mapBinarySpatialToOgc( const QString &name )
|
||||
{
|
||||
QString nameCompare( name );
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2)
|
||||
if ( name.size() > 3 && name.midRef( 0, 3 ).compare( QLatin1String( "ST_" ), Qt::CaseInsensitive ) == 0 )
|
||||
nameCompare = name.mid( 3 );
|
||||
#else
|
||||
if ( name.size() > 3 && QStringView {name}.mid( 0, 3 ).toString().compare( QLatin1String( "ST_" ), Qt::CaseInsensitive ) == 0 )
|
||||
nameCompare = name.mid( 3 );
|
||||
#endif
|
||||
QStringList spatialOps;
|
||||
spatialOps << QStringLiteral( "BBOX" ) << QStringLiteral( "Intersects" ) << QStringLiteral( "Contains" ) << QStringLiteral( "Crosses" ) << QStringLiteral( "Equals" )
|
||||
<< QStringLiteral( "Disjoint" ) << QStringLiteral( "Overlaps" ) << QStringLiteral( "Touches" ) << QStringLiteral( "Within" );
|
||||
@ -2697,8 +2702,13 @@ static QString mapBinarySpatialToOgc( const QString &name )
|
||||
static QString mapTernarySpatialToOgc( const QString &name )
|
||||
{
|
||||
QString nameCompare( name );
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2)
|
||||
if ( name.size() > 3 && name.midRef( 0, 3 ).compare( QLatin1String( "ST_" ), Qt::CaseInsensitive ) == 0 )
|
||||
nameCompare = name.mid( 3 );
|
||||
#else
|
||||
if ( name.size() > 3 && QStringView {name}.mid( 0, 3 ).compare( QLatin1String( "ST_" ), Qt::CaseInsensitive ) == 0 )
|
||||
nameCompare = name.mid( 3 );
|
||||
#endif
|
||||
if ( nameCompare.compare( QLatin1String( "DWithin" ), Qt::CaseInsensitive ) == 0 )
|
||||
return QStringLiteral( "DWithin" );
|
||||
if ( nameCompare.compare( QLatin1String( "Beyond" ), Qt::CaseInsensitive ) == 0 )
|
||||
|
@ -40,7 +40,7 @@ QString QgsPostgresStringUtils::getNextString( const QString &txt, int &i, const
|
||||
}
|
||||
i += stringRe.cap( 1 ).length() + 2;
|
||||
jumpSpace( txt, i );
|
||||
if ( !txt.midRef( i ).startsWith( sep ) && i < txt.length() )
|
||||
if ( !QStringView{txt}.mid( i ).startsWith( sep ) && i < txt.length() )
|
||||
{
|
||||
QgsMessageLog::logMessage( QObject::tr( "Cannot find separator: %1" ).arg( txt.mid( i ) ), QObject::tr( "PostgresStringUtils" ) );
|
||||
return QString();
|
||||
|
@ -635,13 +635,21 @@ QString QgsStringUtils::wordWrap( const QString &string, const int length, const
|
||||
}
|
||||
if ( strHit > -1 )
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2)
|
||||
newstr.append( lines.at( i ).midRef( strCurrent, strHit - strCurrent ) );
|
||||
#else
|
||||
newstr.append( QStringView {lines.at( i )}.mid( strCurrent, strHit - strCurrent ) );
|
||||
#endif
|
||||
newstr.append( '\n' );
|
||||
strCurrent = strHit + delimiterLength;
|
||||
}
|
||||
else
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2)
|
||||
newstr.append( lines.at( i ).midRef( strCurrent ) );
|
||||
#else
|
||||
newstr.append( QStringView {lines.at( i )}.mid( strCurrent ) );
|
||||
#endif
|
||||
strCurrent = strLength;
|
||||
}
|
||||
}
|
||||
|
@ -4739,7 +4739,7 @@ QString QgsPostgresProvider::getNextString( const QString &txt, int &i, const QS
|
||||
}
|
||||
i += stringRe.cap( 1 ).length() + 2;
|
||||
jumpSpace( txt, i );
|
||||
if ( !txt.midRef( i ).startsWith( sep ) && i < txt.length() )
|
||||
if ( !QStringView{txt}.mid( i ).startsWith( sep ) && i < txt.length() )
|
||||
{
|
||||
QgsMessageLog::logMessage( tr( "Cannot find separator: %1" ).arg( txt.mid( i ) ), tr( "PostGIS" ) );
|
||||
return QString();
|
||||
@ -4752,14 +4752,14 @@ QString QgsPostgresProvider::getNextString( const QString &txt, int &i, const QS
|
||||
int start = i;
|
||||
for ( ; i < txt.length(); i++ )
|
||||
{
|
||||
if ( txt.midRef( i ).startsWith( sep ) )
|
||||
if ( QStringView{txt}.mid( i ).startsWith( sep ) )
|
||||
{
|
||||
QStringRef r( txt.midRef( start, i - start ) );
|
||||
QStringView v( QStringView{txt}.mid( start, i - start ) );
|
||||
i += sep.length();
|
||||
return r.trimmed().toString();
|
||||
return v.trimmed().toString();
|
||||
}
|
||||
}
|
||||
return txt.midRef( start, i - start ).trimmed().toString();
|
||||
return QStringView{txt}.mid( start, i - start ).trimmed().toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -570,7 +570,11 @@ namespace QgsWms
|
||||
const QRegExp composerParamRegExp( QStringLiteral( "^MAP\\d+:" ), Qt::CaseInsensitive );
|
||||
if ( key.contains( composerParamRegExp ) )
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2)
|
||||
const int mapId = key.midRef( 3, key.indexOf( ':' ) - 3 ).toInt();
|
||||
#else
|
||||
const int mapId = QStringView {key}.mid( 3, key.indexOf( ':' ) - 3 ).toInt();
|
||||
#endif
|
||||
const QString theKey = key.mid( key.indexOf( ':' ) + 1 );
|
||||
const QgsWmsParameter::Name name = QgsWmsParameter::name( theKey );
|
||||
|
||||
|
@ -562,8 +562,11 @@ int main( int argc, char *argv[] )
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2)
|
||||
coords[i] = myInitialExtent.midRef( posOld, pos - posOld ).toDouble( &ok );
|
||||
#else
|
||||
coords[i] = QStringView {myInitialExtent}.mid( posOld, pos - posOld ).toDouble( &ok );
|
||||
#endif
|
||||
if ( !ok )
|
||||
break;
|
||||
|
||||
@ -571,8 +574,13 @@ int main( int argc, char *argv[] )
|
||||
}
|
||||
|
||||
// parse last coordinate
|
||||
#if QT_VERSION < QT_VERSION_CHECK(5, 15, 2)
|
||||
if ( ok )
|
||||
coords[3] = myInitialExtent.midRef( posOld ).toDouble( &ok );
|
||||
#else
|
||||
if ( ok )
|
||||
coords[3] = QStringView {myInitialExtent}.mid( posOld ).toDouble( &ok );
|
||||
#endif
|
||||
|
||||
if ( !ok )
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user