QgsExpressionContext QgsGraduatedSymbolRendererWidget::createExpressionContext() const { QgsExpressionContext expContext; expContext << QgsExpressionContextUtils::globalScope() << QgsExpressionContextUtils::projectScope() << QgsExpressionContextUtils::atlasScope( nullptr ); if ( mapCanvas() ) { expContext << QgsExpressionContextUtils::mapSettingsScope( mapCanvas()->mapSettings() ) << new QgsExpressionContextScope( mapCanvas()->expressionContextScope() ); } else { expContext << QgsExpressionContextUtils::mapSettingsScope( QgsMapSettings() ); } if ( vectorLayer() ) expContext << QgsExpressionContextUtils::layerScope( vectorLayer() ); return expContext; }
void QgsArcGisServiceSourceSelect::addButtonClicked() { if ( treeView->selectionModel()->selectedRows().isEmpty() ) { return; } QgsOwsConnection connection( mServiceName, cmbConnections->currentText() ); QString pCrsString( labelCoordRefSys->text() ); QgsCoordinateReferenceSystem pCrs( pCrsString ); //prepare canvas extent info for layers with "cache features" option not set QgsRectangle extent; QgsCoordinateReferenceSystem canvasCrs; if ( mapCanvas() ) { extent = mapCanvas()->extent(); canvasCrs = mapCanvas()->mapSettings().destinationCrs(); } //does canvas have "on the fly" reprojection set? if ( pCrs.isValid() && canvasCrs.isValid() ) { try { Q_NOWARN_DEPRECATED_PUSH extent = QgsCoordinateTransform( canvasCrs, pCrs ).transform( extent ); Q_NOWARN_DEPRECATED_POP QgsDebugMsg( QStringLiteral( "canvas transform: Canvas CRS=%1, Provider CRS=%2, BBOX=%3" ) .arg( canvasCrs.authid(), pCrs.authid(), extent.asWktCoordinates() ) ); } catch ( const QgsCsException & ) { // Extent is not in range for specified CRS, leave extent empty. } } //create layers that user selected from this feature source QModelIndexList list = treeView->selectionModel()->selectedRows(); for ( int i = 0; i < list.size(); i++ ) { //add a wfs layer to the map QModelIndex idx = mModelProxy->mapToSource( list[i] ); if ( !idx.isValid() ) { continue; } int row = idx.row(); QString layerTitle = mModel->item( row, 0 )->text(); //layer title/id QString layerName = mModel->item( row, 1 )->text(); //layer name bool cacheFeatures = mServiceType == FeatureService ? mModel->item( row, 3 )->checkState() == Qt::Checked : false; QString filter = mServiceType == FeatureService ? mModel->item( row, 4 )->text() : QString(); //optional filter specified by user if ( cbxUseTitleLayerName->isChecked() && !layerTitle.isEmpty() ) { layerName = layerTitle; } QgsRectangle layerExtent; if ( mServiceType == FeatureService && ( cbxFeatureCurrentViewExtent->isChecked() || !cacheFeatures ) ) { layerExtent = extent; } QString uri = getLayerURI( connection, layerTitle, layerName, pCrsString, filter, layerExtent ); QgsDebugMsg( "Layer " + layerName + ", uri: " + uri ); addServiceLayer( uri, layerName ); } accept(); }