Skip to content
Permalink
Browse files

More qt deprecation warning fixes

  • Loading branch information
nyalldawson committed Feb 4, 2020
1 parent a4d8820 commit 00c86182539357a3c4f769a64c0750ed9ba4a4aa
@@ -168,7 +168,7 @@ QVariant QgsVectorLayerAndAttributeModel::data( const QModelIndex &idx, int role
int n;
for ( n = 0; !hasChecked || !hasUnchecked; n++ )
{
QVariant v = data( idx.child( n, 0 ), role );
QVariant v = data( index( n, 0, idx ), role );
if ( !v.isValid() )
break;

@@ -237,7 +237,7 @@ bool QgsVectorLayerAndAttributeModel::setData( const QModelIndex &index, const Q
int i = 0;
for ( i = 0; ; i++ )
{
QModelIndex child = index.child( i, 0 );
QModelIndex child = QgsVectorLayerAndAttributeModel::index( i, 0, index );
if ( !child.isValid() )
break;

@@ -390,7 +390,7 @@ QVariant QgsSnappingLayerTreeModel::data( const QModelIndex &idx, int role ) con
int n;
for ( n = 0; !hasChecked || !hasUnchecked; n++ )
{
QVariant v = data( idx.child( n, LayerColumn ), role );
QVariant v = data( index( n, LayerColumn, idx ), role );
if ( !v.isValid() )
break;

@@ -526,7 +526,7 @@ bool QgsSnappingLayerTreeModel::setData( const QModelIndex &index, const QVarian
int i = 0;
for ( i = 0; ; i++ )
{
QModelIndex child = index.child( i, LayerColumn );
QModelIndex child = QgsSnappingLayerTreeModel::index( i, LayerColumn, index );
if ( !child.isValid() )
break;

@@ -112,10 +112,12 @@ void eVisDatabaseConnectionGui::drawNewVectorLayer( const QString &layerName, co
//the last file in the list is always the newest
mTempOutputFileList->last()->open();
QUrl url = QUrl::fromLocalFile( mTempOutputFileList->last()->fileName() );
url.addQueryItem( QStringLiteral( "delimiter" ), QStringLiteral( "\t" ) );
url.addQueryItem( QStringLiteral( "delimiterType" ), QStringLiteral( "regexp" ) );
url.addQueryItem( QStringLiteral( "xField" ), xCoordinate );
url.addQueryItem( QStringLiteral( "yField" ), yCoordinate );
QUrlQuery query;
query.addQueryItem( QStringLiteral( "delimiter" ), QStringLiteral( "\t" ) );
query.addQueryItem( QStringLiteral( "delimiterType" ), QStringLiteral( "regexp" ) );
query.addQueryItem( QStringLiteral( "xField" ), xCoordinate );
query.addQueryItem( QStringLiteral( "yField" ), yCoordinate );
url.setQuery( query );
emit drawVectorLayer( QString::fromLatin1( url.toEncoded() ), layerName, QStringLiteral( "delimitedtext" ) );
mTempOutputFileList->last()->close();
}
@@ -84,7 +84,9 @@ void QgsAmsLegendFetcher::start()
headers[ QStringLiteral( "Referer" )] = referer;

QUrl queryUrl( dataSource.param( QStringLiteral( "url" ) ) + "/legend" );
queryUrl.addQueryItem( QStringLiteral( "f" ), QStringLiteral( "json" ) );
QUrlQuery query( queryUrl );
query.addQueryItem( QStringLiteral( "f" ), QStringLiteral( "json" ) );
queryUrl.setQuery( query );
mQuery->start( queryUrl, authCfg, &mQueryReply, false, headers );
}
else
@@ -726,12 +728,14 @@ QImage QgsAmsProvider::draw( const QgsRectangle &viewExtent, int pixelWidth, int
extent.setYMaximum( viewExtent.yMinimum() + viewExtent.height() / pixelHeight * ( currentStepHeight * maxHeight + height ) );

QUrl requestUrl( dataSource.param( QStringLiteral( "url" ) ) + ( mImageServer ? "/exportImage" : "/export" ) );
requestUrl.addQueryItem( QStringLiteral( "bbox" ), QStringLiteral( "%1,%2,%3,%4" ).arg( extent.xMinimum(), 0, 'f', -1 ).arg( extent.yMinimum(), 0, 'f', -1 ).arg( extent.xMaximum(), 0, 'f', -1 ).arg( extent.yMaximum(), 0, 'f', -1 ) );
requestUrl.addQueryItem( QStringLiteral( "size" ), QStringLiteral( "%1,%2" ).arg( width ).arg( height ) );
requestUrl.addQueryItem( QStringLiteral( "format" ), dataSource.param( QStringLiteral( "format" ) ) );
requestUrl.addQueryItem( QStringLiteral( "layers" ), QStringLiteral( "show:%1" ).arg( dataSource.param( QStringLiteral( "layer" ) ) ) );
requestUrl.addQueryItem( QStringLiteral( "transparent" ), QStringLiteral( "true" ) );
requestUrl.addQueryItem( QStringLiteral( "f" ), QStringLiteral( "image" ) );
QUrlQuery query( requestUrl );
query.addQueryItem( QStringLiteral( "bbox" ), QStringLiteral( "%1,%2,%3,%4" ).arg( extent.xMinimum(), 0, 'f', -1 ).arg( extent.yMinimum(), 0, 'f', -1 ).arg( extent.xMaximum(), 0, 'f', -1 ).arg( extent.yMaximum(), 0, 'f', -1 ) );
query.addQueryItem( QStringLiteral( "size" ), QStringLiteral( "%1,%2" ).arg( width ).arg( height ) );
query.addQueryItem( QStringLiteral( "format" ), dataSource.param( QStringLiteral( "format" ) ) );
query.addQueryItem( QStringLiteral( "layers" ), QStringLiteral( "show:%1" ).arg( dataSource.param( QStringLiteral( "layer" ) ) ) );
query.addQueryItem( QStringLiteral( "transparent" ), QStringLiteral( "true" ) );
query.addQueryItem( QStringLiteral( "f" ), QStringLiteral( "image" ) );
requestUrl.setQuery( query );
mError.clear();
mErrorTitle.clear();
QString contentType;
@@ -823,14 +827,16 @@ QgsRasterIdentifyResult QgsAmsProvider::identify( const QgsPointXY &point, QgsRa
// http://resources.arcgis.com/en/help/rest/apiref/identify.html
QgsDataSourceUri dataSource( dataSourceUri() );
QUrl queryUrl( dataSource.param( QStringLiteral( "url" ) ) + "/identify" );
queryUrl.addQueryItem( QStringLiteral( "f" ), QStringLiteral( "json" ) );
queryUrl.addQueryItem( QStringLiteral( "geometryType" ), QStringLiteral( "esriGeometryPoint" ) );
queryUrl.addQueryItem( QStringLiteral( "geometry" ), QStringLiteral( "{x: %1, y: %2}" ).arg( point.x(), 0, 'f' ).arg( point.y(), 0, 'f' ) );
// queryUrl.addQueryItem( "sr", mCrs.postgisSrid() );
queryUrl.addQueryItem( QStringLiteral( "layers" ), QStringLiteral( "all:%1" ).arg( dataSource.param( QStringLiteral( "layer" ) ) ) );
queryUrl.addQueryItem( QStringLiteral( "imageDisplay" ), QStringLiteral( "%1,%2,%3" ).arg( width ).arg( height ).arg( dpi ) );
queryUrl.addQueryItem( QStringLiteral( "mapExtent" ), QStringLiteral( "%1,%2,%3,%4" ).arg( extent.xMinimum(), 0, 'f' ).arg( extent.yMinimum(), 0, 'f' ).arg( extent.xMaximum(), 0, 'f' ).arg( extent.yMaximum(), 0, 'f' ) );
queryUrl.addQueryItem( QStringLiteral( "tolerance" ), QStringLiteral( "10" ) );
QUrlQuery query( queryUrl );
query.addQueryItem( QStringLiteral( "f" ), QStringLiteral( "json" ) );
query.addQueryItem( QStringLiteral( "geometryType" ), QStringLiteral( "esriGeometryPoint" ) );
query.addQueryItem( QStringLiteral( "geometry" ), QStringLiteral( "{x: %1, y: %2}" ).arg( point.x(), 0, 'f' ).arg( point.y(), 0, 'f' ) );
// query.addQueryItem( "sr", mCrs.postgisSrid() );
query.addQueryItem( QStringLiteral( "layers" ), QStringLiteral( "all:%1" ).arg( dataSource.param( QStringLiteral( "layer" ) ) ) );
query.addQueryItem( QStringLiteral( "imageDisplay" ), QStringLiteral( "%1,%2,%3" ).arg( width ).arg( height ).arg( dpi ) );
query.addQueryItem( QStringLiteral( "mapExtent" ), QStringLiteral( "%1,%2,%3,%4" ).arg( extent.xMinimum(), 0, 'f' ).arg( extent.yMinimum(), 0, 'f' ).arg( extent.xMaximum(), 0, 'f' ).arg( extent.yMaximum(), 0, 'f' ) );
query.addQueryItem( QStringLiteral( "tolerance" ), QStringLiteral( "10" ) );
queryUrl.setQuery( query );

const QString authcfg = dataSource.authConfigId();
const QVariantList queryResults = QgsArcGisRestUtils::queryServiceJSON( queryUrl, authcfg, mErrorTitle, mError ).value( QStringLiteral( "results" ) ).toList();
@@ -395,33 +395,39 @@ QVariantMap QgsArcGisRestUtils::getServiceInfo( const QString &baseurl, const QS
{
// http://sampleserver5.arcgisonline.com/arcgis/rest/services/Energy/Geology/FeatureServer?f=json
QUrl queryUrl( baseurl );
queryUrl.addQueryItem( QStringLiteral( "f" ), QStringLiteral( "json" ) );
QUrlQuery query( queryUrl );
query.addQueryItem( QStringLiteral( "f" ), QStringLiteral( "json" ) );
queryUrl.setQuery( query );
return queryServiceJSON( queryUrl, authcfg, errorTitle, errorText, requestHeaders );
}

QVariantMap QgsArcGisRestUtils::getLayerInfo( const QString &layerurl, const QString &authcfg, QString &errorTitle, QString &errorText, const QgsStringMap &requestHeaders )
{
// http://sampleserver5.arcgisonline.com/arcgis/rest/services/Energy/Geology/FeatureServer/1?f=json
QUrl queryUrl( layerurl );
queryUrl.addQueryItem( QStringLiteral( "f" ), QStringLiteral( "json" ) );
QUrlQuery query( queryUrl );
query.addQueryItem( QStringLiteral( "f" ), QStringLiteral( "json" ) );
queryUrl.setQuery( query );
return queryServiceJSON( queryUrl, authcfg, errorTitle, errorText, requestHeaders );
}

QVariantMap QgsArcGisRestUtils::getObjectIds( const QString &layerurl, const QString &authcfg, QString &errorTitle, QString &errorText, const QgsStringMap &requestHeaders, const QgsRectangle &bbox )
{
// http://sampleserver5.arcgisonline.com/arcgis/rest/services/Energy/Geology/FeatureServer/1/query?where=1%3D1&returnIdsOnly=true&f=json
QUrl queryUrl( layerurl + "/query" );
queryUrl.addQueryItem( QStringLiteral( "f" ), QStringLiteral( "json" ) );
queryUrl.addQueryItem( QStringLiteral( "where" ), QStringLiteral( "1=1" ) );
queryUrl.addQueryItem( QStringLiteral( "returnIdsOnly" ), QStringLiteral( "true" ) );
QUrlQuery query( queryUrl );
query.addQueryItem( QStringLiteral( "f" ), QStringLiteral( "json" ) );
query.addQueryItem( QStringLiteral( "where" ), QStringLiteral( "1=1" ) );
query.addQueryItem( QStringLiteral( "returnIdsOnly" ), QStringLiteral( "true" ) );
if ( !bbox.isNull() )
{
queryUrl.addQueryItem( QStringLiteral( "geometry" ), QStringLiteral( "%1,%2,%3,%4" )
.arg( bbox.xMinimum(), 0, 'f', -1 ).arg( bbox.yMinimum(), 0, 'f', -1 )
.arg( bbox.xMaximum(), 0, 'f', -1 ).arg( bbox.yMaximum(), 0, 'f', -1 ) );
queryUrl.addQueryItem( QStringLiteral( "geometryType" ), QStringLiteral( "esriGeometryEnvelope" ) );
queryUrl.addQueryItem( QStringLiteral( "spatialRel" ), QStringLiteral( "esriSpatialRelEnvelopeIntersects" ) );
query.addQueryItem( QStringLiteral( "geometry" ), QStringLiteral( "%1,%2,%3,%4" )
.arg( bbox.xMinimum(), 0, 'f', -1 ).arg( bbox.yMinimum(), 0, 'f', -1 )
.arg( bbox.xMaximum(), 0, 'f', -1 ).arg( bbox.yMaximum(), 0, 'f', -1 ) );
query.addQueryItem( QStringLiteral( "geometryType" ), QStringLiteral( "esriGeometryEnvelope" ) );
query.addQueryItem( QStringLiteral( "spatialRel" ), QStringLiteral( "esriSpatialRelEnvelopeIntersects" ) );
}
queryUrl.setQuery( query );
return queryServiceJSON( queryUrl, authcfg, errorTitle, errorText, requestHeaders );
}

@@ -437,45 +443,49 @@ QVariantMap QgsArcGisRestUtils::getObjects( const QString &layerurl, const QStri
ids.append( QString::number( id ) );
}
QUrl queryUrl( layerurl + "/query" );
queryUrl.addQueryItem( QStringLiteral( "f" ), QStringLiteral( "json" ) );
queryUrl.addQueryItem( QStringLiteral( "objectIds" ), ids.join( QStringLiteral( "," ) ) );
QUrlQuery query( queryUrl );
query.addQueryItem( QStringLiteral( "f" ), QStringLiteral( "json" ) );
query.addQueryItem( QStringLiteral( "objectIds" ), ids.join( QStringLiteral( "," ) ) );
QString wkid = crs.indexOf( QLatin1String( ":" ) ) >= 0 ? crs.split( ':' )[1] : QString();
queryUrl.addQueryItem( QStringLiteral( "inSR" ), wkid );
queryUrl.addQueryItem( QStringLiteral( "outSR" ), wkid );
query.addQueryItem( QStringLiteral( "inSR" ), wkid );
query.addQueryItem( QStringLiteral( "outSR" ), wkid );

queryUrl.addQueryItem( QStringLiteral( "returnGeometry" ), fetchGeometry ? QStringLiteral( "true" ) : QStringLiteral( "false" ) );
query.addQueryItem( QStringLiteral( "returnGeometry" ), fetchGeometry ? QStringLiteral( "true" ) : QStringLiteral( "false" ) );

QString outFields;
if ( fetchAttributes.isEmpty() )
outFields = QStringLiteral( "*" );
else
outFields = fetchAttributes.join( ',' );
queryUrl.addQueryItem( QStringLiteral( "outFields" ), outFields );
query.addQueryItem( QStringLiteral( "outFields" ), outFields );

queryUrl.addQueryItem( QStringLiteral( "returnM" ), fetchM ? QStringLiteral( "true" ) : QStringLiteral( "false" ) );
queryUrl.addQueryItem( QStringLiteral( "returnZ" ), fetchZ ? QStringLiteral( "true" ) : QStringLiteral( "false" ) );
query.addQueryItem( QStringLiteral( "returnM" ), fetchM ? QStringLiteral( "true" ) : QStringLiteral( "false" ) );
query.addQueryItem( QStringLiteral( "returnZ" ), fetchZ ? QStringLiteral( "true" ) : QStringLiteral( "false" ) );
if ( !filterRect.isNull() )
{
queryUrl.addQueryItem( QStringLiteral( "geometry" ), QStringLiteral( "%1,%2,%3,%4" )
.arg( filterRect.xMinimum(), 0, 'f', -1 ).arg( filterRect.yMinimum(), 0, 'f', -1 )
.arg( filterRect.xMaximum(), 0, 'f', -1 ).arg( filterRect.yMaximum(), 0, 'f', -1 ) );
queryUrl.addQueryItem( QStringLiteral( "geometryType" ), QStringLiteral( "esriGeometryEnvelope" ) );
queryUrl.addQueryItem( QStringLiteral( "spatialRel" ), QStringLiteral( "esriSpatialRelEnvelopeIntersects" ) );
query.addQueryItem( QStringLiteral( "geometry" ), QStringLiteral( "%1,%2,%3,%4" )
.arg( filterRect.xMinimum(), 0, 'f', -1 ).arg( filterRect.yMinimum(), 0, 'f', -1 )
.arg( filterRect.xMaximum(), 0, 'f', -1 ).arg( filterRect.yMaximum(), 0, 'f', -1 ) );
query.addQueryItem( QStringLiteral( "geometryType" ), QStringLiteral( "esriGeometryEnvelope" ) );
query.addQueryItem( QStringLiteral( "spatialRel" ), QStringLiteral( "esriSpatialRelEnvelopeIntersects" ) );
}
queryUrl.setQuery( query );
return queryServiceJSON( queryUrl, authcfg, errorTitle, errorText, requestHeaders, feedback );
}

QList<quint32> QgsArcGisRestUtils::getObjectIdsByExtent( const QString &layerurl, const QgsRectangle &filterRect, QString &errorTitle, QString &errorText, const QString &authcfg, const QgsStringMap &requestHeaders, QgsFeedback *feedback )
{
QUrl queryUrl( layerurl + "/query" );
queryUrl.addQueryItem( QStringLiteral( "f" ), QStringLiteral( "json" ) );
queryUrl.addQueryItem( QStringLiteral( "where" ), QStringLiteral( "1=1" ) );
queryUrl.addQueryItem( QStringLiteral( "returnIdsOnly" ), QStringLiteral( "true" ) );
queryUrl.addQueryItem( QStringLiteral( "geometry" ), QStringLiteral( "%1,%2,%3,%4" )
.arg( filterRect.xMinimum(), 0, 'f', -1 ).arg( filterRect.yMinimum(), 0, 'f', -1 )
.arg( filterRect.xMaximum(), 0, 'f', -1 ).arg( filterRect.yMaximum(), 0, 'f', -1 ) );
queryUrl.addQueryItem( QStringLiteral( "geometryType" ), QStringLiteral( "esriGeometryEnvelope" ) );
queryUrl.addQueryItem( QStringLiteral( "spatialRel" ), QStringLiteral( "esriSpatialRelEnvelopeIntersects" ) );
QUrlQuery query( queryUrl );
query.addQueryItem( QStringLiteral( "f" ), QStringLiteral( "json" ) );
query.addQueryItem( QStringLiteral( "where" ), QStringLiteral( "1=1" ) );
query.addQueryItem( QStringLiteral( "returnIdsOnly" ), QStringLiteral( "true" ) );
query.addQueryItem( QStringLiteral( "geometry" ), QStringLiteral( "%1,%2,%3,%4" )
.arg( filterRect.xMinimum(), 0, 'f', -1 ).arg( filterRect.yMinimum(), 0, 'f', -1 )
.arg( filterRect.xMaximum(), 0, 'f', -1 ).arg( filterRect.yMaximum(), 0, 'f', -1 ) );
query.addQueryItem( QStringLiteral( "geometryType" ), QStringLiteral( "esriGeometryEnvelope" ) );
query.addQueryItem( QStringLiteral( "spatialRel" ), QStringLiteral( "esriSpatialRelEnvelopeIntersects" ) );
queryUrl.setQuery( query );
const QVariantMap objectIdData = queryServiceJSON( queryUrl, authcfg, errorTitle, errorText, requestHeaders, feedback );

if ( objectIdData.isEmpty() )
@@ -25,25 +25,27 @@ bool QgsWFSDescribeFeatureType::requestFeatureType( const QString &WFSVersion,
const QString &typeName, const QgsWfsCapabilities::Capabilities &caps )
{
QUrl url( mUri.requestUrl( QStringLiteral( "DescribeFeatureType" ) ) );
url.addQueryItem( QStringLiteral( "VERSION" ), WFSVersion );
QUrlQuery query( url );
query.addQueryItem( QStringLiteral( "VERSION" ), WFSVersion );

QString namespaceValue( caps.getNamespaceParameterValue( WFSVersion, typeName ) );

if ( WFSVersion.startsWith( QLatin1String( "2.0" ) ) )
{
url.addQueryItem( QStringLiteral( "TYPENAMES" ), typeName );
query.addQueryItem( QStringLiteral( "TYPENAMES" ), typeName );
if ( !namespaceValue.isEmpty() )
{
url.addQueryItem( QStringLiteral( "NAMESPACES" ), namespaceValue );
query.addQueryItem( QStringLiteral( "NAMESPACES" ), namespaceValue );
}
}

url.addQueryItem( QStringLiteral( "TYPENAME" ), typeName );
query.addQueryItem( QStringLiteral( "TYPENAME" ), typeName );
if ( !namespaceValue.isEmpty() )
{
url.addQueryItem( QStringLiteral( "NAMESPACE" ), namespaceValue );
query.addQueryItem( QStringLiteral( "NAMESPACE" ), namespaceValue );
}

url.setQuery( query );
return sendGET( url, QString(), true, false );
}

0 comments on commit 00c8618

Please sign in to comment.
You can’t perform that action at this time.