30 #include <QPainterPath>    32 #include <QProgressDialog>    36 #include <QStringBuilder>    38 #include <QUndoCommand>   104 #ifdef TESTPROVIDERLIB   110   const QString &qmlStyle,
   111   const QString &sldStyle,
   112   const QString &styleName,
   113   const QString &styleDescription,
   114   const QString &uiFileContent,
   128   QStringList &descriptions,
   146                                 const QString &baseName,
   147                                 const QString &providerKey,
   151   , mAuxiliaryLayer( nullptr )
   152   , mAuxiliaryLayerKey( QString() )
   153   , mReadExtentFromXml( options.readExtentFromXml )
   163   mGeometryOptions = qgis::make_unique<QgsGeometryOptions>();
   167   mStoredExpressionManager->setParent( 
this );
   170   mJoinBuffer->setParent( 
this );
   175   if ( !vectorLayerPath.isEmpty() && !
mProviderKey.isEmpty() )
   190   mSimplifyMethod.
setThreshold( settings.
value( QStringLiteral( 
"qgis/simplifyDrawingTol" ), mSimplifyMethod.
threshold() ).toFloat() );
   203   delete mDataProvider;
   206   delete mExpressionFieldBuffer;
   208   delete mDiagramLayerSettings;
   209   delete mDiagramRenderer;
   214   delete mConditionalStyles;
   215   delete mStoredExpressionManager;
   217   if ( mFeatureCounter )
   218     mFeatureCounter->
cancel();
   244   QList<QgsVectorLayerJoinInfo> joins = 
vectorJoins();
   245   const auto constJoins = joins;
   267   for ( 
const QgsAction &action : constActions )
   303     auto constraintIt = constraints.constBegin();
   304     for ( ; constraintIt != constraints.constEnd(); ++ constraintIt )
   380     p.setPen( QColor( 50, 100, 120, 200 ) );
   381     p.setBrush( QColor( 200, 200, 210, 120 ) );
   382     p.drawEllipse( x - m, y - m, m * 2 + 1, m * 2 + 1 );
   386     p.setPen( QColor( 255, 0, 0 ) );
   387     p.drawLine( x - m, y + m, x + m, y - m );
   388     p.drawLine( x - m, y - m, x + m, y + m );
   394   mSelectedFeatureIds.insert( fid );
   395   mPreviousSelectedFeatureIds.clear();
   402   mSelectedFeatureIds.unite( featureIds );
   403   mPreviousSelectedFeatureIds.clear();
   410   mSelectedFeatureIds.remove( fid );
   411   mPreviousSelectedFeatureIds.clear();
   418   mSelectedFeatureIds.subtract( featureIds );
   419   mPreviousSelectedFeatureIds.clear();
   432                                 .setFilterRect( rect )
   434                                 .setNoAttributes() );
   439     newSelection << feat.
id();
   468       newSelection << feat.
id();
   490       bool matches = exp.
evaluate( &context ).toBool();
   494         newSelection << feat.
id();
   498         newSelection << feat.
id();
   517       newSelection = mSelectedFeatureIds + ids;
   521       newSelection = mSelectedFeatureIds - ids;
   525       newSelection = mSelectedFeatureIds.intersect( ids );
   529   QgsFeatureIds deselectedFeatures = mSelectedFeatureIds - newSelection;
   530   mSelectedFeatureIds = newSelection;
   531   mPreviousSelectedFeatureIds.clear();
   539   if ( !intersectingIds.isEmpty() )
   541     QgsDebugMsgLevel( QStringLiteral( 
"Trying to select and deselect the same item at the same time. Unsure what to do. Selecting dubious items." ), 3 );
   544   mSelectedFeatureIds -= deselectIds;
   545   mSelectedFeatureIds += selectIds;
   546   mPreviousSelectedFeatureIds.clear();
   554   ids.subtract( mSelectedFeatureIds );
   569                                         .setFilterRect( rect )
   571                                         .setNoAttributes() );
   579     if ( mSelectedFeatureIds.contains( fet.
id() ) )
   581       deselectIds << fet.
id();
   585       selectIds << fet.
id();
   594   if ( mSelectedFeatureIds.isEmpty() )
   599   mPreviousSelectedFeatureIds = previous;
   604   if ( mPreviousSelectedFeatureIds.isEmpty() || !mSelectedFeatureIds.empty() )
   612   return mDataProvider;
   617   return mDataProvider;
   622   if ( 
mValid && mDataProvider && mDataProvider->
encoding() != encoding )
   631   delete mDiagramRenderer;
   632   mDiagramRenderer = r;
   649   if ( !
mValid || !
isSpatial() || mSelectedFeatureIds.isEmpty() || !mDataProvider ) 
   661                                           .setFilterFids( mSelectedFeatureIds )
   662                                           .setNoAttributes() );
   675                                           .setNoAttributes() );
   679       if ( mSelectedFeatureIds.contains( fet.
id() ) )
   690   if ( retval.
width() == 0.0 || retval.
height() == 0.0 )
   699       retval.
set( -1.0, -1.0, 1.0, 1.0 );
   708   return mLabelsEnabled && 
static_cast< bool >( mLabeling );
   713   mLabelsEnabled = enabled;
   718   if ( !mDiagramRenderer || !mDiagramLayerSettings )
   721   QList<QgsDiagramSettings> settingList = mDiagramRenderer->
diagramSettings();
   722   if ( !settingList.isEmpty() )
   724     return settingList.at( 0 ).enabled;
   731   if ( !mSymbolFeatureCounted )
   734   return mSymbolFeatureCountMap.value( legendKey, -1 );
   739   if ( !mSymbolFeatureCounted )
   742   return mSymbolFeatureIdMap.value( legendKey, 
QgsFeatureIds() );
   746   if ( ( mSymbolFeatureCounted || mFeatureCounter ) && !( storeSymbolFids && mSymbolFeatureIdMap.isEmpty() ) )
   747     return mFeatureCounter;
   749   mSymbolFeatureCountMap.clear();
   750   mSymbolFeatureIdMap.clear();
   755     return mFeatureCounter;
   757   if ( !mDataProvider )
   760     return mFeatureCounter;
   765     return mFeatureCounter;
   768   if ( !mFeatureCounter || ( mFeatureCounter && ( storeSymbolFids && mSymbolFeatureIdMap.isEmpty() ) ) )
   771     connect( mFeatureCounter, &
QgsTask::taskCompleted, 
this, &QgsVectorLayer::onFeatureCounterCompleted, Qt::UniqueConnection );
   772     connect( mFeatureCounter, &
QgsTask::taskTerminated, 
this, &QgsVectorLayer::onFeatureCounterTerminated, Qt::UniqueConnection );
   776   return mFeatureCounter;
   782   if ( force || !mReadExtentFromXml || ( mReadExtentFromXml && mXmlExtent.
isNull() ) )
   783     mValidExtent = 
false;
   794   if ( !mDefaultValueOnUpdateFields.isEmpty() )
   799     int size = mFields.
size();
   800     for ( 
int idx : qgis::as_const( mDefaultValueOnUpdateFields ) )
   802       if ( idx < 0 || idx >= size )
   819   if ( !mValidExtent && mLazyExtent && mDataProvider && !mDataProvider->
hasMetadata() && mReadExtentFromXml && !mXmlExtent.
isNull() )
   826   if ( !mValidExtent && mLazyExtent && mDataProvider && mDataProvider->
isValid() )
   843   if ( !
mValid || !mDataProvider )
   845     QgsDebugMsgLevel( QStringLiteral( 
"invoked with invalid layer or null mDataProvider" ), 3 );
   867         if ( it->hasGeometry() )
   878                                           .setNoAttributes() );
   913   if ( !
mValid || !mDataProvider )
   915     QgsDebugMsgLevel( QStringLiteral( 
"invoked with invalid layer or null mDataProvider" ), 3 );
   916     return customProperty( QStringLiteral( 
"storedSubsetString" ) ).toString();
   923   if ( !
mValid || !mDataProvider )
   925     QgsDebugMsgLevel( QStringLiteral( 
"invoked with invalid layer or null mDataProvider or while editing" ), 3 );
   929   else if ( mEditBuffer )
   958     double maximumSimplificationScale = mSimplifyMethod.
maximumScale();
   961     return !( maximumSimplificationScale > 1 && renderContext.
rendererScale() <= maximumSimplificationScale );
   968   return mConditionalStyles;
   973   if ( !
mValid || !mDataProvider )
   991   if ( !
mValid || !mEditBuffer || !mDataProvider )
   995   if ( mGeometryOptions->isActive() )
   998     mGeometryOptions->apply( geom );
  1002   bool success = mEditBuffer->
addFeature( feature );
  1009       success = mJoinBuffer->
addFeature( feature );
  1017   if ( !mEditBuffer || !mDataProvider )
  1023   if ( currentFeature.
isValid() )
  1025     bool hasChanged = 
false;
  1026     bool hasError = 
false;
  1038         QgsDebugMsgLevel( QStringLiteral( 
"geometry of feature %1 could not be changed." ).arg( updatedFeature.
id() ), 3 );
  1045     for ( 
int attr = 0; attr < fa.count(); ++attr )
  1047       if ( fa.at( attr ) != ca.at( attr ) )
  1055           QgsDebugMsgLevel( QStringLiteral( 
"attribute %1 of feature %2 could not be changed." ).arg( attr ).arg( updatedFeature.
id() ), 3 );
  1060     if ( hasChanged && !mDefaultValueOnUpdateFields.isEmpty() && !skipDefaultValues )
  1061       updateDefaultValues( updatedFeature.
id(), updatedFeature );
  1067     QgsDebugMsgLevel( QStringLiteral( 
"feature %1 could not be retrieved" ).arg( updatedFeature.
id() ), 3 );
  1075   if ( !
mValid || !mEditBuffer || !mDataProvider )
  1079   bool result = utils.
insertVertex( x, y, atFeatureId, beforeVertex );
  1088   if ( !
mValid || !mEditBuffer || !mDataProvider )
  1092   bool result = utils.
insertVertex( point, atFeatureId, beforeVertex );
  1101   if ( !
mValid || !mEditBuffer || !mDataProvider )
  1105   bool result = utils.
moveVertex( x, y, atFeatureId, atVertex );
  1114   if ( !
mValid || !mEditBuffer || !mDataProvider )
  1118   bool result = utils.
moveVertex( p, atFeatureId, atVertex );
  1127   if ( !
mValid || !mEditBuffer || !mDataProvider )
  1152   int count = mSelectedFeatureIds.size();
  1166     *deletedCount = deleted;
  1169   return deleted == count;
  1172 static const QgsPointSequence vectorPointXY2pointSequence( 
const QVector<QgsPointXY> &points )
  1175   pts.reserve( points.size() );
  1176   QVector<const QgsPointXY>::iterator it = points.constBegin();
  1177   while ( it != points.constEnd() )
  1186   return addRing( vectorPointXY2pointSequence( ring ), featureId );
  1191   if ( !
mValid || !mEditBuffer || !mDataProvider )
  1192     return QgsGeometry::OperationResult::LayerNotEditable;
  1198   if ( !mSelectedFeatureIds.isEmpty() )
  1200     result = utils.
addRing( ring, mSelectedFeatureIds, featureId );
  1203   if ( result != QgsGeometry::OperationResult::Success )
  1214   if ( !
mValid || !mEditBuffer || !mDataProvider )
  1217     return QgsGeometry::OperationResult::LayerNotEditable;
  1222     return QgsGeometry::OperationResult::InvalidInputGeometryType;
  1228     return QgsGeometry::OperationResult::AddRingNotClosed;
  1235   if ( !mSelectedFeatureIds.isEmpty() )
  1237     result = utils.
addRing( static_cast< QgsCurve * >( ring->
clone() ), mSelectedFeatureIds, featureId );
  1240   if ( result != QgsGeometry::OperationResult::Success )
  1253   pts.reserve( points.size() );
  1254   for ( QList<QgsPointXY>::const_iterator it = points.constBegin(); it != points.constEnd() ; ++it )
  1263   return addPart( vectorPointXY2pointSequence( points ) );
  1268   if ( !
mValid || !mEditBuffer || !mDataProvider )
  1269     return QgsGeometry::OperationResult::LayerNotEditable;
  1273   if ( mSelectedFeatureIds.empty() )
  1276     return QgsGeometry::OperationResult::SelectionIsEmpty;
  1278   else if ( mSelectedFeatureIds.size() > 1 )
  1281     return QgsGeometry::OperationResult::SelectionIsGreaterThanOne;
  1287   if ( result == QgsGeometry::OperationResult::Success )
  1294   if ( !
mValid || !mEditBuffer || !mDataProvider )
  1295     return QgsGeometry::OperationResult::LayerNotEditable;
  1299   if ( mSelectedFeatureIds.empty() )
  1302     return QgsGeometry::OperationResult::SelectionIsEmpty;
  1304   else if ( mSelectedFeatureIds.size() > 1 )
  1307     return QgsGeometry::OperationResult::SelectionIsGreaterThanOne;
  1313   if ( result == QgsGeometry::OperationResult::Success )
  1320   if ( !
mValid || !mEditBuffer || !mDataProvider )
  1321     return QgsGeometry::OperationResult::LayerNotEditable;
  1326   if ( result == QgsGeometry::OperationResult::Success )
  1333   return splitParts( vectorPointXY2pointSequence( splitLine ), topologicalEditing );
  1337   if ( !
mValid || !mEditBuffer || !mDataProvider )
  1338     return QgsGeometry::OperationResult::LayerNotEditable;
  1341   return utils.
splitParts( splitLine, topologicalEditing );
  1345   return splitFeatures( vectorPointXY2pointSequence( splitLine ), topologicalEditing );
  1350   if ( !
mValid || !mEditBuffer || !mDataProvider )
  1351     return QgsGeometry::OperationResult::LayerNotEditable;
  1354   return utils.
splitFeatures( splitLine, topologicalEditing );
  1359   if ( !
mValid || !mEditBuffer || !mDataProvider )
  1373   if ( !
mValid || !mEditBuffer || !mDataProvider )
  1382   if ( mLabeling == labeling )
  1391   if ( !
mValid || !mDataProvider )
  1453   if ( mDataProvider )
  1465     if ( !mRenderer->
accept( visitor ) )
  1469     if ( !mLabeling->
accept( visitor ) )
  1480   QDomNode pkeyNode = layer_node.namedItem( QStringLiteral( 
"provider" ) );
  1482   if ( pkeyNode.isNull() )
  1488     QDomElement pkeyElt = pkeyNode.toElement();
  1498   else if ( 
mDataSource.contains( QLatin1String( 
"dbname=" ) ) )
  1510     if ( !( 
mReadFlags & QgsMapLayer::FlagDontResolveLayers ) )
  1514     const QDomElement elem = layer_node.toElement();
  1517     if ( elem.hasAttribute( QStringLiteral( 
"wkbType" ) ) )
  1518       mWkbType = 
qgsEnumKeyToValue( elem.attribute( QStringLiteral( 
"wkbType" ) ), mWkbType );
  1521   QDomElement pkeyElem = pkeyNode.toElement();
  1522   if ( !pkeyElem.isNull() )
  1524     QString encodingString = pkeyElem.attribute( QStringLiteral( 
"encoding" ) );
  1525     if ( mDataProvider && !encodingString.isEmpty() )
  1532   mJoinBuffer->
readXml( layer_node );
  1544   QDomNode depsNode = layer_node.namedItem( QStringLiteral( 
"dataDependencies" ) );
  1545   QDomNodeList depsNodes = depsNode.childNodes();
  1546   QSet<QgsMapLayerDependency> sources;
  1547   for ( 
int i = 0; i < depsNodes.count(); i++ )
  1549     QString 
source = depsNodes.at( i ).toElement().attribute( QStringLiteral( 
"id" ) );
  1555   QDomElement legendElem = layer_node.firstChildElement( QStringLiteral( 
"legend" ) );
  1556   if ( !legendElem.isNull() )
  1557     legend->
readXml( legendElem, context );
  1561   if ( mReadExtentFromXml )
  1563     QDomNode extentNode = layer_node.namedItem( QStringLiteral( 
"extent" ) );
  1564     if ( !extentNode.isNull() )
  1571   const QDomNode asNode = layer_node.namedItem( QStringLiteral( 
"auxiliaryLayer" ) );
  1572   const QDomElement asElem = asNode.toElement();
  1573   if ( !asElem.isNull() )
  1575     mAuxiliaryLayerKey = asElem.attribute( QStringLiteral( 
"key" ) );
  1579   mServerProperties->readXml( layer_node );
  1589   setDataSource( dataSource, baseName, provider, options, loadDefaultStyleFlag );
  1598   setDataProvider( provider, options );
  1612     bool defaultLoadedFlag = 
false;
  1617       std::unique_ptr< QgsFeatureRenderer > defaultRenderer( mDataProvider->
createRenderer() );
  1618       if ( defaultRenderer )
  1620         defaultLoadedFlag = 
true;
  1627     if ( !defaultLoadedFlag && loadDefaultStyleFlag )
  1633     if ( !defaultLoadedFlag && 
isSpatial() )
  1643       std::unique_ptr< QgsAbstractVectorLayerLabeling > defaultLabeling( mDataProvider->
createLabeling() );
  1644       if ( defaultLabeling )
  1661     std::unique_ptr< QgsFeatureRenderer > defaultRenderer( mDataProvider->
createRenderer() );
  1662     if ( defaultRenderer )
  1677   delete mDataProvider;
  1684   if ( provider.compare( QLatin1String( 
"postgres" ) ) == 0 )
  1686     const QString checkUnicityKey { QStringLiteral( 
"checkPrimaryKeyUnicity" ) };
  1688     if ( ! uri.
hasParam( checkUnicityKey ) )
  1690       uri.
setParam( checkUnicityKey, mReadExtentFromXml ? 
"0" : 
"1" );
  1696   if ( !mDataProvider )
  1703   mDataProvider->setParent( 
this );
  1706   QgsDebugMsgLevel( QStringLiteral( 
"Instantiated the data provider plugin" ), 2 );
  1718     QgsDebugMsgLevel( QStringLiteral( 
"Set Data provider QgsLayerMetadata identifier[%1]" ).arg( 
metadata().identifier() ), 4 );
  1725   mWkbType = mDataProvider->
wkbType();
  1737     QRegExp reg( R
"lit("[^"]+"\."([^"] + )"( \([^)]+\))?)lit" );  1738     if ( reg.indexIn( 
name() ) >= 0 )
  1740       QStringList stuff = reg.capturedTexts();
  1741       QString lName = stuff[1];
  1745       QMap<QString, QgsMapLayer *>::const_iterator it;
  1746       for ( it = layers.constBegin(); it != layers.constEnd() && ( *it )->name() != lName; ++it )
  1749       if ( it != layers.constEnd() && stuff.size() > 2 )
  1751         lName += 
'.' + stuff[2].mid( 2, stuff[2].length() - 3 );
  1754       if ( !lName.isEmpty() )
  1764   else if ( provider == QLatin1String( 
"ogr" ) )
  1768     if ( 
mDataSource.right( 10 ) == QLatin1String( 
"|layerid=0" ) )
  1771   else if ( provider == QStringLiteral( 
"memory" ) )
  1788                                QDomDocument &document,
  1793   QDomElement mapLayerNode = layer_node.toElement();
  1795   if ( mapLayerNode.isNull() || ( 
"maplayer" != mapLayerNode.nodeName() ) )
  1801   mapLayerNode.setAttribute( QStringLiteral( 
"type" ), QStringLiteral( 
"vector" ) );
  1808   if ( mDataProvider )
  1810     QDomElement provider  = document.createElement( QStringLiteral( 
"provider" ) );
  1811     provider.setAttribute( QStringLiteral( 
"encoding" ), mDataProvider->
encoding() );
  1812     QDomText providerText = document.createTextNode( 
providerType() );
  1813     provider.appendChild( providerText );
  1814     layer_node.appendChild( provider );
  1818   mJoinBuffer->
writeXml( layer_node, document );
  1821   QDomElement dependenciesElement = document.createElement( QStringLiteral( 
"layerDependencies" ) );
  1827     QDomElement depElem = document.createElement( QStringLiteral( 
"layer" ) );
  1828     depElem.setAttribute( QStringLiteral( 
"id" ), dep.layerId() );
  1829     dependenciesElement.appendChild( depElem );
  1831   layer_node.appendChild( dependenciesElement );
  1834   QDomElement dataDependenciesElement = document.createElement( QStringLiteral( 
"dataDependencies" ) );
  1839     QDomElement depElem = document.createElement( QStringLiteral( 
"layer" ) );
  1840     depElem.setAttribute( QStringLiteral( 
"id" ), dep.layerId() );
  1841     dataDependenciesElement.appendChild( depElem );
  1843   layer_node.appendChild( dataDependenciesElement );
  1848     QDomElement legendElement = 
legend()->
writeXml( document, context );
  1849     if ( !legendElement.isNull() )
  1850       layer_node.appendChild( legendElement );
  1854   mExpressionFieldBuffer->
writeXml( layer_node, document );
  1859   QDomElement asElem = document.createElement( QStringLiteral( 
"auxiliaryLayer" ) );
  1860   if ( mAuxiliaryLayer )
  1862     const QString pkField = mAuxiliaryLayer->joinInfo().targetFieldName();
  1863     asElem.setAttribute( QStringLiteral( 
"key" ), pkField );
  1865   layer_node.appendChild( asElem );
  1868   mServerProperties->writeXml( layer_node, document );
  1872   return writeSymbology( layer_node, document, errorMsg, context );
  1877   QString src( source );
  1889     QStringList theURIParts = src.split( 
'|' );
  1891     src = theURIParts.join( QStringLiteral( 
"|" ) );
  1895     QStringList theURIParts = src.split( 
'?' );
  1897     src = theURIParts.join( QStringLiteral( 
"?" ) );
  1899   else if ( 
providerType() == QLatin1String( 
"delimitedtext" ) )
  1901     QUrl urlSource = QUrl::fromEncoded( src.toLatin1() );
  1903     urlDest.setQuery( urlSource.query() );
  1904     src = QString::fromLatin1( urlDest.toEncoded() );
  1906   else if ( 
providerType() == QLatin1String( 
"memory" ) )
  1911   else if ( 
providerType() == QLatin1String( 
"virtual" ) )
  1913     QUrl urlSource = QUrl::fromEncoded( src.toLatin1() );
  1914     QStringList theURIParts;
  1916     QUrlQuery query = QUrlQuery( urlSource.query() );
  1917     QList<QPair<QString, QString> > queryItems = query.queryItems();
  1919     for ( 
int i = 0; i < queryItems.size(); i++ )
  1921       QString key = queryItems.at( i ).first;
  1922       QString value = queryItems.at( i ).second;
  1923       if ( key == QLatin1String( 
"layer" ) )
  1926         theURIParts = value.split( 
':' );
  1927         theURIParts[1] = QUrl::fromPercentEncoding( theURIParts[1].toUtf8() );
  1929         theURIParts[1] = QUrl::toPercentEncoding( theURIParts[1] );
  1930         queryItems[i].second =  theURIParts.join( QStringLiteral( 
":" ) ) ;
  1934     query.setQueryItems( queryItems );
  1936     QUrl urlDest = QUrl( urlSource );
  1937     urlDest.setQuery( query.query() );
  1938     src = QString::fromLatin1( urlDest.toEncoded() );
  1950   QString src( source );
  1952   if ( provider == QLatin1String( 
"spatialite" ) )
  1958   else if ( provider == QLatin1String( 
"ogr" ) )
  1960     QStringList theURIParts = src.split( 
'|' );
  1962     src = theURIParts.join( QStringLiteral( 
"|" ) );
  1964   else if ( provider == QLatin1String( 
"gpx" ) )
  1966     QStringList theURIParts = src.split( 
'?' );
  1968     src = theURIParts.join( QStringLiteral( 
"?" ) );
  1970   else if ( provider == QLatin1String( 
"delimitedtext" ) )
  1972     QUrl urlSource = QUrl::fromEncoded( src.toLatin1() );
  1974     if ( !src.startsWith( QLatin1String( 
"file:" ) ) )
  1976       QUrl file = QUrl::fromLocalFile( src.left( src.indexOf( 
'?' ) ) );
  1977       urlSource.setScheme( QStringLiteral( 
"file" ) );
  1978       urlSource.setPath( file.path() );
  1981     QUrl urlDest = QUrl::fromLocalFile( context.
pathResolver().
readPath( urlSource.toLocalFile() ) );
  1982     urlDest.setQuery( urlSource.query() );
  1983     src = QString::fromLatin1( urlDest.toEncoded() );
  1985   else if ( provider == QLatin1String( 
"virtual" ) )
  1987     QUrl urlSource = QUrl::fromEncoded( src.toLatin1() );
  1988     QStringList theURIParts;
  1990     QUrlQuery query = QUrlQuery( urlSource.query() );
  1991     QList<QPair<QString, QString> > queryItems = query.queryItems();
  1993     for ( 
int i = 0; i < queryItems.size(); i++ )
  1995       QString key = queryItems.at( i ).first;
  1996       QString value = queryItems.at( i ).second;
  1997       if ( key == QLatin1String( 
"layer" ) )
  2000         theURIParts = value.split( 
':' );
  2001         theURIParts[1] = QUrl::fromPercentEncoding( theURIParts[1].toUtf8() );
  2003         theURIParts[1] = QUrl::toPercentEncoding( theURIParts[1] );
  2004         queryItems[i].second =  theURIParts.join( QStringLiteral( 
":" ) ) ;
  2008     query.setQueryItems( queryItems );
  2010     QUrl urlDest = QUrl( urlSource );
  2011     urlDest.setQuery( query.query() );
  2012     src = QString::fromLatin1( urlDest.toEncoded() );
  2036   if ( categories.testFlag( 
Fields ) )
  2038     if ( !mExpressionFieldBuffer )
  2040     mExpressionFieldBuffer->
readXml( layerNode );
  2051     QDomNodeList referencedLayersNodeList = layerNode.toElement().elementsByTagName( QStringLiteral( 
"referencedLayers" ) );
  2052     if ( referencedLayersNodeList.size() > 0 )
  2054       const QDomNodeList relationNodes { referencedLayersNodeList.at( 0 ).childNodes() };
  2055       for ( 
int i = 0; i < relationNodes.length(); ++i )
  2057         const QDomElement relationElement = relationNodes.at( i ).toElement();
  2058         QList<QgsRelation::FieldPair> fieldPairs;
  2059         const QDomNodeList fieldPairNodes { relationElement.elementsByTagName( QStringLiteral( 
"fieldPair" ) ) };
  2060         for ( 
int j = 0; j < fieldPairNodes.length(); ++j )
  2062           const QDomElement fieldPairElement = fieldPairNodes.at( j ).toElement();
  2063           fieldPairs.push_back( { fieldPairElement.attribute( QStringLiteral( 
"referencing" ) ),
  2064                                   fieldPairElement.attribute( QStringLiteral( 
"referenced" ) ) } );
  2066         mWeakRelations.push_back( 
QgsWeakRelation { relationElement.attribute( QStringLiteral( 
"id" ) ),
  2067                                   relationElement.attribute( QStringLiteral( 
"name" ) ),
  2075                                   relationElement.attribute( QStringLiteral( 
"layerId" ) ),
  2076                                   relationElement.attribute( QStringLiteral( 
"layerName" ) ),
  2077                                   relationElement.attribute( QStringLiteral( 
"dataSource" ) ),
  2078                                   relationElement.attribute( QStringLiteral( 
"providerKey" ) ),
  2085     QDomNodeList referencingLayersNodeList = layerNode.toElement().elementsByTagName( QStringLiteral( 
"referencingLayers" ) );
  2086     if ( referencingLayersNodeList.size() > 0 )
  2088       const QDomNodeList relationNodes { referencingLayersNodeList.at( 0 ).childNodes() };
  2089       for ( 
int i = 0; i < relationNodes.length(); ++i )
  2091         const QDomElement relationElement = relationNodes.at( i ).toElement();
  2092         QList<QgsRelation::FieldPair> fieldPairs;
  2093         const QDomNodeList fieldPairNodes { relationElement.elementsByTagName( QStringLiteral( 
"fieldPair" ) ) };
  2094         for ( 
int j = 0; j < fieldPairNodes.length(); ++j )
  2096           const QDomElement fieldPairElement = fieldPairNodes.at( j ).toElement();
  2097           fieldPairs.push_back( { fieldPairElement.attribute( QStringLiteral( 
"referencing" ) ),
  2098                                   fieldPairElement.attribute( QStringLiteral( 
"referenced" ) ) } );
  2100         mWeakRelations.push_back( 
QgsWeakRelation { relationElement.attribute( QStringLiteral( 
"id" ) ),
  2101                                   relationElement.attribute( QStringLiteral( 
"name" ) ),
  2104                                   relationElement.attribute( QStringLiteral( 
"layerId" ) ),
  2105                                   relationElement.attribute( QStringLiteral( 
"layerName" ) ),
  2106                                   relationElement.attribute( QStringLiteral( 
"dataSource" ) ),
  2107                                   relationElement.attribute( QStringLiteral( 
"providerKey" ) ),
  2119   QDomElement layerElement = layerNode.toElement();
  2123   readStyle( layerNode, errorMessage, context, categories );
  2125   if ( categories.testFlag( 
MapTips ) )
  2126     mMapTipTemplate = layerNode.namedItem( QStringLiteral( 
"mapTip" ) ).toElement().text();
  2129     mDisplayExpression = layerNode.namedItem( QStringLiteral( 
"previewExpression" ) ).toElement().text();
  2132   QString 
displayField = layerNode.namedItem( QStringLiteral( 
"displayfield" ) ).toElement().text();
  2136     if ( mMapTipTemplate.isEmpty() && categories.testFlag( 
MapTips ) )
  2137       mMapTipTemplate = displayField;
  2146   if ( categories.testFlag( 
Actions ) )
  2147     mActions->
readXml( layerNode );
  2149   if ( categories.testFlag( 
Fields ) )
  2151     mAttributeAliasMap.clear();
  2152     QDomNode aliasesNode = layerNode.namedItem( QStringLiteral( 
"aliases" ) );
  2153     if ( !aliasesNode.isNull() )
  2155       QDomElement aliasElem;
  2157       QDomNodeList aliasNodeList = aliasesNode.toElement().elementsByTagName( QStringLiteral( 
"alias" ) );
  2158       for ( 
int i = 0; i < aliasNodeList.size(); ++i )
  2160         aliasElem = aliasNodeList.at( i ).toElement();
  2163         if ( aliasElem.hasAttribute( QStringLiteral( 
"field" ) ) )
  2165           field = aliasElem.attribute( QStringLiteral( 
"field" ) );
  2169           int index = aliasElem.attribute( QStringLiteral( 
"index" ) ).toInt();
  2171           if ( index >= 0 && index < 
fields().count() )
  2177         if ( !aliasElem.attribute( QStringLiteral( 
"name" ) ).isEmpty() )
  2180           alias = context.
projectTranslator()->
translate( QStringLiteral( 
"project:layers:%1:fieldaliases" ).arg( layerNode.namedItem( QStringLiteral( 
"id" ) ).toElement().text() ), aliasElem.attribute( QStringLiteral( 
"name" ) ) );
  2181           QgsDebugMsgLevel( 
"context" + QStringLiteral( 
"project:layers:%1:fieldaliases" ).arg( layerNode.namedItem( QStringLiteral( 
"id" ) ).toElement().text() ) + 
" source " + aliasElem.attribute( QStringLiteral( 
"name" ) ), 3 );
  2186           alias = context.
projectTranslator()->
translate( QStringLiteral( 
"project:layers:%1:fieldaliases" ).arg( layerNode.namedItem( QStringLiteral( 
"id" ) ).toElement().text() ), field );
  2187           QgsDebugMsgLevel( 
"context" + QStringLiteral( 
"project:layers:%1:fieldaliases" ).arg( layerNode.namedItem( QStringLiteral( 
"id" ) ).toElement().text() ) + 
" source " + field, 3 );
  2189           if ( alias == aliasElem.attribute( QStringLiteral( 
"field" ) ) )
  2193         QgsDebugMsgLevel( 
"field " + field + 
" origalias " + aliasElem.attribute( QStringLiteral( 
"name" ) ) + 
" trans " + alias, 3 );
  2194         mAttributeAliasMap.insert( field, alias );
  2199     mDefaultExpressionMap.clear();
  2200     QDomNode defaultsNode = layerNode.namedItem( QStringLiteral( 
"defaults" ) );
  2201     if ( !defaultsNode.isNull() )
  2203       QDomNodeList defaultNodeList = defaultsNode.toElement().elementsByTagName( QStringLiteral( 
"default" ) );
  2204       for ( 
int i = 0; i < defaultNodeList.size(); ++i )
  2206         QDomElement defaultElem = defaultNodeList.at( i ).toElement();
  2208         QString field = defaultElem.attribute( QStringLiteral( 
"field" ), QString() );
  2209         QString expression = defaultElem.attribute( QStringLiteral( 
"expression" ), QString() );
  2210         bool applyOnUpdate = defaultElem.attribute( QStringLiteral( 
"applyOnUpdate" ), QStringLiteral( 
"0" ) ) == QLatin1String( 
"1" );
  2211         if ( field.isEmpty() || expression.isEmpty() )
  2214         mDefaultExpressionMap.insert( field, 
QgsDefaultValue( expression, applyOnUpdate ) );
  2219     mFieldConstraints.clear();
  2220     mFieldConstraintStrength.clear();
  2221     QDomNode constraintsNode = layerNode.namedItem( QStringLiteral( 
"constraints" ) );
  2222     if ( !constraintsNode.isNull() )
  2224       QDomNodeList constraintNodeList = constraintsNode.toElement().elementsByTagName( QStringLiteral( 
"constraint" ) );
  2225       for ( 
int i = 0; i < constraintNodeList.size(); ++i )
  2227         QDomElement constraintElem = constraintNodeList.at( i ).toElement();
  2229         QString field = constraintElem.attribute( QStringLiteral( 
"field" ), QString() );
  2230         int constraints = constraintElem.attribute( QStringLiteral( 
"constraints" ), QStringLiteral( 
"0" ) ).toInt();
  2231         if ( field.isEmpty() || constraints == 0 )
  2234         mFieldConstraints.insert( field, static_cast< QgsFieldConstraints::Constraints >( constraints ) );
  2236         int uniqueStrength = constraintElem.attribute( QStringLiteral( 
"unique_strength" ), QStringLiteral( 
"1" ) ).toInt();
  2237         int notNullStrength = constraintElem.attribute( QStringLiteral( 
"notnull_strength" ), QStringLiteral( 
"1" ) ).toInt();
  2238         int expStrength = constraintElem.attribute( QStringLiteral( 
"exp_strength" ), QStringLiteral( 
"1" ) ).toInt();
  2245     mFieldConstraintExpressions.clear();
  2246     QDomNode constraintExpressionsNode = layerNode.namedItem( QStringLiteral( 
"constraintExpressions" ) );
  2247     if ( !constraintExpressionsNode.isNull() )
  2249       QDomNodeList constraintNodeList = constraintExpressionsNode.toElement().elementsByTagName( QStringLiteral( 
"constraint" ) );
  2250       for ( 
int i = 0; i < constraintNodeList.size(); ++i )
  2252         QDomElement constraintElem = constraintNodeList.at( i ).toElement();
  2254         QString field = constraintElem.attribute( QStringLiteral( 
"field" ), QString() );
  2255         QString exp = constraintElem.attribute( QStringLiteral( 
"exp" ), QString() );
  2256         QString desc = constraintElem.attribute( QStringLiteral( 
"desc" ), QString() );
  2257         if ( field.isEmpty() || exp.isEmpty() )
  2260         mFieldConstraintExpressions.insert( field, qMakePair( exp, desc ) );
  2267     mExcludeAttributesWMS.clear();
  2268     QDomNode excludeWMSNode = layerNode.namedItem( QStringLiteral( 
"excludeAttributesWMS" ) );
  2269     if ( !excludeWMSNode.isNull() )
  2271       QDomNodeList attributeNodeList = excludeWMSNode.toElement().elementsByTagName( QStringLiteral( 
"attribute" ) );
  2272       for ( 
int i = 0; i < attributeNodeList.size(); ++i )
  2274         mExcludeAttributesWMS.insert( attributeNodeList.at( i ).toElement().text() );
  2278     mExcludeAttributesWFS.clear();
  2279     QDomNode excludeWFSNode = layerNode.namedItem( QStringLiteral( 
"excludeAttributesWFS" ) );
  2280     if ( !excludeWFSNode.isNull() )
  2282       QDomNodeList attributeNodeList = excludeWFSNode.toElement().elementsByTagName( QStringLiteral( 
"attribute" ) );
  2283       for ( 
int i = 0; i < attributeNodeList.size(); ++i )
  2285         mExcludeAttributesWFS.insert( attributeNodeList.at( i ).toElement().text() );
  2290     QDomElement widgetsElem = layerNode.namedItem( QStringLiteral( 
"fieldConfiguration" ) ).toElement();
  2291     QDomNodeList fieldConfigurationElementList = widgetsElem.elementsByTagName( QStringLiteral( 
"field" ) );
  2292     for ( 
int i = 0; i < fieldConfigurationElementList.size(); ++i )
  2294       const QDomElement fieldConfigElement = fieldConfigurationElementList.at( i ).toElement();
  2295       const QDomElement fieldWidgetElement = fieldConfigElement.elementsByTagName( QStringLiteral( 
"editWidget" ) ).at( 0 ).toElement();
  2297       QString fieldName = fieldConfigElement.attribute( QStringLiteral( 
"name" ) );
  2299       const QString widgetType = fieldWidgetElement.attribute( QStringLiteral( 
"type" ) );
  2300       const QDomElement cfgElem = fieldConfigElement.elementsByTagName( QStringLiteral( 
"config" ) ).at( 0 ).toElement();
  2301       const QDomElement optionsElem = cfgElem.childNodes().at( 0 ).toElement();
  2303       if ( widgetType == QStringLiteral( 
"ValueRelation" ) )
  2305         optionsMap[ QStringLiteral( 
"Value" ) ] = context.
projectTranslator()->
translate( QStringLiteral( 
"project:layers:%1:fields:%2:valuerelationvalue" ).arg( layerNode.namedItem( QStringLiteral( 
"id" ) ).toElement().text(), fieldName ), optionsMap[ QStringLiteral( 
"Value" ) ].toString() );
  2308       mFieldWidgetSetups[fieldName] = setup;
  2313     mGeometryOptions->readXml( layerNode.namedItem( QStringLiteral( 
"geometryOptions" ) ) );
  2315   if ( categories.testFlag( 
Forms ) )
  2316     mEditFormConfig.
readXml( layerNode, context );
  2320     mAttributeTableConfig.
readXml( layerNode );
  2321     mConditionalStyles->
readXml( layerNode, context );
  2322     mStoredExpressionManager->
readXml( layerNode );
  2328   QDomElement mapLayerNode = layerNode.toElement();
  2330        && mapLayerNode.attribute( QStringLiteral( 
"readOnly" ), QStringLiteral( 
"0" ) ).toInt() == 1 )
  2353       if ( !rendererElement.isNull() )
  2373     if ( categories.testFlag( 
Labeling ) )
  2375       QDomElement labelingElement = node.firstChildElement( QStringLiteral( 
"labeling" ) );
  2377       if ( labelingElement.isNull() ||
  2378            ( labelingElement.attribute( QStringLiteral( 
"type" ) ) == QLatin1String( 
"simple" ) && labelingElement.firstChildElement( QStringLiteral( 
"settings" ) ).isNull() ) )
  2386         labeling = readLabelingFromCustomProperties();
  2394       if ( node.toElement().hasAttribute( QStringLiteral( 
"labelsEnabled" ) ) )
  2395         mLabelsEnabled = node.toElement().attribute( QStringLiteral( 
"labelsEnabled" ) ).toInt();
  2397         mLabelsEnabled = 
true;
  2403       QDomNode blendModeNode = node.namedItem( QStringLiteral( 
"blendMode" ) );
  2404       if ( !blendModeNode.isNull() )
  2406         QDomElement e = blendModeNode.toElement();
  2411       QDomNode featureBlendModeNode = node.namedItem( QStringLiteral( 
"featureBlendMode" ) );
  2412       if ( !featureBlendModeNode.isNull() )
  2414         QDomElement e = featureBlendModeNode.toElement();
  2422       QDomNode layerTransparencyNode = node.namedItem( QStringLiteral( 
"layerTransparency" ) );
  2423       if ( !layerTransparencyNode.isNull() )
  2425         QDomElement e = layerTransparencyNode.toElement();
  2426         setOpacity( 1.0 - e.text().toInt() / 100.0 );
  2428       QDomNode layerOpacityNode = node.namedItem( QStringLiteral( 
"layerOpacity" ) );
  2429       if ( !layerOpacityNode.isNull() )
  2431         QDomElement e = layerOpacityNode.toElement();
  2435       const bool hasScaleBasedVisibiliy { node.attributes().namedItem( QStringLiteral( 
"hasScaleBasedVisibilityFlag" ) ).nodeValue() == 
'1' };
  2438       const double maxScale { node.attributes().namedItem( QStringLiteral( 
"maxScale" ) ).nodeValue().toDouble( &ok ) };
  2443       const double minScale { node.attributes().namedItem( QStringLiteral( 
"minScale" ) ).nodeValue().toDouble( &ok ) };
  2452       QDomElement e = node.toElement();
  2455       mSimplifyMethod.
setSimplifyHints( static_cast< QgsVectorSimplifyMethod::SimplifyHints >( e.attribute( QStringLiteral( 
"simplifyDrawingHints" ), QStringLiteral( 
"1" ) ).toInt() ) );
  2456       mSimplifyMethod.
setSimplifyAlgorithm( static_cast< QgsVectorSimplifyMethod::SimplifyAlgorithm >( e.attribute( QStringLiteral( 
"simplifyAlgorithm" ), QStringLiteral( 
"0" ) ).toInt() ) );
  2457       mSimplifyMethod.
setThreshold( e.attribute( QStringLiteral( 
"simplifyDrawingTol" ), QStringLiteral( 
"1" ) ).toFloat() );
  2458       mSimplifyMethod.
setForceLocalOptimization( e.attribute( QStringLiteral( 
"simplifyLocal" ), QStringLiteral( 
"1" ) ).toInt() );
  2459       mSimplifyMethod.
setMaximumScale( e.attribute( QStringLiteral( 
"simplifyMaxScale" ), QStringLiteral( 
"1" ) ).toFloat() );
  2463     if ( categories.testFlag( 
Diagrams ) )
  2465       delete mDiagramRenderer;
  2466       mDiagramRenderer = 
nullptr;
  2467       QDomElement singleCatDiagramElem = node.firstChildElement( QStringLiteral( 
"SingleCategoryDiagramRenderer" ) );
  2468       if ( !singleCatDiagramElem.isNull() )
  2471         mDiagramRenderer->
readXml( singleCatDiagramElem, context );
  2473       QDomElement linearDiagramElem = node.firstChildElement( QStringLiteral( 
"LinearlyInterpolatedDiagramRenderer" ) );
  2474       if ( !linearDiagramElem.isNull() )
  2476         if ( linearDiagramElem.hasAttribute( QStringLiteral( 
"classificationAttribute" ) ) )
  2479           int idx = linearDiagramElem.attribute( QStringLiteral( 
"classificationAttribute" ) ).toInt();
  2480           if ( idx >= 0 && idx < mFields.
count() )
  2481             linearDiagramElem.setAttribute( QStringLiteral( 
"classificationField" ), mFields.
at( idx ).
name() );
  2485         mDiagramRenderer->
readXml( linearDiagramElem, context );
  2488       if ( mDiagramRenderer )
  2490         QDomElement diagramSettingsElem = node.firstChildElement( QStringLiteral( 
"DiagramLayerSettings" ) );
  2491         if ( !diagramSettingsElem.isNull() )
  2493           bool oldXPos = diagramSettingsElem.hasAttribute( QStringLiteral( 
"xPosColumn" ) );
  2494           bool oldYPos = diagramSettingsElem.hasAttribute( QStringLiteral( 
"yPosColumn" ) );
  2495           bool oldShow = diagramSettingsElem.hasAttribute( QStringLiteral( 
"showColumn" ) );
  2496           if ( oldXPos || oldYPos || oldShow )
  2502               int xPosColumn = diagramSettingsElem.attribute( QStringLiteral( 
"xPosColumn" ) ).toInt();
  2503               if ( xPosColumn >= 0 && xPosColumn < mFields.
count() )
  2508               int yPosColumn = diagramSettingsElem.attribute( QStringLiteral( 
"yPosColumn" ) ).toInt();
  2509               if ( yPosColumn >= 0 && yPosColumn < mFields.
count() )
  2514               int showColumn = diagramSettingsElem.attribute( QStringLiteral( 
"showColumn" ) ).toInt();
  2515               if ( showColumn >= 0 && showColumn < mFields.
count() )
  2518             QDomElement propertiesElem = diagramSettingsElem.ownerDocument().createElement( QStringLiteral( 
"properties" ) );
  2525             ddp.
writeXml( propertiesElem, defs );
  2526             diagramSettingsElem.appendChild( propertiesElem );
  2529           delete mDiagramLayerSettings;
  2531           mDiagramLayerSettings->
readXml( diagramSettingsElem );
  2544   QDomElement layerElement = node.toElement();
  2547   ( void )
writeStyle( node, doc, errorMessage, context, categories );
  2550     mGeometryOptions->writeXml( node );
  2560     QDomElement referencedLayersElement = doc.createElement( QStringLiteral( 
"referencedLayers" ) );
  2561     node.appendChild( referencedLayersElement );
  2564     for ( 
const auto &rel : constReferencingRelations )
  2567       QDomElement relationElement = doc.createElement( QStringLiteral( 
"relation" ) );
  2568       referencedLayersElement.appendChild( relationElement );
  2570       relationElement.setAttribute( QStringLiteral( 
"id" ), rel.id() );
  2571       relationElement.setAttribute( QStringLiteral( 
"name" ), rel.name() );
  2572       relationElement.setAttribute( QStringLiteral( 
"strength" ), rel.strength() );
  2573       relationElement.setAttribute( QStringLiteral( 
"layerId" ), rel.referencedLayer()->id() );
  2574       relationElement.setAttribute( QStringLiteral( 
"layerName" ), rel.referencedLayer()->name() );
  2575       relationElement.setAttribute( QStringLiteral( 
"dataSource" ), resolver.writePath( rel.referencedLayer()->publicSource() ) );
  2576       relationElement.setAttribute( QStringLiteral( 
"providerKey" ), rel.referencedLayer()->providerType() );
  2578       const QList<QgsRelation::FieldPair> constFieldPairs { rel.fieldPairs() };
  2581         QDomElement fieldPair = doc.createElement( QStringLiteral( 
"fieldPair" ) );
  2582         relationElement.appendChild( fieldPair );
  2583         fieldPair.setAttribute( QStringLiteral( 
"referenced" ), fp.referencedField() );
  2584         fieldPair.setAttribute( QStringLiteral( 
"referencing" ), fp.referencingField() );
  2590     QDomElement referencingLayersElement = doc.createElement( QStringLiteral( 
"referencingLayers" ) );
  2591     node.appendChild( referencingLayersElement );
  2594     for ( 
const auto &rel : constReferencedRelations )
  2597       QDomElement relationElement = doc.createElement( QStringLiteral( 
"relation" ) );
  2598       referencingLayersElement.appendChild( relationElement );
  2600       relationElement.setAttribute( QStringLiteral( 
"id" ), rel.id() );
  2601       relationElement.setAttribute( QStringLiteral( 
"name" ), rel.name() );
  2602       relationElement.setAttribute( QStringLiteral( 
"strength" ), rel.strength() );
  2603       relationElement.setAttribute( QStringLiteral( 
"layerId" ), rel.referencingLayer()->id() );
  2604       relationElement.setAttribute( QStringLiteral( 
"layerName" ), rel.referencingLayer()->name() );
  2605       relationElement.setAttribute( QStringLiteral( 
"dataSource" ), resolver.writePath( rel.referencingLayer()->publicSource() ) );
  2606       relationElement.setAttribute( QStringLiteral( 
"providerKey" ), rel.referencingLayer()->providerType() );
  2608       const QList<QgsRelation::FieldPair> constFieldPairs { rel.fieldPairs() };
  2611         QDomElement fieldPair = doc.createElement( QStringLiteral( 
"fieldPair" ) );
  2612         relationElement.appendChild( fieldPair );
  2613         fieldPair.setAttribute( QStringLiteral( 
"referenced" ), fp.referencedField() );
  2614         fieldPair.setAttribute( QStringLiteral( 
"referencing" ), fp.referencingField() );
  2620   if ( categories.testFlag( 
Fields ) )
  2622     QDomElement fieldConfigurationElement = doc.createElement( QStringLiteral( 
"fieldConfiguration" ) );
  2623     node.appendChild( fieldConfigurationElement );
  2626     for ( 
const QgsField &field : mFields )
  2628       QDomElement fieldElement = doc.createElement( QStringLiteral( 
"field" ) );
  2629       fieldElement.setAttribute( QStringLiteral( 
"name" ), field.name() );
  2631       fieldConfigurationElement.appendChild( fieldElement );
  2636       QDomElement editWidgetElement = doc.createElement( QStringLiteral( 
"editWidget" ) );
  2637       fieldElement.appendChild( editWidgetElement );
  2638       editWidgetElement.setAttribute( QStringLiteral( 
"type" ), field.editorWidgetSetup().type() );
  2639       QDomElement editWidgetConfigElement = doc.createElement( QStringLiteral( 
"config" ) );
  2642       editWidgetElement.appendChild( editWidgetConfigElement );
  2649     QDomElement aliasElem = doc.createElement( QStringLiteral( 
"aliases" ) );
  2650     for ( 
const QgsField &field : mFields )
  2652       QDomElement aliasEntryElem = doc.createElement( QStringLiteral( 
"alias" ) );
  2653       aliasEntryElem.setAttribute( QStringLiteral( 
"field" ), field.name() );
  2654       aliasEntryElem.setAttribute( QStringLiteral( 
"index" ), mFields.indexFromName( field.name() ) );
  2655       aliasEntryElem.setAttribute( QStringLiteral( 
"name" ), field.alias() );
  2656       aliasElem.appendChild( aliasEntryElem );
  2658     node.appendChild( aliasElem );
  2661     QDomElement excludeWMSElem = doc.createElement( QStringLiteral( 
"excludeAttributesWMS" ) );
  2662     QSet<QString>::const_iterator attWMSIt = mExcludeAttributesWMS.constBegin();
  2663     for ( ; attWMSIt != mExcludeAttributesWMS.constEnd(); ++attWMSIt )
  2665       QDomElement attrElem = doc.createElement( QStringLiteral( 
"attribute" ) );
  2666       QDomText attrText = doc.createTextNode( *attWMSIt );
  2667       attrElem.appendChild( attrText );
  2668       excludeWMSElem.appendChild( attrElem );
  2670     node.appendChild( excludeWMSElem );
  2673     QDomElement excludeWFSElem = doc.createElement( QStringLiteral( 
"excludeAttributesWFS" ) );
  2674     QSet<QString>::const_iterator attWFSIt = mExcludeAttributesWFS.constBegin();
  2675     for ( ; attWFSIt != mExcludeAttributesWFS.constEnd(); ++attWFSIt )
  2677       QDomElement attrElem = doc.createElement( QStringLiteral( 
"attribute" ) );
  2678       QDomText attrText = doc.createTextNode( *attWFSIt );
  2679       attrElem.appendChild( attrText );
  2680       excludeWFSElem.appendChild( attrElem );
  2682     node.appendChild( excludeWFSElem );
  2685     QDomElement defaultsElem = doc.createElement( QStringLiteral( 
"defaults" ) );
  2686     for ( 
const QgsField &field : mFields )
  2688       QDomElement defaultElem = doc.createElement( QStringLiteral( 
"default" ) );
  2689       defaultElem.setAttribute( QStringLiteral( 
"field" ), field.name() );
  2690       defaultElem.setAttribute( QStringLiteral( 
"expression" ), field.defaultValueDefinition().expression() );
  2691       defaultElem.setAttribute( QStringLiteral( 
"applyOnUpdate" ), field.defaultValueDefinition().applyOnUpdate() ? QStringLiteral( 
"1" ) : QStringLiteral( 
"0" ) );
  2692       defaultsElem.appendChild( defaultElem );
  2694     node.appendChild( defaultsElem );
  2697     QDomElement constraintsElem = doc.createElement( QStringLiteral( 
"constraints" ) );
  2698     for ( 
const QgsField &field : mFields )
  2700       QDomElement constraintElem = doc.createElement( QStringLiteral( 
"constraint" ) );
  2701       constraintElem.setAttribute( QStringLiteral( 
"field" ), field.name() );
  2702       constraintElem.setAttribute( QStringLiteral( 
"constraints" ), field.constraints().constraints() );
  2706       constraintsElem.appendChild( constraintElem );
  2708     node.appendChild( constraintsElem );
  2711     QDomElement constraintExpressionsElem = doc.createElement( QStringLiteral( 
"constraintExpressions" ) );
  2712     for ( 
const QgsField &field : mFields )
  2714       QDomElement constraintExpressionElem = doc.createElement( QStringLiteral( 
"constraint" ) );
  2715       constraintExpressionElem.setAttribute( QStringLiteral( 
"field" ), field.name() );
  2716       constraintExpressionElem.setAttribute( QStringLiteral( 
"exp" ), field.constraints().constraintExpression() );
  2717       constraintExpressionElem.setAttribute( QStringLiteral( 
"desc" ), field.constraints().constraintDescription() );
  2718       constraintExpressionsElem.appendChild( constraintExpressionElem );
  2720     node.appendChild( constraintExpressionsElem );
  2723     if ( !mExpressionFieldBuffer )
  2731       mExpressionFieldBuffer->
writeXml( node, doc );
  2736   if ( categories.testFlag( 
Actions ) )
  2741     mAttributeTableConfig.
writeXml( node );
  2742     mConditionalStyles->
writeXml( node, doc, context );
  2743     mStoredExpressionManager->
writeXml( node );
  2746   if ( categories.testFlag( 
Forms ) )
  2747     mEditFormConfig.
writeXml( node, context );
  2751     node.toElement().setAttribute( QStringLiteral( 
"readOnly" ), mReadOnly );
  2756     QDomElement prevExpElem = doc.createElement( QStringLiteral( 
"previewExpression" ) );
  2757     QDomText prevExpText = doc.createTextNode( mDisplayExpression );
  2758     prevExpElem.appendChild( prevExpText );
  2759     node.appendChild( prevExpElem );
  2763   if ( categories.testFlag( 
MapTips ) )
  2765     QDomElement mapTipElem = doc.createElement( QStringLiteral( 
"mapTip" ) );
  2766     QDomText mapTipText = doc.createTextNode( mMapTipTemplate );
  2767     mapTipElem.appendChild( mapTipText );
  2768     node.toElement().appendChild( mapTipElem );
  2777   QDomElement mapLayerNode = node.toElement();
  2787         QDomElement rendererElement = mRenderer->
save( doc, context );
  2788         node.appendChild( rendererElement );
  2792     if ( categories.testFlag( 
Labeling ) )
  2796         QDomElement labelingElement = mLabeling->
save( doc, context );
  2797         node.appendChild( labelingElement );
  2799       mapLayerNode.setAttribute( QStringLiteral( 
"labelsEnabled" ), mLabelsEnabled ? QStringLiteral( 
"1" ) : QStringLiteral( 
"0" ) );
  2805       mapLayerNode.setAttribute( QStringLiteral( 
"simplifyDrawingHints" ), QString::number( mSimplifyMethod.
simplifyHints() ) );
  2806       mapLayerNode.setAttribute( QStringLiteral( 
"simplifyAlgorithm" ), QString::number( mSimplifyMethod.
simplifyAlgorithm() ) );
  2807       mapLayerNode.setAttribute( QStringLiteral( 
"simplifyDrawingTol" ), QString::number( mSimplifyMethod.
threshold() ) );
  2808       mapLayerNode.setAttribute( QStringLiteral( 
"simplifyLocal" ), mSimplifyMethod.
forceLocalOptimization() ? 1 : 0 );
  2809       mapLayerNode.setAttribute( QStringLiteral( 
"simplifyMaxScale" ), QString::number( mSimplifyMethod.
maximumScale() ) );
  2821       QDomElement blendModeElem  = doc.createElement( QStringLiteral( 
"blendMode" ) );
  2823       blendModeElem.appendChild( blendModeText );
  2824       node.appendChild( blendModeElem );
  2827       QDomElement featureBlendModeElem  = doc.createElement( QStringLiteral( 
"featureBlendMode" ) );
  2829       featureBlendModeElem.appendChild( featureBlendModeText );
  2830       node.appendChild( featureBlendModeElem );
  2836       QDomElement layerOpacityElem  = doc.createElement( QStringLiteral( 
"layerOpacity" ) );
  2837       QDomText layerOpacityText = doc.createTextNode( QString::number( 
opacity() ) );
  2838       layerOpacityElem.appendChild( layerOpacityText );
  2839       node.appendChild( layerOpacityElem );
  2840       mapLayerNode.setAttribute( QStringLiteral( 
"hasScaleBasedVisibilityFlag" ), 
hasScaleBasedVisibility() ? 1 : 0 );
  2841       mapLayerNode.setAttribute( QStringLiteral( 
"maxScale" ), 
maximumScale() );
  2842       mapLayerNode.setAttribute( QStringLiteral( 
"minScale" ), 
minimumScale() );
  2845     if ( categories.testFlag( 
Diagrams ) && mDiagramRenderer )
  2847       mDiagramRenderer->
writeXml( mapLayerNode, doc, context );
  2848       if ( mDiagramLayerSettings )
  2849         mDiagramLayerSettings->
writeXml( mapLayerNode, doc );
  2858   QDomElement nameElem = node.firstChildElement( QStringLiteral( 
"Name" ) );
  2859   if ( nameElem.isNull() )
  2861     errorMessage = QStringLiteral( 
"Warning: Name element not found within NamedLayer while it's required." );
  2873     readSldLabeling( node );
  2880   Q_UNUSED( errorMessage )
  2891     QDomElement nameNode = doc.createElement( QStringLiteral( 
"se:Name" ) );
  2892     nameNode.appendChild( doc.createTextNode( 
name() ) );
  2893     node.appendChild( nameNode );
  2895     QDomElement userStyleElem = doc.createElement( QStringLiteral( 
"UserStyle" ) );
  2896     node.appendChild( userStyleElem );
  2898     QDomElement nameElem = doc.createElement( QStringLiteral( 
"se:Name" ) );
  2899     nameElem.appendChild( doc.createTextNode( 
name() ) );
  2901     userStyleElem.appendChild( nameElem );
  2903     QDomElement featureTypeStyleElem = doc.createElement( QStringLiteral( 
"se:FeatureTypeStyle" ) );
  2904     userStyleElem.appendChild( featureTypeStyleElem );
  2906     mRenderer->
toSld( doc, featureTypeStyleElem, localProps );
  2909       mLabeling->
toSld( featureTypeStyleElem, localProps );
  2918   if ( !mEditBuffer || !mDataProvider )
  2923   if ( mGeometryOptions->isActive() )
  2924     mGeometryOptions->apply( geom );
  2933     if ( !skipDefaultValue && !mDefaultValueOnUpdateFields.isEmpty() )
  2934       updateDefaultValues( fid );
  2942   bool result = 
false;
  2944   switch ( 
fields().fieldOrigin( field ) )
  2956       if ( mEditBuffer && mDataProvider )
  2965   if ( result && !skipDefaultValues && !mDefaultValueOnUpdateFields.isEmpty() )
  2966     updateDefaultValues( fid );
  2981   for ( 
auto it = newValues.constBegin(); it != newValues.constEnd(); ++it )
  2983     const int field = it.key();
  2984     const QVariant newValue = it.value();
  2987     if ( oldValues.contains( field ) )
  2988       oldValue = oldValues[field];
  2993         newValuesJoin[field] = newValue;
  2994         oldValuesJoin[field] = oldValue;
  3001         newValuesNotJoin[field] = newValue;
  3002         oldValuesNotJoin[field] = oldValue;
  3011   if ( ! newValuesJoin.isEmpty() && mJoinBuffer )
  3016   if ( ! newValuesNotJoin.isEmpty() && mEditBuffer && mDataProvider )
  3021   if ( result && !skipDefaultValues && !mDefaultValueOnUpdateFields.isEmpty() )
  3023     updateDefaultValues( fid );
  3031   if ( !mEditBuffer || !mDataProvider )
  3039   if ( attIndex < 0 || attIndex >= 
fields().count() )
  3043   mFields[ attIndex ].setAlias( QString() );
  3044   if ( mAttributeAliasMap.contains( name ) )
  3046     mAttributeAliasMap.remove( name );
  3048     mEditFormConfig.setFields( mFields );
  3055   if ( index < 0 || index >= 
fields().count() )
  3062       if ( mExpressionFieldBuffer )
  3078       if ( !mEditBuffer || !mDataProvider )
  3094   if ( attIndex < 0 || attIndex >= 
fields().count() )
  3099   mAttributeAliasMap.insert( name, aliasString );
  3100   mFields[ attIndex ].setAlias( aliasString );
  3101   mEditFormConfig.setFields( mFields );
  3107   if ( index < 0 || index >= 
fields().count() )
  3115   if ( index >= 0 && index < mFields.
count() )
  3123   return mAttributeAliasMap;
  3128   if ( index < 0 || index >= 
fields().count() )
  3137   if ( !mEditBuffer || !mDataProvider )
  3145   bool deleted = 
false;
  3148   QList<int> attrList = attrs.toSet().toList();
  3150   std::sort( attrList.begin(), attrList.end(), std::greater<int>() );
  3152   for ( 
int attr : qgis::as_const( attrList ) )
  3174     mSelectedFeatureIds.remove( fid ); 
  3185     QgsDebugMsgLevel( QStringLiteral( 
"Cannot delete features (mEditBuffer==NULL)" ), 1 );
  3196     mSelectedFeatureIds.subtract( fids ); 
  3211   if ( !mDataProvider )
  3212     return pkAttributesList;
  3215   for ( 
int i = 0; i < mFields.
count(); ++i )
  3219       pkAttributesList << i;
  3222   return pkAttributesList;
  3227   if ( ! mDataProvider )
  3238   if ( mEditBuffer && !deletedFeatures.empty() )
  3240     if ( addedFeatures.size() > deletedFeatures.size() )
  3241       return QgsFeatureSource::FeatureAvailability::FeaturesAvailable;
  3243       return QgsFeatureSource::FeatureAvailability::FeaturesMaybeAvailable;
  3246   if ( ( !mEditBuffer || addedFeatures.empty() ) && mDataProvider && mDataProvider->
empty() )
  3247     return QgsFeatureSource::FeatureAvailability::NoFeaturesAvailable;
  3249     return QgsFeatureSource::FeatureAvailability::FeaturesAvailable;
  3254   mCommitErrors.clear();
  3256   if ( !mDataProvider )
  3258     mCommitErrors << tr( 
"ERROR: no provider" );
  3264     mCommitErrors << tr( 
"ERROR: layer not editable" );
  3270   if ( !mAllowCommit )
  3278     mEditBuffer = 
nullptr;
  3299   return mCommitErrors;
  3309   if ( !mDataProvider )
  3311     mCommitErrors << tr( 
"ERROR: no provider" );
  3337     mEditBuffer = 
nullptr;
  3342   if ( rollbackExtent )
  3353   return mSelectedFeatureIds.size();
  3358   return mSelectedFeatureIds;
  3364   features.reserve( mSelectedFeatureIds.count() );
  3367   if ( mSelectedFeatureIds.count() <= 8 )
  3371     const auto constMSelectedFeatureIds = mSelectedFeatureIds;
  3384       features.push_back( f );
  3393   if ( mSelectedFeatureIds.isEmpty() )
  3399   if ( mSelectedFeatureIds.count() == 1 )
  3400     request.
setFilterFid( *mSelectedFeatureIds.constBegin() );
  3409   if ( !mEditBuffer || !mDataProvider )
  3412   if ( mGeometryOptions->isActive() )
  3414     for ( 
auto feature = features.begin(); feature != features.end(); ++feature )
  3417       mGeometryOptions->apply( geom );
  3450   if ( mDisplayExpression == displayExpression )
  3459   if ( !mDisplayExpression.isEmpty() || mFields.
isEmpty() )
  3461     return mDisplayExpression;
  3474     static QStringList sCandidates{ QStringLiteral( 
"name" ),
  3475                                     QStringLiteral( 
"title" ),
  3476                                     QStringLiteral( 
"heibt" ),
  3477                                     QStringLiteral( 
"desc" ),
  3478                                     QStringLiteral( 
"nom" ),
  3479                                     QStringLiteral( 
"street" ),
  3480                                     QStringLiteral( 
"road" ),
  3481                                     QStringLiteral( 
"id" )};
  3482     for ( 
const QString &candidate : sCandidates )
  3484       for ( 
const QgsField &field : mFields )
  3486         QString fldName = field.name();
  3487         if ( fldName.indexOf( candidate, 0, Qt::CaseInsensitive ) > -1 )
  3494       if ( !idxName.isEmpty() )
  3498     if ( !idxName.isNull() )
  3511   return ( mEditBuffer && mDataProvider );
  3520 bool QgsVectorLayer::isReadOnly()
 const  3528   if ( readonly && mEditBuffer )
  3531   mReadOnly = readonly;
  3539   return mEditBuffer && mEditBuffer->
isModified();
  3544   bool auxiliaryField = 
false;
  3548     return auxiliaryField;
  3555       auxiliaryField = 
true;
  3558   return auxiliaryField;
  3569   if ( r != mRenderer )
  3573     mSymbolFeatureCounted = 
false;
  3574     mSymbolFeatureCountMap.clear();
  3575     mSymbolFeatureIdMap.clear();
  3584   if ( !mDataProvider )
  3590     QString ignoredError;
  3594   mEditCommandActive = 
true;
  3600   if ( !mDataProvider )
  3605   mEditCommandActive = 
false;
  3606   if ( !mDeletedFids.isEmpty() )
  3609     mDeletedFids.clear();
  3616   if ( !mDataProvider )
  3627   std::unique_ptr< QUndoCommand > command = qgis::make_unique< QUndoCommand >();
  3628   command->setObsolete( 
true );
  3631   mEditCommandActive = 
false;
  3632   mDeletedFids.clear();
  3638   return mJoinBuffer->
addJoin( joinInfo );
  3644   return mJoinBuffer->
removeJoin( joinLayerId );
  3674   if ( oi < 0 || oi >= mExpressionFieldBuffer->
expressions().size() )
  3677   return mExpressionFieldBuffer->
expressions().at( oi ).cachedExpression.expression();
  3688   if ( !mDataProvider )
  3693   mFields = mDataProvider->
fields();
  3703   if ( mExpressionFieldBuffer )
  3707   QMap< QString, QString >::const_iterator aliasIt = mAttributeAliasMap.constBegin();
  3708   for ( ; aliasIt != mAttributeAliasMap.constEnd(); ++aliasIt )
  3714     mFields[ index ].setAlias( aliasIt.value() );
  3718   mDefaultValueOnUpdateFields.clear();
  3719   QMap< QString, QgsDefaultValue >::const_iterator defaultIt = mDefaultExpressionMap.constBegin();
  3720   for ( ; defaultIt != mDefaultExpressionMap.constEnd(); ++defaultIt )
  3722     int index = mFields.
lookupField( defaultIt.key() );
  3726     mFields[ index ].setDefaultValueDefinition( defaultIt.value() );
  3727     if ( defaultIt.value().applyOnUpdate() )
  3728       mDefaultValueOnUpdateFields.insert( index );
  3731   QMap< QString, QgsFieldConstraints::Constraints >::const_iterator constraintIt = mFieldConstraints.constBegin();
  3732   for ( ; constraintIt != mFieldConstraints.constEnd(); ++constraintIt )
  3734     int index = mFields.
lookupField( constraintIt.key() );
  3747     mFields[ index ].setConstraints( constraints );
  3750   QMap< QString, QPair< QString, QString > >::const_iterator constraintExpIt = mFieldConstraintExpressions.constBegin();
  3751   for ( ; constraintExpIt != mFieldConstraintExpressions.constEnd(); ++constraintExpIt )
  3753     int index = mFields.
lookupField( constraintExpIt.key() );
  3764     mFields[ index ].setConstraints( constraints );
  3768   for ( ; constraintStrengthIt != mFieldConstraintStrength.constEnd(); ++constraintStrengthIt )
  3770     int index = mFields.
lookupField( constraintStrengthIt.key().first );
  3780     constraints.
setConstraintStrength( constraintStrengthIt.key().second, constraintStrengthIt.value() );
  3781     mFields[ index ].setConstraints( constraints );
  3784   auto fieldWidgetIterator = mFieldWidgetSetups.constBegin();
  3785   for ( ; fieldWidgetIterator != mFieldWidgetSetups.constEnd(); ++ fieldWidgetIterator )
  3787     int index = mFields.
indexOf( fieldWidgetIterator.key() );
  3791     mFields[index].setEditorWidgetSetup( fieldWidgetIterator.value() );
  3794   if ( oldFields != mFields )
  3797     mEditFormConfig.setFields( mFields );
  3804   if ( index < 0 || index >= mFields.
count() || !mDataProvider )
  3808   if ( expression.isEmpty() )
  3812   std::unique_ptr< QgsExpressionContext > tempContext;
  3817     evalContext = tempContext.get();
  3850   if ( index < 0 || index >= mFields.
count() )
  3855     mDefaultExpressionMap.insert( mFields.
at( index ).
name(), definition );
  3859     mDefaultExpressionMap.remove( mFields.
at( index ).
name() );
  3866   if ( index < 0 || index >= mFields.
count() )
  3875   if ( !mDataProvider )
  3888       uniqueValues = mDataProvider->
uniqueValues( index, limit );
  3894         for ( 
const QVariant &v : constUniqueValues )
  3896           vals << v.toString();
  3900         QMapIterator< QgsFeatureId, QgsFeature > addedIt( added );
  3901         while ( addedIt.hasNext() && ( limit < 0 || uniqueValues.count() < limit ) )
  3904           QVariant v = addedIt.value().attribute( index );
  3907             QString vs = v.toString();
  3908             if ( !vals.contains( vs ) )
  3917         while ( it.hasNext() && ( limit < 0 || uniqueValues.count() < limit ) )
  3920           QVariant v = it.value().value( index );
  3923             QString vs = v.toString();
  3924             if ( !vals.contains( vs ) )
  3943         uniqueValues = mDataProvider->
uniqueValues( index, limit );
  3956                                             .setSubsetOfAttributes( attList ) );
  3959       QVariant currentValue;
  3960       QHash<QString, QVariant> val;
  3964         val.insert( currentValue.toString(), currentValue );
  3965         if ( limit >= 0 && val.size() >= limit )
  3971       return val.values().toSet();
  3975   Q_ASSERT_X( 
false, 
"QgsVectorLayer::uniqueValues()", 
"Unknown source of the field!" );
  3981   QStringList results;
  3982   if ( !mDataProvider )
  4000         QMapIterator< QgsFeatureId, QgsFeature > addedIt( added );
  4001         while ( addedIt.hasNext() && ( limit < 0 || results.count() < limit ) && ( !feedback || !feedback->
isCanceled() ) )
  4004           QVariant v = addedIt.value().attribute( index );
  4007             QString vs = v.toString();
  4008             if ( vs.contains( substring, Qt::CaseInsensitive ) && !results.contains( vs ) )
  4016         while ( it.hasNext() && ( limit < 0 || results.count() < limit ) && ( !feedback || !feedback->
isCanceled() ) )
  4019           QVariant v = it.value().value( index );
  4022             QString vs = v.toString();
  4023             if ( vs.contains( substring, Qt::CaseInsensitive ) && !results.contains( vs ) )
  4054       QString fieldName = mFields.
at( index ).
name();
  4055       request.
setFilterExpression( QStringLiteral( 
"\"%1\" ILIKE '%%2%'" ).arg( fieldName, substring ) );
  4059       QString currentValue;
  4062         currentValue = f.
attribute( index ).toString();
  4063         if ( !results.contains( currentValue ) )
  4064           results << currentValue;
  4066         if ( ( limit >= 0 && results.size() >= limit ) || ( feedback && feedback->
isCanceled() ) )
  4076   Q_ASSERT_X( 
false, 
"QgsVectorLayer::uniqueStringsMatching()", 
"Unknown source of the field!" );
  4082   return minimumOrMaximumValue( index, 
true );
  4087   return minimumOrMaximumValue( index, 
false );
  4090 QVariant QgsVectorLayer::minimumOrMaximumValue( 
int index, 
bool minimum )
 const  4092   if ( !mDataProvider )
  4110         QMapIterator< QgsFeatureId, QgsFeature > addedIt( added );
  4111         while ( addedIt.hasNext() )
  4114           QVariant v = addedIt.value().attribute( index );
  4123         while ( it.hasNext() )
  4126           QVariant v = it.value().value( index );
  4159                                             .setSubsetOfAttributes( attList ) );
  4162       double value = minimum ? std::numeric_limits<double>::max() : -std::numeric_limits<double>::max();
  4163       double currentValue = 0;
  4166         currentValue = f.
attribute( index ).toDouble();
  4167         if ( ( minimum && currentValue < value ) || ( !minimum && currentValue > value ) )
  4169           value = currentValue;
  4172       return QVariant( value );
  4176   Q_ASSERT_X( 
false, 
"QgsVectorLayer::minOrMax()", 
"Unknown source of the field!" );
  4187   if ( !mDataProvider )
  4193   int attrIndex = mFields.
lookupField( fieldOrExpression );
  4194   if ( attrIndex >= 0 )
  4201       bool providerOk = 
false;
  4202       QVariant val = mDataProvider->
aggregate( aggregate, attrIndex, parameters, context, providerOk, fids );
  4218   return c.
calculate( aggregate, fieldOrExpression, context, ok );
  4223   if ( mFeatureBlendMode == featureBlendMode )
  4233   return mFeatureBlendMode;
  4247   return mLayerOpacity;
  4252 void QgsVectorLayer::readSldLabeling( 
const QDomNode &node )
  4257   QDomElement element = node.toElement();
  4258   if ( element.isNull() )
  4261   QDomElement userStyleElem = element.firstChildElement( QStringLiteral( 
"UserStyle" ) );
  4262   if ( userStyleElem.isNull() )
  4264     QgsDebugMsgLevel( QStringLiteral( 
"Info: UserStyle element not found." ), 4 );
  4268   QDomElement featTypeStyleElem = userStyleElem.firstChildElement( QStringLiteral( 
"FeatureTypeStyle" ) );
  4269   if ( featTypeStyleElem.isNull() )
  4271     QgsDebugMsgLevel( QStringLiteral( 
"Info: FeatureTypeStyle element not found." ), 4 );
  4276   QDomElement mergedFeatTypeStyle = featTypeStyleElem.cloneNode( 
false ).toElement();
  4281   bool needRuleBasedLabeling = 
false;
  4284   while ( !featTypeStyleElem.isNull() )
  4286     QDomElement ruleElem = featTypeStyleElem.firstChildElement( QStringLiteral( 
"Rule" ) );
  4287     while ( !ruleElem.isNull() )
  4291       bool hasTextSymbolizer = 
false;
  4292       bool hasRuleBased = 
false;
  4293       QDomElement ruleChildElem = ruleElem.firstChildElement();
  4294       while ( !ruleChildElem.isNull() )
  4297         if ( ruleChildElem.localName() == QLatin1String( 
"Filter" ) ||
  4298              ruleChildElem.localName() == QLatin1String( 
"MinScaleDenominator" ) ||
  4299              ruleChildElem.localName() == QLatin1String( 
"MaxScaleDenominator" ) )
  4301           hasRuleBased = 
true;
  4304         else if ( ruleChildElem.localName() == QLatin1String( 
"TextSymbolizer" ) )
  4306           QgsDebugMsgLevel( QStringLiteral( 
"Info: TextSymbolizer element found" ), 4 );
  4307           hasTextSymbolizer = 
true;
  4310         ruleChildElem = ruleChildElem.nextSiblingElement();
  4313       if ( hasTextSymbolizer )
  4318         mergedFeatTypeStyle.appendChild( ruleElem.cloneNode().toElement() );
  4322           QgsDebugMsgLevel( QStringLiteral( 
"Info: Filter or Min/MaxScaleDenominator element found: need a RuleBasedLabeling" ), 4 );
  4323           needRuleBasedLabeling = 
true;
  4328       if ( ruleCount > 1 )
  4330         QgsDebugMsgLevel( QStringLiteral( 
"Info: More Rule elements found: need a RuleBasedLabeling" ), 4 );
  4331         needRuleBasedLabeling = 
true;
  4335       if ( ruleCount == 0 )
  4337         needRuleBasedLabeling = 
false;
  4340       ruleElem = ruleElem.nextSiblingElement( QStringLiteral( 
"Rule" ) );
  4342     featTypeStyleElem = featTypeStyleElem.nextSiblingElement( QStringLiteral( 
"FeatureTypeStyle" ) );
  4345   if ( ruleCount == 0 )
  4347     QgsDebugMsgLevel( QStringLiteral( 
"Info: No TextSymbolizer element." ), 4 );
  4351   QDomElement ruleElem = mergedFeatTypeStyle.firstChildElement( QStringLiteral( 
"Rule" ) );
  4353   if ( needRuleBasedLabeling )
  4357     while ( !ruleElem.isNull() )
  4360       QString label, description, filterExp;
  4361       int scaleMinDenom = 0, scaleMaxDenom = 0;
  4365       QDomElement childElem = ruleElem.firstChildElement();
  4366       while ( !childElem.isNull() )
  4368         if ( childElem.localName() == QLatin1String( 
"Name" ) )
  4372           if ( label.isEmpty() )
  4373             label = childElem.firstChild().nodeValue();
  4375         else if ( childElem.localName() == QLatin1String( 
"Description" ) )
  4378           QDomElement titleElem = childElem.firstChildElement( QStringLiteral( 
"Title" ) );
  4379           if ( !titleElem.isNull() )
  4381             label = titleElem.firstChild().nodeValue();
  4384           QDomElement abstractElem = childElem.firstChildElement( QStringLiteral( 
"Abstract" ) );
  4385           if ( !abstractElem.isNull() )
  4387             description = abstractElem.firstChild().nodeValue();
  4390         else if ( childElem.localName() == QLatin1String( 
"Abstract" ) )
  4393           description = childElem.firstChild().nodeValue();
  4395         else if ( childElem.localName() == QLatin1String( 
"Title" ) )
  4398           label = childElem.firstChild().nodeValue();
  4400         else if ( childElem.localName() == QLatin1String( 
"Filter" ) )
  4416         else if ( childElem.localName() == QLatin1String( 
"MinScaleDenominator" ) )
  4419           int v = childElem.firstChild().nodeValue().toInt( &ok );
  4423         else if ( childElem.localName() == QLatin1String( 
"MaxScaleDenominator" ) )
  4426           int v = childElem.firstChild().nodeValue().toInt( &ok );
  4430         else if ( childElem.localName() == QLatin1String( 
"TextSymbolizer" ) )
  4432           readSldTextSymbolizer( childElem, settings );
  4435         childElem = childElem.nextSiblingElement();
  4441       ruleElem = ruleElem.nextSiblingElement();
  4451     QDomElement textSymbolizerElem = ruleElem.firstChildElement( QStringLiteral( 
"TextSymbolizer" ) );
  4453     if ( readSldTextSymbolizer( textSymbolizerElem, s ) )
  4461 bool QgsVectorLayer::readSldTextSymbolizer( 
const QDomNode &node, 
QgsPalLayerSettings &settings )
 const  4463   if ( node.localName() != QLatin1String( 
"TextSymbolizer" ) )
  4465     QgsDebugMsgLevel( QStringLiteral( 
"Not a TextSymbolizer element: %1" ).arg( node.localName() ), 3 );
  4468   QDomElement textSymbolizerElem = node.toElement();
  4470   QDomElement labelElem = textSymbolizerElem.firstChildElement( QStringLiteral( 
"Label" ) );
  4471   if ( !labelElem.isNull() )
  4473     QDomElement propertyNameElem = labelElem.firstChildElement( QStringLiteral( 
"PropertyName" ) );
  4474     if ( !propertyNameElem.isNull() )
  4479       QString labelAttribute = propertyNameElem.text();
  4483       int fieldIndex = mFields.
lookupField( labelAttribute );
  4484       if ( fieldIndex == -1 )
  4500       QgsDebugMsgLevel( QStringLiteral( 
"Info: PropertyName element not found." ), 4 );
  4511   if ( textSymbolizerElem.hasAttribute( QStringLiteral( 
"uom" ) ) )
  4516   QString fontFamily = QStringLiteral( 
"Sans-Serif" );
  4517   int fontPointSize = 10;
  4519   int fontWeight = -1;
  4520   bool fontItalic = 
false;
  4521   bool fontUnderline = 
false;
  4524   QDomElement fontElem = textSymbolizerElem.firstChildElement( QStringLiteral( 
"Font" ) );
  4525   if ( !fontElem.isNull() )
  4528     for ( QgsStringMap::iterator it = fontSvgParams.begin(); it != fontSvgParams.end(); ++it )
  4530       QgsDebugMsgLevel( QStringLiteral( 
"found fontSvgParams %1: %2" ).arg( it.key(), it.value() ), 4 );
  4532       if ( it.key() == QLatin1String( 
"font-family" ) )
  4534         fontFamily = it.value();
  4536       else if ( it.key() == QLatin1String( 
"font-style" ) )
  4538         fontItalic = ( it.value() == QLatin1String( 
"italic" ) ) || ( it.value() == QLatin1String( 
"Italic" ) );
  4540       else if ( it.key() == QLatin1String( 
"font-size" ) )
  4543         int fontSize = it.value().toInt( &ok );
  4546           fontPointSize = fontSize;
  4547           fontUnitSize = sldUnitSize;
  4550       else if ( it.key() == QLatin1String( 
"font-weight" ) )
  4552         if ( ( it.value() == QLatin1String( 
"bold" ) ) || ( it.value() == QLatin1String( 
"Bold" ) ) )
  4553           fontWeight = QFont::Bold;
  4555       else if ( it.key() == QLatin1String( 
"font-underline" ) )
  4557         fontUnderline = ( it.value() == QLatin1String( 
"underline" ) ) || ( it.value() == QLatin1String( 
"Underline" ) );
  4563   QFont font( fontFamily, fontPointSize, fontWeight, fontItalic );
  4564   font.setUnderline( fontUnderline );
  4566   format.
setSize( fontPointSize );
  4570   QDomElement fillElem = textSymbolizerElem.firstChildElement( QStringLiteral( 
"Fill" ) );
  4572   Qt::BrushStyle textBrush = Qt::SolidPattern;
  4574   if ( textColor.isValid() )
  4576     QgsDebugMsgLevel( QStringLiteral( 
"Info: textColor %1." ).arg( QVariant( textColor ).toString() ), 4 );
  4583   QDomElement haloElem = textSymbolizerElem.firstChildElement( QStringLiteral( 
"Halo" ) );
  4584   if ( !haloElem.isNull() )
  4589     QDomElement radiusElem = haloElem.firstChildElement( QStringLiteral( 
"Radius" ) );
  4590     if ( !radiusElem.isNull() )
  4593       double bufferSize = radiusElem.text().toDouble( &ok );
  4596         bufferSettings.
setSize( bufferSize );
  4601     QDomElement haloFillElem = haloElem.firstChildElement( QStringLiteral( 
"Fill" ) );
  4603     Qt::BrushStyle bufferBrush = Qt::SolidPattern;
  4605     if ( bufferColor.isValid() )
  4607       QgsDebugMsgLevel( QStringLiteral( 
"Info: bufferColor %1." ).arg( QVariant( bufferColor ).toString() ), 4 );
  4608       bufferSettings.
setColor( bufferColor );
  4613   QDomElement labelPlacementElem = textSymbolizerElem.firstChildElement( QStringLiteral( 
"LabelPlacement" ) );
  4614   if ( !labelPlacementElem.isNull() )
  4617     QDomElement pointPlacementElem = labelPlacementElem.firstChildElement( QStringLiteral( 
"PointPlacement" ) );
  4618     if ( !pointPlacementElem.isNull() )
  4626       QDomElement displacementElem = pointPlacementElem.firstChildElement( QStringLiteral( 
"Displacement" ) );
  4627       if ( !displacementElem.isNull() )
  4629         QDomElement displacementXElem = displacementElem.firstChildElement( QStringLiteral( 
"DisplacementX" ) );
  4630         if ( !displacementXElem.isNull() )
  4633           double xOffset = displacementXElem.text().toDouble( &ok );
  4640         QDomElement displacementYElem = displacementElem.firstChildElement( QStringLiteral( 
"DisplacementY" ) );
  4641         if ( !displacementYElem.isNull() )
  4644           double yOffset = displacementYElem.text().toDouble( &ok );
  4652       QDomElement anchorPointElem = pointPlacementElem.firstChildElement( QStringLiteral( 
"AnchorPoint" ) );
  4653       if ( !anchorPointElem.isNull() )
  4655         QDomElement anchorPointXElem = anchorPointElem.firstChildElement( QStringLiteral( 
"AnchorPointX" ) );
  4656         if ( !anchorPointXElem.isNull() )
  4659           double xOffset = anchorPointXElem.text().toDouble( &ok );
  4666         QDomElement anchorPointYElem = anchorPointElem.firstChildElement( QStringLiteral( 
"AnchorPointY" ) );
  4667         if ( !anchorPointYElem.isNull() )
  4670           double yOffset = anchorPointYElem.text().toDouble( &ok );
  4679       QDomElement rotationElem = pointPlacementElem.firstChildElement( QStringLiteral( 
"Rotation" ) );
  4680       if ( !rotationElem.isNull() )
  4683         double rotation = rotationElem.text().toDouble( &ok );
  4693       QDomElement linePlacementElem = labelPlacementElem.firstChildElement( QStringLiteral( 
"LinePlacement" ) );
  4694       if ( !linePlacementElem.isNull() )
  4703   QDomElement vendorOptionElem = textSymbolizerElem.firstChildElement( QStringLiteral( 
"VendorOption" ) );
  4704   while ( !vendorOptionElem.isNull() && vendorOptionElem.localName() == QLatin1String( 
"VendorOption" ) )
  4706     QString optionName = vendorOptionElem.attribute( QStringLiteral( 
"name" ) );
  4707     QString optionValue;
  4708     if ( vendorOptionElem.firstChild().nodeType() == QDomNode::TextNode )
  4710       optionValue = vendorOptionElem.firstChild().nodeValue();
  4714       if ( vendorOptionElem.firstChild().nodeType() == QDomNode::ElementNode &&
  4715            vendorOptionElem.firstChild().localName() == QLatin1String( 
"Literal" ) )
  4717         QgsDebugMsg( vendorOptionElem.firstChild().localName() );
  4718         optionValue = vendorOptionElem.firstChild().firstChild().nodeValue();
  4722         QgsDebugMsg( QStringLiteral( 
"unexpected child of %1 named %2" ).arg( vendorOptionElem.localName(), optionName ) );
  4726     if ( !optionName.isEmpty() && !optionValue.isEmpty() )
  4728       vendorOptions[ optionName ] = optionValue;
  4731     vendorOptionElem = vendorOptionElem.nextSiblingElement();
  4733   if ( !vendorOptions.isEmpty() )
  4735     for ( QgsStringMap::iterator it = vendorOptions.begin(); it != vendorOptions.end(); ++it )
  4737       if ( it.key() == QLatin1String( 
"underlineText" ) && it.value() == QLatin1String( 
"true" ) )
  4739         font.setUnderline( 
true );
  4742       else if ( it.key() == QLatin1String( 
"strikethroughText" ) && it.value() == QLatin1String( 
"true" ) )
  4744         font.setStrikeOut( 
true );
  4747       else if ( it.key() == QLatin1String( 
"maxDisplacement" ) )
  4751       else if ( it.key() == QLatin1String( 
"followLine" ) && it.value() == QLatin1String( 
"true" ) )
  4762       else if ( it.key() == QLatin1String( 
"maxAngleDelta" ) )
  4765         double angle = it.value().toDouble( &ok );
  4773       else if ( it.key() == QLatin1String( 
"conflictResolution" ) && it.value() == QLatin1String( 
"false" ) )
  4777       else if ( it.key() == QLatin1String( 
"forceLeftToRight" ) && it.value() == QLatin1String( 
"false" ) )
  4781       else if ( it.key() == QLatin1String( 
"group" ) && it.value() == QLatin1String( 
"yes" ) )
  4785       else if ( it.key() == QLatin1String( 
"labelAllGroup" ) && it.value() == QLatin1String( 
"true" ) )
  4799   return mEditFormConfig;
  4804   if ( mEditFormConfig == editFormConfig )
  4808   mEditFormConfig.onRelationsLoaded();
  4814   return mMapTipTemplate;
  4819   if ( mMapTipTemplate == mapTip )
  4822   mMapTipTemplate = mapTip;
  4838   if ( mAttributeTableConfig != attributeTableConfig )
  4857   if ( !mDiagramLayerSettings )
  4859   *mDiagramLayerSettings = s;
  4865   QString myMetadata = QStringLiteral( 
"<html>\n<body>\n" );
  4868   myMetadata += QStringLiteral( 
"<h1>" ) + tr( 
"Information from provider" ) + QStringLiteral( 
"</h1>\n<hr>\n" );
  4869   myMetadata += QLatin1String( 
"<table class=\"list-view\">\n" );
  4872   myMetadata += QStringLiteral( 
"<tr><td class=\"highlight\">" ) + tr( 
"Name" ) + QStringLiteral( 
"</td><td>" ) + 
name() + QStringLiteral( 
"</td></tr>\n" );
  4877   if ( uriComponents.contains( QStringLiteral( 
"path" ) ) )
  4879     path = uriComponents[QStringLiteral( 
"path" )].toString();
  4880     if ( QFile::exists( path ) )
  4881       myMetadata += QStringLiteral( 
"<tr><td class=\"highlight\">" ) + tr( 
"Path" ) + QStringLiteral( 
"</td><td>%1" ).arg( QStringLiteral( 
"<a href=\"%1\">%2</a>" ).arg( QUrl::fromLocalFile( path ).toString(), QDir::toNativeSeparators( path ) ) ) + QStringLiteral( 
"</td></tr>\n" );
  4883   if ( uriComponents.contains( QStringLiteral( 
"url" ) ) )
  4885     const QString url = uriComponents[QStringLiteral( 
"url" )].toString();
  4886     myMetadata += QStringLiteral( 
"<tr><td class=\"highlight\">" ) + tr( 
"URL" ) + QStringLiteral( 
"</td><td>%1" ).arg( QStringLiteral( 
"<a href=\"%1\">%2</a>" ).arg( QUrl( url ).toString(), url ) ) + QStringLiteral( 
"</td></tr>\n" );
  4891     myMetadata += QStringLiteral( 
"<tr><td class=\"highlight\">" ) + tr( 
"Source" ) + QStringLiteral( 
"</td><td>%1" ).arg( 
publicSource() ) + QStringLiteral( 
"</td></tr>\n" );
  4894   myMetadata += QStringLiteral( 
"<tr><td class=\"highlight\">" ) + tr( 
"Storage" ) + QStringLiteral( 
"</td><td>" ) + 
storageType() + QStringLiteral( 
"</td></tr>\n" );
  4897   myMetadata += QStringLiteral( 
"<tr><td class=\"highlight\">" ) + tr( 
"Comment" ) + QStringLiteral( 
"</td><td>" ) + 
dataComment() + QStringLiteral( 
"</td></tr>\n" );
  4903     myMetadata += QStringLiteral( 
"<tr><td class=\"highlight\">" ) + tr( 
"Encoding" ) + QStringLiteral( 
"</td><td>" ) + provider->
encoding() + QStringLiteral( 
"</td></tr>\n" );
  4918       myMetadata += QStringLiteral( 
"<tr><td class=\"highlight\">" ) + tr( 
"Geometry" ) + QStringLiteral( 
"</td><td>" ) + typeString + QStringLiteral( 
"</td></tr>\n" );
  4922     myMetadata += QStringLiteral( 
"<tr><td class=\"highlight\">" ) + tr( 
"CRS" ) + QStringLiteral( 
"</td><td>" );
  4926       if ( 
crs().isGeographic() )
  4927         myMetadata += tr( 
"Geographic" );
  4929         myMetadata += tr( 
"Projected" );
  4931     myMetadata += QLatin1String( 
"</td></tr>\n" );
  4934     myMetadata += QStringLiteral( 
"<tr><td class=\"highlight\">" ) + tr( 
"Extent" ) + QStringLiteral( 
"</td><td>" ) + 
extent().
toString() + QStringLiteral( 
"</td></tr>\n" );
  4937     myMetadata += QStringLiteral( 
"<tr><td class=\"highlight\">" ) + tr( 
"Unit" ) + QStringLiteral( 
"</td><td>" ) + 
QgsUnitTypes::toString( 
crs().mapUnits() ) + QStringLiteral( 
"</td></tr>\n" );
  4942   QLocale locale = QLocale();
  4943   locale.setNumberOptions( locale.numberOptions() &= ~QLocale::NumberOption::OmitGroupSeparator );
  4944   myMetadata += QStringLiteral( 
"<tr><td class=\"highlight\">" )
  4945                 + tr( 
"Feature count" ) + QStringLiteral( 
"</td><td>" )
  4947                 + QStringLiteral( 
"</td></tr>\n" );
  4950   myMetadata += QLatin1String( 
"</table>\n<br><br>" );
  4953   myMetadata += QStringLiteral( 
"<h1>" ) + tr( 
"Identification" ) + QStringLiteral( 
"</h1>\n<hr>\n" );
  4955   myMetadata += QLatin1String( 
"<br><br>\n" );
  4958   myMetadata += QStringLiteral( 
"<h1>" ) + tr( 
"Extent" ) + QStringLiteral( 
"</h1>\n<hr>\n" );
  4960   myMetadata += QLatin1String( 
"<br><br>\n" );
  4963   myMetadata += QStringLiteral( 
"<h1>" ) + tr( 
"Access" ) + QStringLiteral( 
"</h1>\n<hr>\n" );
  4965   myMetadata += QLatin1String( 
"<br><br>\n" );
  4968   myMetadata += QStringLiteral( 
"<h1>" ) + tr( 
"Fields" ) + QStringLiteral( 
"</h1>\n<hr>\n<table class=\"list-view\">\n" );
  4972   if ( !pkAttrList.isEmpty() )
  4974     myMetadata += QStringLiteral( 
"<tr><td class=\"highlight\">" ) + tr( 
"Primary key attributes" ) + QStringLiteral( 
"</td><td>" );
  4975     const auto constPkAttrList = pkAttrList;
  4976     for ( 
int idx : constPkAttrList )
  4980     myMetadata += QLatin1String( 
"</td></tr>\n" );
  4986   myMetadata += QStringLiteral( 
"<tr><td class=\"highlight\">" ) + tr( 
"Count" ) + QStringLiteral( 
"</td><td>" ) + QString::number( myFields.
size() ) + QStringLiteral( 
"</td></tr>\n" );
  4988   myMetadata += QLatin1String( 
"</table>\n<br><table width=\"100%\" class=\"tabular-view\">\n" );
  4989   myMetadata += QLatin1String( 
"<tr><th>" ) + tr( 
"Field" ) + QLatin1String( 
"</th><th>" ) + tr( 
"Type" ) + QLatin1String( 
"</th><th>" ) + tr( 
"Length" ) + QLatin1String( 
"</th><th>" ) + tr( 
"Precision" ) + QLatin1String( 
"</th><th>" ) + tr( 
"Comment" ) + QLatin1String( 
"</th></tr>\n" );
  4991   for ( 
int i = 0; i < myFields.
size(); ++i )
  4996       rowClass = QStringLiteral( 
"class=\"odd-row\"" );
  4997     myMetadata += QLatin1String( 
"<tr " ) + rowClass + QLatin1String( 
"><td>" ) + myField.
name() + QLatin1String( 
"</td><td>" ) + myField.
typeName() + QLatin1String( 
"</td><td>" ) + QString::number( myField.
length() ) + QLatin1String( 
"</td><td>" ) + QString::number( myField.
precision() ) + QLatin1String( 
"</td><td>" ) + myField.
comment() + QLatin1String( 
"</td></tr>\n" );
  5001   myMetadata += QLatin1String( 
"</table>\n<br><br>" );
  5004   myMetadata += QStringLiteral( 
"<h1>" ) + tr( 
"Contacts" ) + QStringLiteral( 
"</h1>\n<hr>\n" );
  5006   myMetadata += QLatin1String( 
"<br><br>\n" );
  5009   myMetadata += QStringLiteral( 
"<h1>" ) + tr( 
"Links" ) + QStringLiteral( 
"</h1>\n<hr>\n" );
  5011   myMetadata += QLatin1String( 
"<br><br>\n" );
  5014   myMetadata += QStringLiteral( 
"<h1>" ) + tr( 
"History" ) + QStringLiteral( 
"</h1>\n<hr>\n" );
  5016   myMetadata += QLatin1String( 
"<br><br>\n" );
  5018   myMetadata += QStringLiteral( 
"\n</body>\n</html>\n" );
  5022 void QgsVectorLayer::invalidateSymbolCountedFlag()
  5024   mSymbolFeatureCounted = 
false;
  5027 void QgsVectorLayer::onFeatureCounterCompleted()
  5030   mFeatureCounter = 
nullptr;
  5033 void QgsVectorLayer::onFeatureCounterTerminated()
  5035   mFeatureCounter = 
nullptr;
  5038 void QgsVectorLayer::onJoinedFieldsChanged()
  5044 void QgsVectorLayer::onFeatureDeleted( 
QgsFeatureId fid )
  5046   if ( mEditCommandActive )
  5047     mDeletedFids << fid;
  5054 void QgsVectorLayer::onRelationsLoaded()
  5056   mEditFormConfig.onRelationsLoaded();
  5059 void QgsVectorLayer::onSymbolsCounted()
  5061   if ( mFeatureCounter )
  5063     mSymbolFeatureCounted = 
true;
  5077   return mWeakRelations;
  5097     bool useAsDefault, 
const QString &uiFileContent, QString &msgError )
  5100   QString sldStyle, qmlStyle;
  5101   QDomDocument qmlDocument, sldDocument;
  5104   if ( !msgError.isNull() )
  5108   qmlStyle = qmlDocument.toString();
  5111   if ( !msgError.isNull() )
  5115   sldStyle = sldDocument.toString();
  5119       description, uiFileContent, useAsDefault, msgError );
  5133   QString joinKey = mAuxiliaryLayerKey;
  5134   if ( !key.isEmpty() )
  5137   if ( storage.
isValid() && !joinKey.isEmpty() )
  5160   mAuxiliaryLayerKey.clear();
  5162   if ( mAuxiliaryLayer )
  5175   mAuxiliaryLayer.reset( alayer );
  5176   if ( mAuxiliaryLayer )
  5177     mAuxiliaryLayer->setParent( 
this );
  5183   return mAuxiliaryLayer.get();
  5188   return mAuxiliaryLayer.get();
  5194   QString returnMessage;
  5195   QString qml, errorMsg;
  5200   if ( !qml.isEmpty() )
  5202     QDomDocument myDocument( QStringLiteral( 
"qgis" ) );
  5203     myDocument.setContent( qml );
  5205     returnMessage = QObject::tr( 
"Loaded from Provider" );
  5215   return returnMessage;
  5220   if ( mDataProvider )
  5225 void QgsVectorLayer::emitDataChanged()
  5227   if ( mDataChangedFired )
  5232   mDataChangedFired = 
true;
  5234   mDataChangedFired = 
false;
  5239   QSet<QgsMapLayerDependency> deps;
  5240   const auto constODeps = oDeps;
  5247   QSet<QgsMapLayerDependency> toAdd = deps - 
dependencies();
  5263   if ( mDataProvider )
  5283   if ( ! toAdd.isEmpty() )
  5291   if ( fieldIndex < 0 || fieldIndex >= mFields.
count() || !mDataProvider )
  5307   QMap< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrength > m;
  5309   if ( fieldIndex < 0 || fieldIndex >= mFields.
count() )
  5312   QString 
name = mFields.
at( fieldIndex ).
name();
  5315   for ( ; conIt != mFieldConstraintStrength.constEnd(); ++conIt )
  5317     if ( conIt.key().first == 
name )
  5319       m[ conIt.key().second ] = mFieldConstraintStrength.value( conIt.key() );
  5328   if ( index < 0 || index >= mFields.
count() )
  5334   QgsFieldConstraints::Constraints constraints = mFieldConstraints.value( name, 
nullptr );
  5335   constraints |= constraint;
  5336   mFieldConstraints.insert( name, constraints );
  5338   mFieldConstraintStrength.insert( qMakePair( name, constraint ), strength );
  5345   if ( index < 0 || index >= mFields.
count() )
  5351   QgsFieldConstraints::Constraints constraints = mFieldConstraints.value( name, 
nullptr );
  5352   constraints &= ~constraint;
  5353   mFieldConstraints.insert( name, constraints );
  5355   mFieldConstraintStrength.remove( qMakePair( name, constraint ) );
  5362   if ( index < 0 || index >= mFields.
count() )
  5370   if ( index < 0 || index >= mFields.
count() )
  5378   if ( index < 0 || index >= mFields.
count() )
  5381   if ( expression.isEmpty() )
  5383     mFieldConstraintExpressions.remove( mFields.
at( index ).
name() );
  5387     mFieldConstraintExpressions.insert( mFields.
at( index ).
name(), qMakePair( expression, description ) );
  5394   if ( index < 0 || index >= mFields.
count() )
  5398     mFieldWidgetSetups.remove( mFields.
at( index ).
name() );
  5400     mFieldWidgetSetups.insert( mFields.
at( index ).
name(), setup );
  5407   if ( index < 0 || index >= mFields.
count() )
  5416   if ( 
customProperty( QStringLiteral( 
"labeling" ) ).toString() == QLatin1String( 
"pal" ) )
  5418     if ( 
customProperty( QStringLiteral( 
"labeling/enabled" ), QVariant( 
false ) ).toBool() )
  5422       settings.readFromLayerCustomProperties( 
this );
  5429     for ( 
const QString &key : constCustomPropertyKeys )
  5431       if ( key.startsWith( QLatin1String( 
"labeling/" ) ) )
  5441   return mAllowCommit;
  5446   if ( mAllowCommit == allowCommit )
  5455   return mGeometryOptions.get();
  5465   return mReadExtentFromXml;
  5468 void QgsVectorLayer::onDirtyTransaction( 
const QString &sql, 
const QString &
name )
  5471   if ( tr && mEditBuffer )
 void setProperty(int key, const QgsProperty &property)
Adds a property to the collection and takes ownership of it. 
 
static void mergeScaleDependencies(double mScaleMinDenom, double mScaleMaxDenom, QgsStringMap &props)
Merges the local scale limits, if any, with the ones already in the map, if any. 
 
int lookupField(const QString &fieldName) const
Looks up field's index from the field name. 
 
bool writeXml(QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context) const FINAL
Writes vector layer specific state to project file Dom node. 
 
bool addFeatures(QgsFeatureList &features, QgsFeatureSink::Flags flags=nullptr) override
Adds a list of features in joined layers. 
 
QList< QgsExpressionFieldBuffer::ExpressionField > expressions() const
 
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn. 
 
QgsFeatureIds symbolFeatureIds(const QString &legendKey) const
Ids of features rendered with specified legend key. 
 
QgsGeometryOptions * geometryOptions() const
Configuration and logic to apply automatically on any edit happening on this layer. 
 
bool isValid() const
Returns the validity of this feature. 
 
void writeXml(QDomNode &layer_node, QDomDocument &document) const
Saves mVectorJoins to xml under the layer node. 
 
Class for parsing and evaluation of expressions (formerly called "search strings"). 
 
void updateFields()
Will regenerate the fields property of this layer by obtaining all fields from the dataProvider...
 
void opacityChanged(double opacity)
Emitted when the layer's opacity is changed, where opacity is a value between 0 (transparent) and 1 (...
 
Q_DECL_DEPRECATED QgsGeometry::OperationResult addPart(const QList< QgsPointXY > &ring)
Adds a new part polygon to a multipart feature. 
 
QgsRectangle sourceExtent() const FINAL
Returns the extent of all geometries from the source. 
 
QgsActionManager * actions()
Returns all layer actions defined on this layer. 
 
bool hasParserError() const
Returns true if an error occurred when parsing the input expression. 
 
double xOffset
Horizontal offset of label. 
 
QString encoding() const
Returns the encoding which is used for accessing data. 
 
QgsStringMap attributeAliases() const
Returns a map of field name to attribute alias. 
 
bool writeStyle(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories) const FINAL
Writes just the style information for the layer into the document. 
 
The class is used as a container of context for various read/write operations on other objects...
 
Wrapper for iterator of features from vector data provider or vector layer. 
 
void featuresDeleted(const QgsFeatureIds &fids)
Emitted when features have been deleted. 
 
Q_INVOKABLE void selectAll()
Select all the features. 
 
void setConstraintStrength(Constraint constraint, ConstraintStrength strength)
Sets the strength of a constraint. 
 
Constraint was set by layer. 
 
bool addJoin(const QgsVectorLayerJoinInfo &joinInfo)
Joins another vector layer to this layer. 
 
void taskTerminated()
Will be emitted by task if it has terminated for any reason other then completion (e...
 
bool saveStyle(const QString &providerKey, const QString &uri, const QString &qmlStyle, const QString &sldStyle, const QString &styleName, const QString &styleDescription, const QString &uiFileContent, bool useAsDefault, QString &errCause)
Saves a layer style to provider. 
 
virtual bool setSubsetString(const QString &subset, bool updateFeatureCount=true)
Set the subset string used to create a subset of features in the layer. 
 
A rectangle specified with double values. 
 
QString targetFieldName() const
Returns name of the field of our layer that will be used for join. 
 
bool readSld(const QDomNode &node, QString &errorMessage) FINAL
 
Base class for all map layer types. 
 
Q_DECL_DEPRECATED QgsGeometry::OperationResult splitParts(const QVector< QgsPointXY > &splitLine, bool topologicalEditing=false)
Splits parts cut by the given line. 
 
double rendererScale() const
Returns the renderer map scale. 
 
void geometryChanged(QgsFeatureId fid, const QgsGeometry &geom)
Emitted when a feature's geometry is changed. 
 
void renameExpression(int index, const QString &name)
Renames an expression field at a given index. 
 
virtual void writeXml(QDomElement &layerElem, QDomDocument &doc, const QgsReadWriteContext &context) const =0
Writes diagram state to a DOM element. 
 
double maxCurvedCharAngleOut
Maximum angle between outside curved label characters (valid range -20.0 to -95.0) ...
 
void setDiagramLayerSettings(const QgsDiagramLayerSettings &s)
 
bool loadDefaultStyle
Set to true if the default layer style should be loaded. 
 
QVariant maximumValue(int index) const override
Returns the maximum value of an attribute. 
 
bool containsJoins() const
Quick way to test if there is any join at all. 
 
void update(const QgsFields &fields)
Update the configuration with the given fields. 
 
virtual QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context) const
Writes configuration to a DOM element, to be used later with readXml() 
 
void setRenderer(QgsFeatureRenderer *r)
Sets renderer which will be invoked to represent this layer. 
 
Field comes from a joined layer (originIndex / 1000 = index of the join, originIndex % 1000 = index w...
 
bool readSymbology(const QDomNode &layerNode, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories) FINAL
Reads the symbology for the current layer from the Dom node supplied. 
 
QSet< QgsFeatureId > QgsFeatureIds
 
void setExcludeAttributesWms(const QSet< QString > &att)
A set of attributes that are not advertised in WMS requests with QGIS server. 
 
virtual bool renameAttribute(int attr, const QString &newName)
Renames an attribute field (but does not commit it) 
 
virtual bool addAttribute(const QgsField &field)
Add an attribute field (but does not commit it) returns true if the field was added. 
 
int size() const
Returns number of items. 
 
virtual void exportSldStyle(QDomDocument &doc, QString &errorMsg) const
Export the properties of this layer as SLD style in a QDomDocument. 
 
FieldOrigin fieldOrigin(int fieldIdx) const
Gets field's origin (value from an enumeration) 
 
void setMinimal()
Set a rectangle so that min corner is at max and max corner is at min. 
 
virtual QString subsetString() const
Returns the subset definition string (typically sql) currently in use by the layer and used by the pr...
 
void setProviderType(const QString &providerType)
Sets the providerType (provider key) 
 
void taskCompleted()
Will be emitted by task to indicate its successful completion. 
 
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique. 
 
virtual QgsVectorDataProvider::Capabilities capabilities() const
Returns flags containing the supported capabilities. 
 
void dependenciesChanged()
Emitted when dependencies are changed. 
 
QgsWkbTypes::Type wkbType() const override=0
Returns the geometry type which is returned by this layer. 
 
static QString quotedColumnRef(QString name)
Returns a quoted column reference (in double quotes) 
 
void committedAttributesDeleted(const QString &layerId, const QgsAttributeList &deletedAttributes)
Signals emitted after committing changes. 
 
bool isValid() const
Returns the status of the auxiliary storage currently defined. 
 
virtual QString subsetString() const
Returns the string (typically sql) used to define a subset of the layer. 
 
QgsMapLayerType type() const
Returns the type of the layer. 
 
static Q_INVOKABLE QString toString(QgsUnitTypes::DistanceUnit unit)
Returns a translated string representing a distance unit. 
 
static QgsStringMap getSvgParameterList(QDomElement &element)
 
void editFormConfigChanged()
Will be emitted whenever the edit form configuration of this layer changes. 
 
Q_INVOKABLE void modifySelection(const QgsFeatureIds &selectIds, const QgsFeatureIds &deselectIds)
Modifies the current selection on this layer. 
 
bool writeXml(QDomNode &layer_node) const
Writes the actions out in XML format. 
 
virtual void updateExtents()
Update the extents of the layer. 
 
The QgsGeometryOptions class contains options to automatically adjust geometries to constraints on a ...
 
void addExpression(const QString &exp, const QgsField &fld)
Add an expression to the buffer. 
 
QVariant minimumValue(int index) const override
Returns the minimum value of an attribute. 
 
void setFidsFilter(const QgsFeatureIds &fids)
Sets a filter to limit the features used during the aggregate calculation. 
 
void removeFieldConstraint(int index, QgsFieldConstraints::Constraint constraint)
Removes a constraint for a specified field index. 
 
bool isValid() const
Returns if this default value should be applied. 
 
virtual bool importNamedStyle(QDomDocument &doc, QString &errorMsg, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories)
Import the properties of this layer from a QDomDocument. 
 
bool writeXml(QDomNode &node, QDomDocument &doc, const QgsReadWriteContext &context) const
Writes the condition styles state to a DOM node. 
 
void beforeRollBack()
Emitted before changes are rolled back. 
 
virtual bool addFeatures(QgsFeatureList &features)
Insert a copy of the given features into the layer (but does not commit it) 
 
bool hasParam(const QString &key) const
Returns true if a parameter with the specified key exists. 
 
void beginEditCommand(const QString &text)
Create edit command for undo/redo operations. 
 
Use exact geometry intersection (slower) instead of bounding boxes. 
 
QSet< QString > excludeAttributesWms() const
A set of attributes that are not advertised in WMS requests with QGIS server. 
 
This class is a composition of two QSettings instances: 
 
Q_DECL_DEPRECATED QgsGeometry::OperationResult splitParts(const QVector< QgsPointXY > &splitLine, bool topologicalEditing=false)
Splits parts cut by the given line. 
 
QString encodedSource(const QString &source, const QgsReadWriteContext &context) const FINAL
Called by writeLayerXML(), used by derived classes to encode provider's specific data source to proje...
 
Q_INVOKABLE QStringList customPropertyKeys() const
Returns list of all keys within custom properties. 
 
MAYBE_UNUSED NODISCARD QgsReadWriteContextCategoryPopper enterCategory(const QString &category, const QString &details=QString())
Push a category to the stack. 
 
double angleOffset
Label rotation, in degrees clockwise. 
 
QString mapTipTemplate() const
The mapTip is a pretty, html representation for feature information. 
 
QString readPath(const QString &filename) const
Turn filename read from the project file to an absolute path. 
 
Q_INVOKABLE int translateFeature(QgsFeatureId featureId, double dx, double dy)
Translates feature by dx, dy. 
 
QgsMapLayerLegend * legend() const
Can be nullptr. 
 
QString storageType() const
Returns the permanent storage type for this layer as a friendly name. 
 
Renders the diagrams for all features with the same settings. 
 
FeatureAvailability
Possible return value for hasFeatures() to determine if a source is empty. 
 
void setExtent(const QgsRectangle &rect) FINAL
Sets the extent. 
 
The QgsDefaultValue class provides a container for managing client side default values for fields...
 
Q_DECL_DEPRECATED QgsGeometry::OperationResult addRing(const QVector< QgsPointXY > &ring, QgsFeatureId *featureId=nullptr)
Adds a ring to polygon/multipolygon features. 
 
virtual void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props=QgsStringMap()) const
used from subclasses to create SLD Rule elements following SLD v1.1 specs 
 
Constraint
Constraints which may be present on a field. 
 
QSet< QString > excludeAttributesWfs() const
A set of attributes that are not advertised in WFS requests with QGIS server. 
 
virtual bool addFeature(QgsFeature &f)
Adds a feature. 
 
UpsideDownLabels upsidedownLabels
Controls whether upside down labels are displayed and how they are handled. 
 
Field has been temporarily added in editing mode (originIndex = index in the list of added attributes...
 
Q_INVOKABLE QgsWkbTypes::Type wkbType() const FINAL
Returns the WKBType or WKBUnknown in case of error. 
 
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key. 
 
Setting options for loading vector layers. 
 
SimplifyAlgorithm simplifyAlgorithm() const
Gets the local simplification algorithm of the vector layer managed. 
 
bool deleteFeature(QgsFeatureId fid)
Deletes a feature from the layer (but does not commit it). 
 
void committedAttributesAdded(const QString &layerId, const QList< QgsField > &addedAttributes)
 
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context. 
 
QSet< QgsMapLayerDependency > dependencies() const FINAL
Gets the list of dependencies. 
 
QList< QgsRelation > referencingRelations(const QgsVectorLayer *layer=nullptr, int fieldIdx=-2) const
Gets all relations where the specified layer (and field) is the referencing part (i.e. 
 
void mapTipTemplateChanged()
Emitted when the map tip changes. 
 
Class allowing to manage the auxiliary storage for a vector layer. 
 
QString qgsEnumValueToKey(const T &value)
Returns the value for the given key of an enum. 
 
bool mShouldValidateCrs
true if the layer's CRS should be validated and invalid CRSes are not permitted. 
 
QgsFieldConstraints::Constraints fieldConstraints(int fieldIndex) const
Returns any constraints which are present at the provider for a specified field index. 
 
Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point...
 
void attributeDeleted(int idx)
 
QList< QgsFeature > QgsFeatureList
 
virtual void readXml(const QDomElement &elem, const QgsReadWriteContext &context)=0
Reads diagram state from a DOM element. 
 
QString mProviderKey
Data provider key (name of the data provider) 
 
Arranges candidates following the curvature of a line feature. Applies to line layers only...
 
bool deleteStyleById_t(const QString &uri, QString styleID, QString &errCause)
 
static void warning(const QString &msg)
Goes to qWarning. 
 
Counts the features in a QgsVectorLayer in task. 
 
void willBeDeleted()
Emitted in the destructor when the layer is about to be deleted, but it is still in a perfectly valid...
 
void setSize(double size)
Sets the size of the buffer. 
 
A class to represent a 2D point. 
 
friend class QgsVectorLayerFeatureSource
 
void setForceLocalOptimization(bool localOptimization)
Sets where the simplification executes, after fetch the geometries from provider, or when supported...
 
void readOnlyChanged()
Emitted when the read only state of this layer is changed. 
 
bool renameAttribute(int index, const QString &newName)
Renames an attribute field (but does not commit it). 
 
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference) 
 
Q_INVOKABLE void invertSelectionInRectangle(QgsRectangle &rect)
Inverts selection of features found within the search rectangle (in layer's coordinates) ...
 
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units used for the buffer size. 
 
void subsetStringChanged()
Emitted when the layer's subset string has changed. 
 
QgsFeature getFeature(QgsFeatureId fid) const
Queries the layer for the feature with the given id. 
 
Q_INVOKABLE bool commitChanges()
Attempts to commit to the underlying data provider any buffered changes made since the last to call t...
 
virtual QSet< QgsMapLayerDependency > dependencies() const
Gets the list of layer ids on which this layer depends. 
 
int selectedFeatureCount() const
Returns the number of features that are selected in this layer. 
 
QString providerType() const
Returns the provider type (provider key) for this layer. 
 
virtual QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context)
store renderer info to XML element 
 
EditResult deleteVertex(QgsFeatureId featureId, int vertex)
Deletes a vertex from a feature. 
 
virtual void setEncoding(const QString &e)
Set encoding used for accessing data from layer. 
 
Q_INVOKABLE bool startEditing()
Makes the layer editable. 
 
void setSimplifyHints(SimplifyHints simplifyHints)
Sets the simplification hints of the vector layer managed. 
 
void setFont(const QFont &font)
Sets the font used for rendering text. 
 
QgsVectorLayer(const QString &path=QString(), const QString &baseName=QString(), const QString &providerLib="ogr", const QgsVectorLayer::LayerOptions &options=QgsVectorLayer::LayerOptions())
Constructor - creates a vector layer. 
 
Q_INVOKABLE void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for layer. 
 
bool deleteAttributes(const QList< int > &attrs)
Deletes a list of attribute fields (but does not commit it) 
 
VertexMarkerType
Editing vertex markers. 
 
void removeExpressionField(int index)
Removes an expression field. 
 
void setFeatureBlendMode(QPainter::CompositionMode blendMode)
Sets the blending mode used for rendering each feature. 
 
QVariant evaluate()
Evaluate the feature and return the result. 
 
void readCustomProperties(const QDomNode &layerNode, const QString &keyStartsWith=QString())
Read custom properties from project file. 
 
static QgsPainting::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode. 
 
static QgsProperty fromField(const QString &fieldName, bool isActive=true)
Returns a new FieldBasedProperty created from the specified field name. 
 
virtual QgsAttributeList pkAttributeIndexes() const
Returns list of indexes of fields that make up the primary key. 
 
Remove from current selection. 
 
void writeXml(QDomElement &layerElem, QDomDocument &doc) const
Writes the diagram settings to a DOM element. 
 
virtual void resolveReferences(QgsProject *project)
Resolve references to other layers (kept as layer IDs after reading XML) into layer objects...
 
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched. 
 
QgsUnitTypes::RenderUnit offsetUnits
Units for offsets of label. 
 
~QgsVectorLayer() override
 
bool writeSymbology(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories) const FINAL
Writes the symbology for the layer into the document provided. 
 
Class providing some utility methods to manage auxiliary storage. 
 
SimplifyHint
Simplification flags for fast rendering of features. 
 
Utility class for calculating aggregates for a field (or expression) over the features from a vector ...
 
double yOffset
Vertical offset of label. 
 
void setLabeling(QgsAbstractVectorLayerLabeling *labeling)
Sets labeling configuration. 
 
Provider can create feature renderers using backend-specific formatting information. Since QGIS 3.2. See QgsVectorDataProvider::createRenderer(). 
 
void readCustomSymbology(const QDomElement &element, QString &errorMessage)
Signal emitted whenever the symbology (QML-file) for this layer is being read. 
 
QString evalErrorString() const
Returns evaluation error. 
 
Aliases, widgets, WMS/WFS, expressions, constraints, virtual fields. 
 
virtual void reloadData()
Reloads the data from the source by calling reloadProviderData() implemented by providers with data c...
 
Q_INVOKABLE QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon. 
 
bool deleteFeatures(const QgsFeatureIds &fids)
Deletes a set of features from the layer (but does not commit it) 
 
virtual const QgsLayerMetadata & metadata() const
Returns a reference to the layer's metadata store. 
 
void readXml(const QDomNode &layer_node)
Reads joins from project file. 
 
void raiseError(const QString &msg) const
Signals an error in this provider. 
 
void configChanged()
Emitted whenever the configuration is changed. 
 
void setDiagramRenderer(QgsDiagramRenderer *r)
Sets diagram rendering object (takes ownership) 
 
Container of fields for a vector layer. 
 
virtual void rollBack()
Stop editing and discard the edits. 
 
A geometry is the spatial representation of a feature. 
 
bool setAttribute(int field, const QVariant &attr)
Set an attribute's value by field index. 
 
virtual QgsFeatureRenderer * createRenderer(const QVariantMap &configuration=QVariantMap()) const
Creates a new vector layer feature renderer, using provider backend specific information. 
 
#define RENDERER_TAG_NAME
 
void beforeRemovingExpressionField(int idx)
Will be emitted, when an expression field is going to be deleted from this vector layer...
 
long featureCount() const FINAL
Returns feature count including changes which have not yet been committed If you need only the count ...
 
QString decodedSource(const QString &source, const QString &provider, const QgsReadWriteContext &context) const FINAL
Called by readLayerXML(), used by derived classes to decode provider's specific data source from proj...
 
static QPainter::CompositionMode getCompositionMode(QgsPainting::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode. 
 
bool mergeLines
true if connected line features with identical label text should be merged prior to generating label ...
 
QgsChangedAttributesMap mChangedAttributeValues
Changed attributes values which are not committed. 
 
bool needsGeometry() const
Returns true if the expression uses feature geometry for some computation. 
 
Allows entering a context category and takes care of leaving this category on deletion of the class...
 
The QgsWeakRelation class represent a QgsRelation with possibly unresolved layers or unmatched fields...
 
QgsEditorWidgetSetup editorWidgetSetup() const
Gets the editor widget setup for the field. 
 
QList< QgsAction > actions(const QString &actionScope=QString()) const
Returns a list of actions that are available in the given action scope. 
 
QVariantMap decodeUri(const QString &providerKey, const QString &uri)
Breaks a provider data source URI into its component paths (e.g. 
 
QMap< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrength > fieldConstraintsAndStrength(int fieldIndex) const
Returns a map of constraint with their strength for a specific field of the layer. 
 
void setFields(const QgsFields &fields)
Convenience function for setting a fields for the scope. 
 
bool skipCrsValidation
Controls whether the layer is allowed to have an invalid/unknown CRS. 
 
QString getStyleById(const QString &providerKey, const QString &uri, QString styleId, QString &errCause)
Gets a layer style defined by styleId. 
 
void setDisplayExpression(const QString &displayExpression)
Set the preview expression, used to create a human readable preview string. 
 
Stores information about constraints which may be present on a field. 
 
Field comes from the underlying data provider of the vector layer (originIndex = index in provider's ...
 
int addTopologicalPoints(const QgsGeometry &geom)
Adds topological points for every vertex of the geometry. 
 
bool isAuxiliaryField(int index, int &srcIndex) const
Returns true if the field comes from the auxiliary layer, false otherwise. 
 
QSet< QString > referencedColumns() const
Gets list of columns referenced by the expression. 
 
Q_INVOKABLE void selectByRect(QgsRectangle &rect, QgsVectorLayer::SelectBehavior behavior=QgsVectorLayer::SetSelection)
Selects features found within the search rectangle (in layer's coordinates) 
 
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
 
static const int EditingCapabilities
Bitmask of all provider's editing capabilities. 
 
void resolveReferences(QgsProject *project) FINAL
Resolves references to other layers (kept as layer IDs after reading XML) into layer objects...
 
bool isValid() const
Returns the status of the layer. 
 
An interface for classes which can visit style entity (e.g. 
 
QgsChangedAttributesMap changedAttributeValues() const
Returns a map of features with changed attributes values which are not committed. ...
 
void beforeCommitChanges()
Emitted before changes are committed to the data provider. 
 
bool qgsVariantGreaterThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is greater than the second. 
 
Q_INVOKABLE QgsFeatureList selectedFeatures() const
Returns a copy of the user-selected features. 
 
bool hasGeometry() const
Returns true if the feature has an associated geometry. 
 
void committedFeaturesRemoved(const QString &layerId, const QgsFeatureIds &deletedFeatureIds)
Emitted when features are deleted from the provider. 
 
QUuid addAction(QgsAction::ActionType type, const QString &name, const QString &command, bool capture=false)
Add an action with the given name and action details. 
 
void committedAttributesDeleted(const QString &layerId, const QgsAttributeList &deletedAttributes)
Emitted when attributes are deleted from the provider. 
 
Full definition – possibly a very lengthy string, e.g. with no truncation of custom WKT definitions...
 
void setBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering a layer. 
 
void setConnection(const QString &aHost, const QString &aPort, const QString &aDatabase, const QString &aUsername, const QString &aPassword, SslMode sslmode=SslPrefer, const QString &authConfigId=QString())
Sets all connection related members at once. 
 
bool insertVertex(double x, double y, QgsFeatureId atFeatureId, int beforeVertex)
Inserts a new vertex before the given vertex number, in the given ring, item (first number is index 0...
 
int count() const
Returns number of items. 
 
QString parserErrorString() const
Returns parser error. 
 
void featureDeleted(QgsFeatureId fid)
Emitted when a feature has been deleted. 
 
QMap< QString, QString > QgsStringMap
 
void editCommandEnded()
Signal emitted, when an edit command successfully ended. 
 
bool isSpatial() const FINAL
Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeome...
 
OperationResult
Success or failure of a geometry operation. 
 
double maxCurvedCharAngleIn
Maximum angle between inside curved label characters (valid range 20.0 to 60.0). 
 
QString username() const
Returns the username stored in the URI. 
 
double ANALYSIS_EXPORT angle(QgsPoint *p1, QgsPoint *p2, QgsPoint *p3, QgsPoint *p4)
Calculates the angle between two segments (in 2 dimension, z-values are ignored) 
 
QgsFieldConstraints::Constraints fieldConstraints(int fieldIndex) const
Returns any constraints which are present for a specified field index. 
 
QList< QgsRelation > referencedRelations(const QgsVectorLayer *layer=nullptr) const
Gets all relations where this layer is the referenced part (i.e. 
 
QgsFeatureIds deletedFeatureIds() const
Returns a list of deleted feature IDs which are not committed. 
 
Q_INVOKABLE void invertSelection()
Selects not selected features and deselects selected ones. 
 
void setParameters(const AggregateParameters ¶meters)
Sets all aggregate parameters from a parameter bundle. 
 
bool qgsVariantLessThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is less than the second. 
 
Attribute table settings: choice and order of columns, conditional styling. 
 
It has not been specified where the field comes from. 
 
void deselect(QgsFeatureId featureId)
Deselects feature by its ID. 
 
Constraint was set at data provider. 
 
void styleChanged()
Signal emitted whenever a change affects the layer's style. 
 
Field has an expression constraint set. See constraintExpression(). 
 
void setFormat(const QgsTextFormat &format)
Sets the label text formatting settings, e.g., font settings, buffer settings, etc. 
 
bool writeXml(QDomNode &layerNode) const
Writes the stored expressions out in XML format. 
 
virtual QgsRectangle extent() const
Returns the extent of the layer. 
 
void setMapTipTemplate(const QString &mapTipTemplate)
The mapTip is a pretty, html representation for feature information. 
 
void writeCustomProperties(QDomNode &layerNode, QDomDocument &doc) const
Write custom properties to project file. 
 
void removeSelection()
Clear selection. 
 
QString attributeAlias(int index) const
Returns the alias of an attribute name or a null string if there is no alias. 
 
Arranges horizontal candidates scattered throughout a polygon feature. Applies to polygon layers only...
 
Manages joined fields for a vector layer. 
 
QgsConditionalLayerStyles * conditionalStyles() const
Returns the conditional styles that are set for this layer. 
 
virtual QgsLayerMetadata layerMetadata() const
Returns layer metadata collected from the provider's source. 
 
QgsField at(int i) const
Gets field at particular index (must be in range 0..N-1) 
 
void setAuxiliaryLayer(QgsAuxiliaryLayer *layer=nullptr)
Sets the current auxiliary layer. 
 
QgsDataProvider * createProvider(const QString &providerKey, const QString &dataSource, const QgsDataProvider::ProviderOptions &options=QgsDataProvider::ProviderOptions())
Creates a new instance of a provider. 
 
const QgsProjectTranslator * projectTranslator() const
Returns the project translator. 
 
int fieldOriginIndex(int fieldIdx) const
Gets field's origin index (its meaning is specific to each type of origin) 
 
bool updateFeature(QgsFeature &feature, bool skipDefaultValues=false)
Updates an existing feature in the layer, replacing the attributes and geometry for the feature with ...
 
void setMaximumScale(double scale)
Sets the maximum map scale (i.e. 
 
static QgsTaskManager * taskManager()
Returns the application's task manager, used for managing application wide background task handling...
 
void dataChanged()
Emitted whenever a change is made to the data provider which may have caused changes in the provider'...
 
Base class for feedback objects to be used for cancellation of something running in a worker thread...
 
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
 
void setFieldConstraint(int index, QgsFieldConstraints::Constraint constraint, QgsFieldConstraints::ConstraintStrength strength=QgsFieldConstraints::ConstraintStrengthHard)
Sets a constraint for a specified field index. 
 
void featureAdded(QgsFeatureId fid)
 
virtual int listStylesInDatabase(QStringList &ids, QStringList &names, QStringList &descriptions, QString &msgError)
Lists all the style in db split into related to the layer and not related to. 
 
QgsFeatureRequest & setExpressionContext(const QgsExpressionContext &context)
Sets the expression context used to evaluate filter expressions. 
 
QgsRectangle mExtent
Extent of the layer. 
 
bool isEditable() const FINAL
Returns true if the provider is in editing mode. 
 
void setExcludeAttributesWfs(const QSet< QString > &att)
A set of attributes that are not advertised in WFS requests with QGIS server. 
 
QgsFeatureRequest & setFilterFid(QgsFeatureId fid)
Sets feature ID that should be fetched. 
 
bool changeAttributeValue(QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue=QVariant())
Changes attribute value in joined layers. 
 
void appendChild(QgsRuleBasedLabeling::Rule *rule)
add child rule, take ownership, sets this as parent 
 
Q_DECL_DEPRECATED void setDataSource(const QString &dataSource, const QString &baseName, const QString &provider, bool loadDefaultStyleFlag=false)
Update the data source of the layer. 
 
void committedGeometriesChanges(const QString &layerId, const QgsGeometryMap &changedGeometries)
 
QString host() const
Returns the host name stored in the URI. 
 
void setEditorWidgetSetup(int index, const QgsEditorWidgetSetup &setup)
The editor widget setup defines which QgsFieldFormatter and editor widget will be used for the field ...
 
Q_INVOKABLE QgsRectangle boundingBoxOfSelected() const
Returns the bounding box of the selected features. If there is no selection, QgsRectangle(0,0,0,0) is returned. 
 
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression. 
 
float maximumScale() const
Gets the maximum scale at which the layer should be simplified. 
 
virtual void updateExtents(bool force=false)
Update the extents for the layer. 
 
Type
The WKB type describes the number of dimensions a geometry has. 
 
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance. 
 
QStringList uniqueStringsMatching(int index, const QString &substring, int limit=-1, QgsFeedback *feedback=nullptr) const
Returns unique string values of an attribute which contain a specified subset string. 
 
bool readXml(const QDomNode &layer_node)
Reads the actions in in XML format. 
 
int indexFromName(const QString &fieldName) const
Gets the field index from the field name. 
 
static QVariant readVariant(const QDomElement &element)
Read a QVariant from a QDomElement. 
 
bool displayAll
If true, all features will be labelled even when overlaps occur. 
 
void setSize(double size)
Sets the size for rendered text. 
 
T qgsEnumKeyToValue(const QString &key, const T &defaultValue)
Returns the value corresponding to the given key of an enum. 
 
const QList< QgsVectorLayerJoinInfo > vectorJoins() const
 
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject. 
 
void reselect()
Reselects the previous set of selected features. 
 
QgsGeometry getGeometry(QgsFeatureId fid) const
Queries the layer for the geometry at the given id. 
 
QgsFields fields() const FINAL
Returns the list of fields of this layer. 
 
QgsCoordinateTransformContext transformContext() const
Returns data provider coordinate transform context. 
 
void writeCommonStyle(QDomElement &layerElement, QDomDocument &document, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) const
Write style data common to all layer types. 
 
Q_INVOKABLE const QgsFeatureIds & selectedFeatureIds() const
Returns a list of the selected features IDs in this layer. 
 
Defines a relation between matching fields of the two involved tables of a relation. 
 
bool changeGeometry(QgsFeatureId fid, QgsGeometry &geometry, bool skipDefaultValue=false)
Changes a feature's geometry within the layer's edit buffer (but does not immediately commit the chan...
 
void readStyleManager(const QDomNode &layerNode)
Read style manager's configuration (if any). To be called by subclasses. 
 
void triggerRepaint(bool deferredUpdate=false)
Will advise the map canvas (and any other interested party) that this layer requires to be repainted...
 
Q_INVOKABLE bool rollBack(bool deleteBuffer=true)
Stops a current editing operation and discards any uncommitted edits. 
 
bool readStyle(const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories) FINAL
Reads the style for the current layer from the Dom node supplied. 
 
void attributeAdded(int idx)
 
bool equals(const QgsGeometry &geometry) const
Test if this geometry is exactly equal to another geometry. 
 
bool deleteFeature(QgsFeatureId fid) const
Deletes a feature from joined layers. 
 
QgsPathResolver pathResolver() const
Returns path resolver object with considering whether the project uses absolute or relative paths and...
 
void select(QgsFeatureId featureId)
Selects feature by its ID. 
 
#define QgsDebugMsgLevel(str, level)
 
bool allowCommit() const
Controls, if the layer is allowed to commit changes. 
 
QString typeName() const
Gets the field type. 
 
Rendering: scale visibility, simplify method, opacity. 
 
void featureBlendModeChanged(QPainter::CompositionMode blendMode)
Signal emitted when setFeatureBlendMode() is called. 
 
QString displayName() const
Returns the name to use when displaying this field. 
 
virtual void setMetadata(const QgsLayerMetadata &metadata)
Sets the layer's metadata store. 
 
static QgsFeatureRenderer * load(QDomElement &symbologyElem, const QgsReadWriteContext &context)
create a renderer from XML element 
 
bool changeAttributeValues(QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues=QgsAttributeMap())
Changes attributes' values in joined layers. 
 
Evaluates and returns the diagram settings relating to a diagram for a specific feature. 
 
void setCrs(const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
Sets layer's spatial reference system. 
 
QSet< QgsMapLayerDependency > mDependencies
List of layers that may modify this layer on modification. 
 
void beforeModifiedCheck() const
Emitted when the layer is checked for modifications. Use for last-minute additions. 
 
QgsFeatureIterator getSelectedFeatures(QgsFeatureRequest request=QgsFeatureRequest()) const
Returns an iterator of the selected features. 
 
void reload() FINAL
Synchronises with changes in the datasource. 
 
QgsFeatureRequest & setNoAttributes()
Set that no attributes will be fetched. 
 
virtual bool isValid() const =0
Returns true if this is a valid layer. 
 
virtual QgsCoordinateReferenceSystem crs() const =0
Returns the coordinate system for the data source. 
 
QString dataComment() const
Returns a description for this layer as defined in the data provider. 
 
QList< QgsRelation > referencingRelations(int idx) const
Returns the layer's relations, where the foreign key is on this layer. 
 
QgsFields fields() const override=0
Returns the fields associated with this data provider. 
 
Show upside down for all labels, including dynamic ones. 
 
QString constraintDescription() const
Returns the descriptive name for the constraint expression. 
 
static QString geometryDisplayString(GeometryType type)
Returns a display string for a geometry type. 
 
double width() const
Returns the width of the rectangle. 
 
bool deleteFeatures(const QgsFeatureIds &fids) const
Deletes a list of features from joined layers. 
 
void afterRollBack()
Emitted after changes are rolled back. 
 
virtual void setExtent(const QgsRectangle &rect)
Sets the extent. 
 
Utility class that encapsulates an action based on vector attributes. 
 
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
 
double opacity() const
Returns the opacity for the vector layer, where opacity is a value between 0 (totally transparent) an...
 
Geometry validation configuration. 
 
void committedFeaturesAdded(const QString &layerId, const QgsFeatureList &addedFeatures)
Emitted when features are added to the provider. 
 
QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext) FINAL
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context...
 
void readXml(const QDomElement &elem)
Reads the diagram settings from a DOM element. 
 
int listStyles(const QString &providerKey, const QString &uri, QStringList &ids, QStringList &names, QStringList &descriptions, QString &errCause)
Lists stored layer styles in the provider defined by providerKey and uri. 
 
bool setDependencies(const QSet< QgsMapLayerDependency > &layers) FINAL
Sets the list of dependencies. 
 
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary). 
 
bool writeSld(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsStringMap &props=QgsStringMap()) const
Writes the symbology of the layer into the document provided in SLD 1.1 format. 
 
virtual QString dataSourceUri(bool expandAuthConfig=false) const
Gets the data source specification. 
 
Q_DECL_DEPRECATED QgsGeometry::OperationResult addPart(const QVector< QgsPointXY > &ring, QgsFeatureId featureId)
Adds a new part polygon to a multipart feature. 
 
Q_DECL_DEPRECATED QgsGeometry::OperationResult splitFeatures(const QVector< QgsPointXY > &splitLine, bool topologicalEditing=false)
Splits features cut by the given line. 
 
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified symbology visitor, causing it to visit all symbols associated with the labeling...
 
Defines left outer join from our vector layer to some other vector layer. 
 
Q_DECL_DEPRECATED QgsGeometry::OperationResult splitFeatures(const QVector< QgsPointXY > &splitLine, bool topologicalEditing=false)
Splits features cut by the given line. 
 
QMap< int, QVariant > QgsAttributeMap
 
virtual bool deleteAttribute(int attr)
Deletes an attribute field (but does not commit it). 
 
void editingStopped()
Emitted when edited changes have been successfully written to the data provider. 
 
void beforeEditingStarted()
Emitted before editing on this layer is started. 
 
static GeometryType geometryType(Type type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
 
QgsGeometryMap mChangedGeometries
Changed geometries which are not committed. 
 
int translateFeature(QgsFeatureId featureId, double dx, double dy)
Translates feature by dx, dy. 
 
void setEnabled(bool enabled)
Sets whether the text buffer will be drawn. 
 
long addTask(QgsTask *task, int priority=0)
Adds a task to the manager. 
 
QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
 
bool moveVertex(double x, double y, QgsFeatureId atFeatureId, int atVertex)
Moves the vertex at the given position number, ring and item (first number is index 0)...
 
Arranges candidates in a circle around a point (or centroid of a polygon). Applies to point or polygo...
 
Don't resolve layer paths or create data providers for layers. 
 
void setColor(const QColor &color)
Sets the color that text will be rendered in. 
 
virtual bool isModified() const
Returns true if the provider has been modified since the last commit. 
 
This class wraps a request for features to a vector layer (or directly its vector data provider)...
 
QgsAttributeList primaryKeyAttributes() const
Returns the list of attributes which make up the layer's primary keys. 
 
void setLabelsEnabled(bool enabled)
Sets whether labels should be enabled for the layer. 
 
void writeXml(QDomNode &layer_node, QDomDocument &document) const
Saves expressions to xml under the layer node. 
 
QgsVectorLayerJoinInfo joinInfo() const
Returns information to use for joining with primary key and so on. 
 
virtual bool changeGeometry(QgsFeatureId fid, const QgsGeometry &geom)
Change feature's geometry. 
 
The QgsMapLayerLegend class is abstract interface for implementations of legends for one map layer...
 
virtual QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) const =0
Returns labeling configuration as XML element. 
 
virtual SpatialIndexPresence hasSpatialIndex() const
Returns an enum value representing the presence of a valid spatial index on the source, if it can be determined. 
 
void setFieldAlias(int index, const QString &aliasString)
Sets an alias (a display name) for attributes to display in dialogs. 
 
float threshold() const
Gets the simplification threshold of the vector layer managed. 
 
bool removeJoin(const QString &joinLayerId)
Removes a vector layer join. 
 
void destroyEditCommand()
Destroy active command and reverts all changes in it. 
 
bool addFeatures(QgsFeatureList &features, QgsFeatureSink::Flags flags=nullptr) FINAL
Adds a list of features to the sink. 
 
An expression node which takes it value from a feature's field. 
 
QgsCoordinateReferenceSystem crs() const
Returns the layer's spatial reference system. 
 
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the size of rendered text. 
 
virtual QVariant aggregate(QgsAggregateCalculator::Aggregate aggregate, int index, const QgsAggregateCalculator::AggregateParameters ¶meters, QgsExpressionContext *context, bool &ok, QgsFeatureIds *fids=nullptr) const
Calculates an aggregated value from the layer's features. 
 
void dataSourceChanged()
Emitted whenever the layer's data source has been changed. 
 
Encapsulates a QGIS project, including sets of map layers and their styles, layouts, annotations, canvases, etc. 
 
Storage and management of actions associated with a layer. 
 
QString publicSource() const
Gets a version of the internal layer definition that has sensitive bits removed (for example...
 
virtual bool deleteFeatures(const QgsFeatureIds &fid)
Deletes a set of features from the layer (but does not commit it) 
 
Provider can read layer metadata from data store. Since QGIS 3.0. See QgsDataProvider::layerMetadata(...
 
SpatialIndexPresence hasSpatialIndex() const override
 
void geometryChanged(QgsFeatureId fid, const QgsGeometry &geometry)
Emitted whenever a geometry change is done in the edit buffer. 
 
bool setReadOnly(bool readonly=true)
Makes layer read-only (editing disabled) or not. 
 
void selectionChanged(const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect)
Emitted when selection was changed. 
 
void setParam(const QString &key, const QString &value)
Sets a generic parameter value on the URI. 
 
virtual bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=nullptr)
Adds a single feature to the sink. 
 
virtual QgsTransaction * transaction() const
Returns the transaction this data provider is included in, if any. 
 
QString loadStyle(const QString &providerKey, const QString &uri, QString &errCause)
Loads a layer style defined by uri. 
 
T flagValue(const QString &key, const T &defaultValue, const Section section=NoSection)
Returns the setting value for a setting based on a flag. 
 
QList< QgsWeakRelation > weakRelations() const
Returns the layer's weak relations as specified in the layer's style. 
 
Manages QGIS Server properties for a vector layer. 
 
QgsFeatureRenderer * renderer()
Returns renderer. 
 
Y-coordinate data defined diagram position. 
 
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer. 
 
QgsFeatureIds mDeletedFeatureIds
Deleted feature IDs which are not committed. 
 
const QgsVectorJoinList & vectorJoins() const
 
Abstract base class for curved geometry type. 
 
void removeCustomProperty(const QString &key)
Remove a custom property from layer. 
 
void attributeValueChanged(QgsFeatureId fid, int idx, const QVariant &value)
Emitted whenever an attribute value change is done in the edit buffer. 
 
Encapsulate a field in an attribute table or data source. 
 
void featureAdded(QgsFeatureId fid)
Emitted when a new feature has been added to the layer. 
 
Fetch only a subset of attributes (setSubsetOfAttributes sets this flag) 
 
QgsCoordinateTransformContext transformContext() const
Returns the layer data provider coordinate transform context or a default transform context if the la...
 
QgsEditFormConfig editFormConfig() const
Returns the configuration of the form used to represent this vector layer. 
 
void setSimplifyAlgorithm(SimplifyAlgorithm simplifyAlgorithm)
Sets the local simplification algorithm of the vector layer managed. 
 
const QgsAbstractVectorLayerLabeling * labeling() const
Access to const labeling configuration. 
 
QVariant minimumValue(int index) const FINAL
Returns the minimum value for an attribute column or an invalid variant in case of error...
 
QString userFriendlyIdentifier(IdentifierType type=MediumString) const
Returns a user friendly identifier for the CRS. 
 
void rendererChanged()
Signal emitted when renderer is changed. 
 
void updateFields(QgsFields &flds)
Adds fields with the expressions buffered in this object to a QgsFields object. 
 
virtual bool isSaveAndLoadStyleToDatabaseSupported() const
It returns false by default. 
 
Single scope for storing variables and functions for use within a QgsExpressionContext. 
 
double minimumScale() const
Returns the minimum map scale (i.e. 
 
Contains information about the context in which a coordinate transform is executed. 
 
virtual bool changeAttributeValues(QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues)
Changes values of attributes (but does not commit it). 
 
Fast access to features using their ID. 
 
QgsRelationManager relationManager
 
Whether to show the diagram. 
 
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the scope. 
 
double maximumScale() const
Returns the maximum map scale (i.e. 
 
bool mValid
Indicates if the layer is valid and can be drawn. 
 
QString port() const
Returns the port stored in the URI. 
 
void raiseError(const QString &msg)
Signals an error related to this vector layer. 
 
Add selection to current selection. 
 
void editingStarted()
Emitted when editing on this layer has started. 
 
void setName(const QString &name)
Set the display name of the layer. 
 
QgsExpressionContext createExpressionContext() const FINAL
This method needs to be reimplemented in all classes which implement this interface and return an exp...
 
QString capabilitiesString() const
Capabilities for this layer, comma separated and translated. 
 
static Q_DECL_DEPRECATED void drawVertexMarker(double x, double y, QPainter &p, QgsVectorLayer::VertexMarkerType type, int vertexSize)
Draws a vertex symbol at (screen) coordinates x, y. 
 
QVariant calculate(Aggregate aggregate, const QString &fieldOrExpression, QgsExpressionContext *context=nullptr, bool *ok=nullptr) const
Calculates the value of an aggregate. 
 
QMap< QString, QgsMapLayer * > mapLayers(const bool validOnly=false) const
Returns a map of all registered layers by layer ID. 
 
QgsAuxiliaryLayer * auxiliaryLayer()
Returns the current auxiliary layer. 
 
Point geometry type, with support for z-dimension and m-values. 
 
Double value (including negative values) 
 
virtual QSet< QVariant > uniqueValues(int fieldIndex, int limit=-1) const
Returns the set of unique values contained within the specified fieldIndex from this source...
 
QString constraintDescription(int index) const
Returns the descriptive name for the constraint expression for a specified field index. 
 
void symbolFeatureCountMapChanged()
Emitted when the feature count for symbols on this layer has been recalculated. 
 
QHash< QString, QgsFeatureIds > symbolFeatureIdMap() const
Returns the QgsFeatureIds for each symbol. 
 
void endEditCommand()
Finish edit command and add it to undo/redo stack. 
 
virtual bool commitChanges(QStringList &commitErrors)
Attempts to commit any changes to disk. 
 
QPainter::CompositionMode featureBlendMode() const
Returns the current blending mode for features. 
 
void setConstraint(Constraint constraint, ConstraintOrigin origin=ConstraintOriginLayer)
Sets a constraint on the field. 
 
void committedAttributeValuesChanges(const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues)
Emitted when attribute value changes are saved to the provider. 
 
void dirtied(const QString &sql, const QString &name)
Emitted if a sql query is executed and the underlying data is modified. 
 
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings for fast rendering of features. 
 
QString displayField() const
This is a shorthand for accessing the displayExpression if it is a simple field. 
 
virtual bool deleteAttribute(int attr)
Delete an attribute field (but does not commit it) 
 
static bool fillFromSld(QDomElement &element, Qt::BrushStyle &brushStyle, QColor &color)
 
bool readXml(const QDomNode &node, const QgsReadWriteContext &context)
Reads the condition styles state from a DOM node. 
 
QgsRectangle extent() const FINAL
Returns the extent of the layer. 
 
Definition for a property. 
 
void fullExtentCalculated()
Emitted whenever a deferred extent calculation is completed by the provider. 
 
const QgsDiagramRenderer * diagramRenderer() const
 
virtual QgsAbstractVectorLayerLabeling * createLabeling(const QVariantMap &configuration=QVariantMap()) const
Creates labeling settings, using provider backend specific information. 
 
bool loadAuxiliaryLayer(const QgsAuxiliaryStorage &storage, const QString &key=QString())
Loads the auxiliary layer for this vector layer. 
 
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties. 
 
void writeXml(QDomNode &node) const
Serialize to XML on layer save. 
 
bool readExtentFromXml() const
Returns true if the extent is read from the XML document when data source has no metadata, false if it's the data provider which determines it. 
 
void editCommandDestroyed()
Signal emitted, when an edit command is destroyed. 
 
void recalculateExtents() const
This is used to send a request that any mapcanvas using this layer update its extents. 
 
Set selection, removing any existing selection. 
 
int addExpressionField(const QString &exp, const QgsField &fld)
Add a new field which is calculated by the expression specified. 
 
void setMaximumScale(float maximumScale)
Sets the maximum scale at which the layer should be simplified. 
 
virtual bool isClosed() const
Returns true if the curve is closed. 
 
void repaintRequested(bool deferredUpdate=false)
By emitting this signal the layer tells that either appearance or content have been changed and any v...
 
virtual void exportNamedStyle(QDomDocument &doc, QString &errorMsg, const QgsReadWriteContext &context=QgsReadWriteContext(), QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories) const
Export the properties of this layer as named style in a QDomDocument. 
 
QString expression() const
Returns the original, unmodified expression string. 
 
double yMinimum() const
Returns the y minimum value (bottom side of rectangle). 
 
QString uri(bool expandAuthConfig=true) const
Returns the complete URI as a string. 
 
virtual QString translate(const QString &context, const QString &sourceText, const char *disambiguation=nullptr, int n=-1) const =0
The derived translate() translates with QTranslator and qm file the sourceText. 
 
static QgsMapLayerLegend * defaultVectorLegend(QgsVectorLayer *vl)
Create new legend implementation for vector layer. 
 
void setProviderEncoding(const QString &encoding)
Sets the text encoding of the data provider. 
 
void relationsLoaded()
Emitted when the relations were loaded after reading a project. 
 
int addTopologicalPoints(const QgsGeometry &geom)
Adds topological points for every vertex of the geometry. 
 
virtual void cancel()
Notifies the task that it should terminate. 
 
General configuration: identifiable, removable, searchable, display expression, read-only. 
 
Implementation of threaded rendering for vector layers. 
 
void setScaleBasedVisibility(bool enabled)
Sets whether scale based visibility is enabled for the layer. 
 
void writeStyleManager(QDomNode &layerNode, QDomDocument &doc) const
Write style manager's configuration (if exists). To be called by subclasses. 
 
void styleLoaded(QgsMapLayer::StyleCategories categories)
Emitted when a style has been loaded. 
 
QStringList commitErrors() const
Returns a list containing any error messages generated when attempting to commit changes to the layer...
 
Stores the settings for rendering of all diagrams for a layer. 
 
double xMaximum() const
Returns the x maximum value (right side of rectangle). 
 
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer...
 
QVector< QgsPoint > QgsPointSequence
 
void combineExtentWith(const QgsRectangle &rect)
Expands the rectangle so that it covers both the original rectangle and the given rectangle...
 
bool readXml(const QDomNode &layerNode)
Reads the stored expressions in in XML format. 
 
QgsCoordinateTransformContext transformContext() const
Returns data provider coordinate transform context. 
 
QString capabilitiesString() const
Returns the above in friendly format. 
 
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way. 
 
bool useRenderingOptimization() const
Returns true if the rendering optimization (geometry simplification) can be executed. 
 
Modify current selection to include only select features which match. 
 
QgsDefaultValue defaultValueDefinition(int index) const
Returns the definition of the expression used when calculating the default value for a field...
 
QMap< QgsFeatureId, QgsFeature > QgsFeatureMap
 
bool removeJoin(const QString &joinLayerId)
Removes a vector layer join. 
 
SelectBehavior
Selection behavior. 
 
RelationStrength
enum for the relation strength Association, Composition 
 
bool insertVertex(double x, double y, QgsFeatureId atFeatureId, int beforeVertex)
Insert a new vertex before the given vertex number, in the given ring, item (first number is index 0)...
 
QgsFeatureMap addedFeatures() const
Returns a map of new features which are not committed. 
 
QgsAttributeTableConfig attributeTableConfig() const
Returns the attribute table configuration object. 
 
const QgsPathResolver & pathResolver() const
Returns path resolver for conversion between relative and absolute paths. 
 
Arranges candidates parallel to a generalised line representing the feature or parallel to a polygon'...
 
void attributeAdded(int idx)
Will be emitted, when a new attribute has been added to this vector layer. 
 
void allowCommitChanged()
Emitted whenever the allowCommitChanged() property of this layer changes. 
 
virtual QString loadDefaultStyle(bool &resultFlag)
Retrieve the default style for this layer if one exists (either as a .qml file on disk or as a record...
 
void beforeAddingExpressionField(const QString &fieldName)
Will be emitted, when an expression field is going to be added to this vector layer. 
 
Custom properties (by plugins for instance) 
 
Contains information about the context of a rendering operation. 
 
QgsExpressionContextScope * createExpressionContextScope() const FINAL
This method needs to be reimplemented in all classes which implement this interface and return an exp...
 
Setting options for creating vector data providers. 
 
QgsFieldConstraints constraints
 
X-coordinate data defined diagram position. 
 
QString name() const
Returns the display name of the layer. 
 
Buffers information about expression fields for a vector layer. 
 
QString getStyleById_t(const QString &uri, QString styleID, QString &errCause)
 
bool isEmpty() const
Returns true if the configuration is empty, ie it contains no columns. 
 
bool deleteStyleById(const QString &providerKey, const QString &uri, QString styleId, QString &errCause)
Deletes a layer style defined by styleId. 
 
void editCommandStarted(const QString &text)
Signal emitted when a new edit command has been started. 
 
QString loadStyle_t(const QString &uri, QString &errCause)
 
bool simplifyDrawingCanbeApplied(const QgsRenderContext &renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint) const
Returns whether the VectorLayer can apply the specified simplification hint. 
 
QgsFeatureRequest & setFilterFids(const QgsFeatureIds &fids)
Sets feature IDs that should be fetched. 
 
bool isCanceled() const
Tells whether the operation has been canceled already. 
 
QgsEditorWidgetSetup editorWidgetSetup(int index) const
The editor widget setup defines which QgsFieldFormatter and editor widget will be used for the field ...
 
void displayExpressionChanged()
Emitted when the display expression changes. 
 
Q_DECL_DEPRECATED QgsGeometry::OperationResult addRing(const QVector< QgsPointXY > &ring, const QgsFeatureIds &targetFeatureIds=QgsFeatureIds(), QgsFeatureId *modifiedFeatureId=nullptr)
Adds a ring to polygon/multipolygon features. 
 
bool addJoin(const QgsVectorLayerJoinInfo &joinInfo)
Joins another vector layer to this layer. 
 
int indexOf(const QString &fieldName) const
Gets the field index from the field name. 
 
Points (e.g., for font sizes) 
 
QString mDataSource
Data source description string, varies by layer type. 
 
void attributeValueChanged(QgsFeatureId fid, int idx, const QVariant &)
 
virtual void setTransformContext(const QgsCoordinateTransformContext &transformContext)
Sets data coordinate transform context to transformContext. 
 
QSet< QVariant > uniqueValues(int fieldIndex, int limit=-1) const FINAL
Calculates a list of unique values contained within an attribute in the layer. 
 
QString source() const
Returns the source for the layer. 
 
long featureCount() const override=0
Number of features in the layer. 
 
const QgsDiagramLayerSettings * diagramLayerSettings() const
 
bool accept(QgsStyleEntityVisitorInterface *visitor) const override
 
const QgsExpressionNode * rootNode() const
Returns the root node of the expression. 
 
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer. 
 
void setConstraintExpression(const QString &expression, const QString &description=QString())
Set the constraint expression for the field. 
 
QgsCurve * clone() const override=0
Clones the geometry by performing a deep copy. 
 
This class allows including a set of layers in a database-side transaction, provided the layer data p...
 
QgsCoordinateTransformContext transformContext
Coordinate transform context. 
 
ConstraintStrength
Strength of constraints. 
 
void updateExpression(int index, const QString &exp)
Changes the expression at a given index. 
 
virtual void toSld(QDomNode &parent, const QgsStringMap &props) const
Writes the SE 1.1 TextSymbolizer element based on the current layer labeling settings. 
 
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes. 
 
void committedAttributeValuesChanges(const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues)
 
static QgsFeatureRenderer * loadSld(const QDomNode &node, QgsWkbTypes::GeometryType geomType, QString &errorMessage)
Create a new renderer according to the information contained in the UserStyle element of a SLD style ...
 
Container for settings relating to a text buffer. 
 
void setAllowCommit(bool allowCommit)
Controls, if the layer is allowed to commit changes. 
 
Q_INVOKABLE bool deleteSelectedFeatures(int *deletedCount=nullptr)
Deletes the selected features. 
 
static QgsUnitTypes::RenderUnit decodeSldUom(const QString &str, double *scaleFactor=nullptr)
Decodes a SLD unit of measure string to a render unit. 
 
Edit operation was successful. 
 
QString expressionField(int index) const
Returns the expression used for a given expression field. 
 
virtual QList< QgsDiagramSettings > diagramSettings() const =0
Returns list with all diagram settings in the renderer. 
 
bool forceLocalOptimization() const
Gets where the simplification executes, after fetch the geometries from provider, or when supported...
 
void setMinimumScale(double scale)
Sets the minimum map scale (i.e. 
 
QString constraintExpression(int index) const
Returns the constraint expression for for a specified field index, if set. 
 
The QgsConditionalLayerStyles class holds conditional style information for a layer. 
 
bool moveVertex(double x, double y, QgsFeatureId atFeatureId, int atVertex)
Moves the vertex at the given position number, ring and item (first number is index 0)...
 
void updateFields(QgsFields &fields)
Updates field map with joined attributes. 
 
QgsWkbTypes::Type fallbackWkbType
Fallback geometry type. 
 
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context. 
 
void committedAttributesAdded(const QString &layerId, const QList< QgsField > &addedAttributes)
Emitted when attributes are added to the provider. 
 
void readXml(const QDomNode &layer_node)
Reads expressions from project file. 
 
static QgsProject * instance()
Returns the QgsProject singleton instance. 
 
Q_INVOKABLE void selectByExpression(const QString &expression, QgsVectorLayer::SelectBehavior behavior=QgsVectorLayer::SetSelection)
Selects matching features using an expression. 
 
virtual QString loadNamedStyle(const QString &uri, bool &resultFlag, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories)
Retrieve a named style for this layer if one exists (either as a .qml file on disk or as a record in ...
 
QgsRectangle boundingBox() const
Returns the bounding box of the geometry. 
 
void removeExpression(int index)
Remove an expression from the buffer. 
 
virtual QString dataComment() const
Returns a short comment for the data that this provider is providing access to (e.g. 
 
This class represents a coordinate reference system (CRS). 
 
bool isField() const
Checks whether an expression consists only of a single field reference. 
 
virtual QStringList uniqueStringsMatching(int index, const QString &substring, int limit=-1, QgsFeedback *feedback=nullptr) const
Returns unique string values of an attribute which contain a specified subset string. 
 
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry. 
 
friend class QgsVectorLayerEditBuffer
 
virtual bool isModified() const
Returns true if the provider has been modified since the last commit. 
 
QHash< QString, long > symbolFeatureCountMap() const
Returns the count for each symbol. 
 
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()). 
 
Abstract base class - its implementations define different approaches to the labeling of a vector lay...
 
Q_INVOKABLE void selectByIds(const QgsFeatureIds &ids, QgsVectorLayer::SelectBehavior behavior=QgsVectorLayer::SetSelection)
Selects matching features using a list of feature IDs. 
 
const QgsVectorLayerJoinInfo * joinForFieldIndex(int index, const QgsFields &fields, int &sourceFieldIndex) const
Finds the vector join for a layer field index. 
 
SimplifyHints simplifyHints() const
Gets the simplification hints of the vector layer managed. 
 
Provider can set labeling settings using backend-specific formatting information. Since QGIS 3...
 
void removeFieldAlias(int index)
Removes an alias (a display name) for attributes to display in dialogs. 
 
bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=nullptr) FINAL
Adds a single feature to the sink. 
 
bool isEmpty() const
Checks whether the container is empty. 
 
void writeCustomSymbology(QDomElement &element, QDomDocument &doc, QString &errorMessage) const
Signal emitted whenever the symbology (QML-file) for this layer is being written. ...
 
static QString displayString(Type type)
Returns a display string type for a WKB type, e.g., the geometry name used in WKT geometry representa...
 
virtual bool setSubsetString(const QString &subset)
Sets the string (typically sql) used to define a subset of the layer. 
 
QString writePath(const QString &filename) const
Prepare a filename to save it to the project file. 
 
QgsVectorLayer::EditResult deleteVertex(QgsFeatureId featureId, int vertex)
Deletes a vertex from a feature. 
 
double xMinimum() const
Returns the x minimum value (left side of rectangle). 
 
void setDefaultValueDefinition(int index, const QgsDefaultValue &definition)
Sets the definition of the expression to use when calculating the default value for a field...
 
virtual QString getStyleFromDatabase(const QString &styleId, QString &msgError)
Returns the named style corresponding to style id provided. 
 
virtual bool deleteFeature(QgsFeatureId fid)
Delete a feature from the layer (but does not commit it) 
 
virtual bool enterUpdateMode()
Enter update mode. 
 
void setSimplifyMethod(const QgsVectorSimplifyMethod &simplifyMethod)
Sets the simplification settings for fast rendering of features. 
 
friend class QgsVectorLayerEditPassthrough
 
Basic implementation of the labeling interface. 
 
T enumValue(const QString &key, const T &defaultValue, const Section section=NoSection)
Returns the setting value for a setting based on an enum. 
 
void dataChanged()
Data of layer changed. 
 
void joinedFieldsChanged()
Emitted whenever the list of joined fields changes (e.g. 
 
virtual bool changeAttributeValue(QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue=QVariant())
Changed an attribute value (but does not commit it) 
 
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID. 
 
A grouped map of multiple QgsProperty objects, each referenced by a integer key value. 
 
Base class for utility classes that encapsulate information necessary for rendering of map layers...
 
void setConstraintExpression(int index, const QString &expression, const QString &description=QString())
Sets the constraint expression for the specified field index. 
 
QString sourceName() const FINAL
Returns a friendly display name for the source. 
 
virtual void handlePostCloneOperations(QgsVectorDataProvider *source)
Handles any post-clone operations required after this vector data provider was cloned from the source...
 
void setBuffer(const QgsTextBufferSettings &bufferSettings)
Sets the text's buffer settings. 
 
Allows deletion of features. 
 
double yMaximum() const
Returns the y maximum value (top side of rectangle). 
 
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request. 
 
SpatialIndexPresence
Enumeration of spatial index presence states. 
 
bool isExpression
true if this label is made from a expression string, e.g., FieldName || 'mm' 
 
QgsCoordinateReferenceSystem sourceCrs() const FINAL
Returns the coordinate reference system for features in the source. 
 
ConstraintOrigin constraintOrigin(Constraint constraint) const
Returns the origin of a field constraint, or ConstraintOriginNotSet if the constraint is not present ...
 
QString password() const
Returns the password stored in the URI. 
 
QgsMapLayerType
Types of layers that can be added to a map. 
 
virtual QgsRectangle extent() const =0
Returns the extent of the layer. 
 
FeatureAvailability hasFeatures() const FINAL
Determines if this vector layer has features. 
 
bool changeAttributeValue(QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue=QVariant(), bool skipDefaultValues=false)
Changes an attribute value for a feature (but does not immediately commit the changes). 
 
QgsWkbTypes::GeometryType type
 
Edit failed due to invalid layer. 
 
Q_INVOKABLE QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer. 
 
Spatial index presence cannot be determined, index may or may not exist. 
 
QUndoStack * undoStack()
Returns pointer to layer's undo stack. 
 
virtual QString storageType() const
Returns the permanent storage type for this layer as a friendly name. 
 
void committedFeaturesRemoved(const QString &layerId, const QgsFeatureIds &deletedFeatureIds)
 
QgsVectorDataProvider * dataProvider() FINAL
Returns the layer's data provider, it may be nullptr. 
 
QList< int > QgsAttributeList
 
QgsExpressionContextScope * popScope()
Removes the last scope from the expression context and return it. 
 
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer. 
 
void committedFeaturesAdded(const QString &layerId, const QgsFeatureList &addedFeatures)
 
void normalize()
Normalize the rectangle so it has non-negative width/height. 
 
virtual bool deleteStyleFromDatabase(const QString &styleId, QString &msgError)
Deletes a style from the database. 
 
bool nextFeature(QgsFeature &f)
 
This is a container for configuration of the attribute table. 
 
void setCoordinateSystem()
Setup the coordinate system transformation for the layer. 
 
This is the base class for vector data providers. 
 
QgsVectorLayerFeatureCounter * countSymbolFeatures(bool storeSymbolFids=false)
Count features for symbols. 
 
void attributeDeleted(int idx)
Will be emitted, when an attribute has been deleted from this vector layer. 
 
virtual void setTransformContext(const QgsCoordinateTransformContext &transformContext) override
Sets the coordinate transform context to transformContext. 
 
Container for all settings relating to text rendering. 
 
Resolves relative paths into absolute paths and vice versa. 
 
QString constraintExpression() const
Returns the constraint expression for the field, if set. 
 
static QgsFeatureRenderer * defaultRenderer(QgsWkbTypes::GeometryType geomType)
Returns a new renderer - used by default in vector layers. 
 
bool changeAttributeValues(QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues=QgsAttributeMap(), bool skipDefaultValues=false)
Changes attributes' values for a feature (but does not immediately commit the changes). 
 
Geometry is not required. It may still be returned if e.g. required for a filter condition. 
 
void setEditFormConfig(const QgsEditFormConfig &editFormConfig)
Sets the editFormConfig (configuration) of the form used to represent this vector layer...
 
void setLegend(QgsMapLayerLegend *legend)
Assign a legend controller to the map layer. 
 
Class for storing the component parts of a RDBMS data source URI (e.g. 
 
QgsFeatureMap mAddedFeatures
New features which are not committed. 
 
void committedGeometriesChanges(const QString &layerId, const QgsGeometryMap &changedGeometries)
Emitted when geometry changes are saved to the provider. 
 
static QgsExpression * expressionFromOgcFilter(const QDomElement &element, QgsVectorLayer *layer=nullptr)
Parse XML with OGC filter into QGIS expression. 
 
virtual bool empty() const
Returns true if the layer does not contain any feature. 
 
QgsCoordinateReferenceSystem fallbackCrs
Fallback layer coordinate reference system. 
 
This class models dependencies with or between map layers. 
 
bool hasEvalError() const
Returns true if an error occurred when evaluating last input. 
 
QString createSavepoint(QString &error)
creates a save point returns empty string on error returns the last created savepoint if it's not dir...
 
QString displayExpression() const
Returns the preview expression, used to create a human readable preview string. 
 
void updateFields(QgsFields &fields)
 
QVariant maximumValue(int index) const FINAL
Returns the maximum value for an attribute column or an invalid variant in case of error...
 
void layerModified()
Emitted when modifications has been done on layer. 
 
Represents a vector layer which manages a vector based data sets. 
 
Arranges candidates following the curvature of a polygon's boundary. Applies to polygon layers only...
 
bool addAttribute(const QgsField &field)
Add an attribute field (but does not commit it) returns true if the field was added. 
 
QString htmlMetadata() const FINAL
Obtain a formatted HTML string containing assorted metadata for this layer. 
 
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name. 
 
virtual QgsFeatureIds allFeatureIds() const
Returns a list of all feature IDs for features present in the source. 
 
virtual bool writeXml(QDomElement &collectionElem, const QgsPropertiesDefinition &definitions) const
Writes the current state of the property collection into an XML element. 
 
virtual void readXml(const QDomElement &elem, const QgsReadWriteContext &context)
Reads configuration from a DOM element previously written by writeXml() 
 
Field is calculated from an expression. 
 
void updatedFields()
Emitted whenever the fields available from this layer have been changed. 
 
void updateExpressionField(int index, const QString &exp)
Changes the expression used to define an expression based (virtual) field. 
 
EditResult
Result of an edit operation. 
 
void setAttributeTableConfig(const QgsAttributeTableConfig &attributeTableConfig)
Sets the attribute table configuration object. 
 
void layerModified()
Emitted when modifications has been done on layer. 
 
QgsAttributeList mDeletedAttributeIds
Deleted attributes fields which are not committed. The list is kept sorted. 
 
static QgsRectangle readRectangle(const QDomElement &element)
 
QString attributeDisplayName(int index) const
Convenience function that returns the attribute alias if defined or the field name else...
 
void setColor(const QColor &color)
Sets the color for the buffer. 
 
QString database() const
Returns the database name stored in the URI. 
 
Manages stored expressions regarding creation, modification and storing in the project. 
 
void featureDeleted(QgsFeatureId fid)
 
static QDomElement writeVariant(const QVariant &value, QDomDocument &doc)
Write a QVariant to a QDomElement. 
 
QgsAuxiliaryLayer * createAuxiliaryLayer(const QgsField &field, QgsVectorLayer *layer) const
Creates an auxiliary layer for a vector layer. 
 
QgsDefaultValue defaultValueDefinition
 
void set(const QgsPointXY &p1, const QgsPointXY &p2)
Sets the rectangle from two QgsPoints. 
 
void setDatabase(const QString &database)
Sets the URI database name. 
 
void resolveReferences(QgsProject *project)
Resolves layer IDs of joined layers using given project's available layers. 
 
static QgsAbstractVectorLayerLabeling * create(const QDomElement &element, const QgsReadWriteContext &context)
Try to create instance of an implementation based on the XML data. 
 
QgsVectorLayer * clone() const override
Returns a new instance equivalent to this one. 
 
virtual bool hasMetadata() const
Returns true if the data source has metadata, false otherwise. 
 
void readXml(const QDomNode &node)
Deserialize to XML on layer load. 
 
Aggregate
Available aggregates to calculate. 
 
virtual bool leaveUpdateMode()
Leave update mode. 
 
void setFlags(QgsMapLayer::LayerFlags flags)
Returns the flags for this layer. 
 
RenderUnit
Rendering size units. 
 
bool diagramsEnabled() const
Returns whether the layer contains diagrams which are enabled and should be drawn. 
 
void readCommonStyle(const QDomElement &layerElement, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories)
Read style data common to all layer types. 
 
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer. 
 
double height() const
Returns the height of the rectangle. 
 
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched. 
 
bool readXml(const QDomNode &layer_node, QgsReadWriteContext &context) FINAL
Reads vector layer specific state from project file Dom node. 
 
QString joinLayerId() const
ID of the joined layer - may be used to resolve reference to the joined layer. 
 
void setReadExtentFromXml(bool readExtentFromXml)
Flag allowing to indicate if the extent has to be read from the XML document when data source has no ...
 
QgsMapLayer::ReadFlags mReadFlags
Read flags. It's up to the subclass to respect these when restoring state from XML. 
 
virtual QString loadNamedStyle(const QString &theURI, bool &resultFlag, bool loadFromLocalDb, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories)
Loads a named style from file/local db/datasource db. 
 
A bundle of parameters controlling aggregate calculation. 
 
QVariant defaultValue(int index, const QgsFeature &feature=QgsFeature(), QgsExpressionContext *context=nullptr) const
Returns the calculated default value for the specified field index. 
 
QString loadDefaultStyle(bool &resultFlag) FINAL
Retrieve the default style for this layer if one exists (either as a .qml file on disk or as a record...
 
virtual void saveStyleToDatabase(const QString &name, const QString &description, bool useAsDefault, const QString &uiFileContent, QString &msgError)
Saves named and sld style of the layer to the style table in the db. 
 
void setThreshold(float threshold)
Sets the simplification threshold of the vector layer managed. 
 
bool saveStyle_t(const QString &uri, const QString &qmlStyle, const QString &sldStyle, const QString &styleName, const QString &styleDescription, const QString &uiFileContent, bool useAsDefault, QString &errCause)
 
QString fieldName
Name of field (or an expression) to use for label text. 
 
Field must have a unique value. 
 
QVariant aggregate(QgsAggregateCalculator::Aggregate aggregate, const QString &fieldOrExpression, const QgsAggregateCalculator::AggregateParameters ¶meters=QgsAggregateCalculator::AggregateParameters(), QgsExpressionContext *context=nullptr, bool *ok=nullptr, QgsFeatureIds *fids=nullptr) const
Calculates an aggregated value from the layer's features. 
 
bool isValid() const
Returns whether this CRS is correctly initialized and usable. 
 
virtual QVariant defaultValue(int fieldIndex) const
Returns any literal default values which are present at the provider for a specified field index...
 
int listStyles_t(const QString &uri, QStringList &ids, QStringList &names, QStringList &descriptions, QString &errCause)
 
void setOpacity(double opacity)
Sets the opacity for the vector layer, where opacity is a value between 0 (totally transparent) and 1...