QGIS API Documentation
3.26.3-Buenos Aires (65e4edfdad)
|
Go to the documentation of this file.
101 #include <QPainterPath>
103 #include <QProgressDialog>
107 #include <QStringBuilder>
109 #include <QUndoCommand>
112 #include <QRegularExpression>
118 #ifdef TESTPROVIDERLIB
124 const QString &qmlStyle,
125 const QString &sldStyle,
126 const QString &styleName,
127 const QString &styleDescription,
128 const QString &uiFileContent,
142 QStringList &descriptions,
160 const QString &baseName,
161 const QString &providerKey,
166 , mAuxiliaryLayer( nullptr )
167 , mAuxiliaryLayerKey( QString() )
168 , mReadExtentFromXml( options.readExtentFromXml )
169 , mRefreshRendererTimer( new QTimer( this ) )
179 mGeometryOptions = std::make_unique<QgsGeometryOptions>();
183 mStoredExpressionManager->setParent(
this );
186 mJoinBuffer->setParent(
this );
191 if ( !vectorLayerPath.isEmpty() && !
mProviderKey.isEmpty() )
194 QgsDataProvider::ReadFlags providerFlags = QgsDataProvider::ReadFlags();
199 setDataSource( vectorLayerPath, baseName, providerKey, providerOptions, providerFlags );
204 if ( !mAttributeAliasMap.contains(
field.
name() ) )
205 mAttributeAliasMap.insert(
field.
name(), QString() );
211 if ( !mTemporalProperties->
isActive() )
232 mSimplifyMethod.
setThreshold( settings.
value( QStringLiteral(
"qgis/simplifyDrawingTol" ), mSimplifyMethod.
threshold() ).toFloat() );
236 connect( mRefreshRendererTimer, &QTimer::timeout,
this, [ = ] {
triggerRepaint(
true ); } );
245 delete mDataProvider;
248 delete mExpressionFieldBuffer;
250 delete mDiagramLayerSettings;
251 delete mDiagramRenderer;
256 delete mConditionalStyles;
257 delete mStoredExpressionManager;
259 if ( mFeatureCounter )
260 mFeatureCounter->
cancel();
262 qDeleteAll( mRendererGenerators );
288 QList<QgsVectorLayerJoinInfo> joins =
vectorJoins();
289 const auto constJoins = joins;
309 for (
const QgsAction &action : constActions )
346 auto constraintIt = constraints.constBegin();
347 for ( ; constraintIt != constraints.constEnd(); ++ constraintIt )
363 layer->mElevationProperties = mElevationProperties->
clone();
364 layer->mElevationProperties->setParent( layer );
390 return mDataProvider && mDataProvider->
isSqlQuery();
437 p.setPen( QColor( 50, 100, 120, 200 ) );
438 p.setBrush( QColor( 200, 200, 210, 120 ) );
439 p.drawEllipse( x - m, y - m, m * 2 + 1, m * 2 + 1 );
443 p.setPen( QColor( 255, 0, 0 ) );
444 p.drawLine( x - m, y + m, x + m, y - m );
445 p.drawLine( x - m, y - m, x + m, y + m );
455 mSelectedFeatureIds.insert( fid );
456 mPreviousSelectedFeatureIds.clear();
463 mSelectedFeatureIds.unite( featureIds );
464 mPreviousSelectedFeatureIds.clear();
471 mSelectedFeatureIds.remove( fid );
472 mPreviousSelectedFeatureIds.clear();
479 mSelectedFeatureIds.subtract( featureIds );
480 mPreviousSelectedFeatureIds.clear();
493 .setFilterRect( rect )
495 .setNoAttributes() );
500 newSelection << feat.
id();
511 std::optional< QgsExpressionContext > defaultContext;
515 context = &defaultContext.value();
534 newSelection << feat.
id();
556 bool matches = exp.
evaluate( context ).toBool();
560 newSelection << feat.
id();
564 newSelection << feat.
id();
583 newSelection = mSelectedFeatureIds + ids;
587 newSelection = mSelectedFeatureIds - ids;
591 newSelection = mSelectedFeatureIds.intersect( ids );
595 QgsFeatureIds deselectedFeatures = mSelectedFeatureIds - newSelection;
596 mSelectedFeatureIds = newSelection;
597 mPreviousSelectedFeatureIds.clear();
605 if ( !intersectingIds.isEmpty() )
607 QgsDebugMsgLevel( QStringLiteral(
"Trying to select and deselect the same item at the same time. Unsure what to do. Selecting dubious items." ), 3 );
610 mSelectedFeatureIds -= deselectIds;
611 mSelectedFeatureIds += selectIds;
612 mPreviousSelectedFeatureIds.clear();
620 ids.subtract( mSelectedFeatureIds );
635 .setFilterRect( rect )
637 .setNoAttributes() );
645 if ( mSelectedFeatureIds.contains( fet.
id() ) )
647 deselectIds << fet.
id();
651 selectIds << fet.
id();
660 if ( mSelectedFeatureIds.isEmpty() )
665 mPreviousSelectedFeatureIds = previous;
670 if ( mPreviousSelectedFeatureIds.isEmpty() || !mSelectedFeatureIds.empty() )
678 return mDataProvider;
683 return mDataProvider;
688 return mTemporalProperties;
693 return mElevationProperties;
705 if (
isValid() && mDataProvider && mDataProvider->
encoding() != encoding )
714 delete mDiagramRenderer;
715 mDiagramRenderer = r;
732 if ( !
isValid() || !
isSpatial() || mSelectedFeatureIds.isEmpty() || !mDataProvider )
744 .setFilterFids( mSelectedFeatureIds )
745 .setNoAttributes() );
758 .setNoAttributes() );
762 if ( mSelectedFeatureIds.contains( fet.
id() ) )
773 if ( retval.
width() == 0.0 || retval.
height() == 0.0 )
782 retval.
set( -1.0, -1.0, 1.0, 1.0 );
791 return mLabelsEnabled &&
static_cast< bool >( mLabeling );
796 mLabelsEnabled = enabled;
801 if ( !mDiagramRenderer || !mDiagramLayerSettings )
804 QList<QgsDiagramSettings> settingList = mDiagramRenderer->
diagramSettings();
805 if ( !settingList.isEmpty() )
807 return settingList.at( 0 ).enabled;
814 if ( !mSymbolFeatureCounted )
817 return mSymbolFeatureCountMap.value( legendKey, -1 );
822 if ( !mSymbolFeatureCounted )
825 return mSymbolFeatureIdMap.value( legendKey,
QgsFeatureIds() );
829 if ( ( mSymbolFeatureCounted || mFeatureCounter ) && !( storeSymbolFids && mSymbolFeatureIdMap.isEmpty() ) )
830 return mFeatureCounter;
832 mSymbolFeatureCountMap.clear();
833 mSymbolFeatureIdMap.clear();
838 return mFeatureCounter;
840 if ( !mDataProvider )
843 return mFeatureCounter;
848 return mFeatureCounter;
851 if ( !mFeatureCounter || ( storeSymbolFids && mSymbolFeatureIdMap.isEmpty() ) )
854 connect( mFeatureCounter, &
QgsTask::taskCompleted,
this, &QgsVectorLayer::onFeatureCounterCompleted, Qt::UniqueConnection );
855 connect( mFeatureCounter, &
QgsTask::taskTerminated,
this, &QgsVectorLayer::onFeatureCounterTerminated, Qt::UniqueConnection );
859 return mFeatureCounter;
865 if ( force || !mReadExtentFromXml || ( mReadExtentFromXml && mXmlExtent.
isNull() ) )
866 mValidExtent =
false;
877 if ( !mDefaultValueOnUpdateFields.isEmpty() )
882 int size = mFields.
size();
883 for (
int idx : std::as_const( mDefaultValueOnUpdateFields ) )
885 if ( idx < 0 || idx >= size )
902 if ( !mValidExtent && mLazyExtent && mReadExtentFromXml && !mXmlExtent.
isNull() )
904 updateExtent( mXmlExtent );
909 if ( !mValidExtent && mLazyExtent && mDataProvider && mDataProvider->
isValid() )
912 updateExtent( mDataProvider->
extent() );
917 QgsDebugMsgLevel( QStringLiteral(
"Extent of layer: %1" ).arg( mExtent.toString() ), 3 );
923 if ( !
isValid() || !mDataProvider )
925 QgsDebugMsgLevel( QStringLiteral(
"invoked with invalid layer or null mDataProvider" ), 3 );
943 if ( mEditBuffer && !mDataProvider->
transaction() )
946 for ( QgsFeatureMap::const_iterator it = addedFeatures.constBegin(); it != addedFeatures.constEnd(); ++it )
948 if ( it->hasGeometry() )
959 .setNoAttributes() );
978 updateExtent( rect );
994 if ( !
isValid() || !mDataProvider )
996 QgsDebugMsgLevel( QStringLiteral(
"invoked with invalid layer or null mDataProvider" ), 3 );
997 return customProperty( QStringLiteral(
"storedSubsetString" ) ).toString();
1004 if ( !
isValid() || !mDataProvider )
1006 QgsDebugMsgLevel( QStringLiteral(
"invoked with invalid layer or null mDataProvider or while editing" ), 3 );
1010 else if ( mEditBuffer )
1039 double maximumSimplificationScale = mSimplifyMethod.
maximumScale();
1042 return !( maximumSimplificationScale > 1 && renderContext.
rendererScale() <= maximumSimplificationScale );
1049 return mConditionalStyles;
1054 if ( !
isValid() || !mDataProvider )
1072 if ( !
isValid() || !mEditBuffer || !mDataProvider )
1076 if ( mGeometryOptions->isActive() )
1079 mGeometryOptions->apply( geom );
1083 bool success = mEditBuffer->
addFeature( feature );
1090 success = mJoinBuffer->
addFeature( feature );
1098 if ( !mEditBuffer || !mDataProvider )
1104 if ( currentFeature.
isValid() )
1106 bool hasChanged =
false;
1107 bool hasError =
false;
1119 QgsDebugMsgLevel( QStringLiteral(
"geometry of feature %1 could not be changed." ).arg( updatedFeature.
id() ), 3 );
1126 for (
int attr = 0; attr < fa.count(); ++attr )
1136 QgsDebugMsgLevel( QStringLiteral(
"attribute %1 of feature %2 could not be changed." ).arg( attr ).arg( updatedFeature.
id() ), 3 );
1141 if ( hasChanged && !mDefaultValueOnUpdateFields.isEmpty() && !skipDefaultValues )
1142 updateDefaultValues( updatedFeature.
id(), updatedFeature );
1148 QgsDebugMsgLevel( QStringLiteral(
"feature %1 could not be retrieved" ).arg( updatedFeature.
id() ), 3 );
1156 if ( !
isValid() || !mEditBuffer || !mDataProvider )
1160 bool result = utils.
insertVertex( x, y, atFeatureId, beforeVertex );
1169 if ( !
isValid() || !mEditBuffer || !mDataProvider )
1173 bool result = utils.
insertVertex( point, atFeatureId, beforeVertex );
1182 if ( !
isValid() || !mEditBuffer || !mDataProvider )
1186 bool result = utils.
moveVertex( x, y, atFeatureId, atVertex );
1195 if ( !
isValid() || !mEditBuffer || !mDataProvider )
1199 bool result = utils.
moveVertex( p, atFeatureId, atVertex );
1208 if ( !
isValid() || !mEditBuffer || !mDataProvider )
1233 int count = mSelectedFeatureIds.size();
1246 *deletedCount = deleted;
1249 return deleted == count;
1252 static const QgsPointSequence vectorPointXY2pointSequence(
const QVector<QgsPointXY> &points )
1255 pts.reserve( points.size() );
1256 QVector<QgsPointXY>::const_iterator it = points.constBegin();
1257 while ( it != points.constEnd() )
1266 return addRing( vectorPointXY2pointSequence( ring ), featureId );
1271 if ( !
isValid() || !mEditBuffer || !mDataProvider )
1278 if ( !mSelectedFeatureIds.isEmpty() )
1280 result = utils.
addRing( ring, mSelectedFeatureIds, featureId );
1294 if ( !
isValid() || !mEditBuffer || !mDataProvider )
1315 if ( !mSelectedFeatureIds.isEmpty() )
1317 result = utils.
addRing(
static_cast< QgsCurve *
>( ring->
clone() ), mSelectedFeatureIds, featureId );
1333 pts.reserve( points.size() );
1334 for ( QList<QgsPointXY>::const_iterator it = points.constBegin(); it != points.constEnd() ; ++it )
1341 #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
1344 return addPart( vectorPointXY2pointSequence( points ) );
1350 if ( !
isValid() || !mEditBuffer || !mDataProvider )
1355 if ( mSelectedFeatureIds.empty() )
1360 else if ( mSelectedFeatureIds.size() > 1 )
1376 if ( !
isValid() || !mEditBuffer || !mDataProvider )
1381 if ( mSelectedFeatureIds.empty() )
1386 else if ( mSelectedFeatureIds.size() > 1 )
1403 if ( !
isValid() || !mEditBuffer || !mDataProvider )
1416 return splitParts( vectorPointXY2pointSequence( splitLine ), topologicalEditing );
1421 if ( !
isValid() || !mEditBuffer || !mDataProvider )
1425 return utils.
splitParts( splitLine, topologicalEditing );
1430 return splitFeatures( vectorPointXY2pointSequence( splitLine ), topologicalEditing );
1437 bool preserveCircular =
false;
1438 return splitFeatures( &splitLineString, topologyTestPoints, preserveCircular, topologicalEditing );
1443 if ( !
isValid() || !mEditBuffer || !mDataProvider )
1447 return utils.
splitFeatures( curve, topologyTestPoints, preserveCircular, topologicalEditing );
1452 if ( !
isValid() || !mEditBuffer || !mDataProvider )
1466 if ( !
isValid() || !mEditBuffer || !mDataProvider )
1475 if ( !
mValid || !mEditBuffer || !mDataProvider )
1496 if ( !
isValid() || !mDataProvider )
1528 if ( mDataProvider )
1540 if ( !mRenderer->
accept( visitor ) )
1544 if ( !mLabeling->
accept( visitor ) )
1555 QDomNode pkeyNode = layer_node.namedItem( QStringLiteral(
"provider" ) );
1557 if ( pkeyNode.isNull() )
1563 QDomElement pkeyElt = pkeyNode.toElement();
1573 else if (
mDataSource.contains( QLatin1String(
"dbname=" ) ) )
1583 QgsDataProvider::ReadFlags
flags;
1594 const QDomElement elem = layer_node.toElement();
1597 if ( elem.hasAttribute( QStringLiteral(
"wkbType" ) ) )
1598 mWkbType =
qgsEnumKeyToValue( elem.attribute( QStringLiteral(
"wkbType" ) ), mWkbType );
1601 QDomElement pkeyElem = pkeyNode.toElement();
1602 if ( !pkeyElem.isNull() )
1604 QString encodingString = pkeyElem.attribute( QStringLiteral(
"encoding" ) );
1605 if ( mDataProvider && !encodingString.isEmpty() )
1612 mJoinBuffer->
readXml( layer_node );
1617 mSetLegendFromStyle =
false;
1627 QDomNode depsNode = layer_node.namedItem( QStringLiteral(
"dataDependencies" ) );
1628 QDomNodeList depsNodes = depsNode.childNodes();
1629 QSet<QgsMapLayerDependency> sources;
1630 for (
int i = 0; i < depsNodes.count(); i++ )
1632 QString
source = depsNodes.at( i ).toElement().attribute( QStringLiteral(
"id" ) );
1637 if ( !mSetLegendFromStyle )
1643 mReadExtentFromXml =
true;
1645 if ( mReadExtentFromXml )
1647 const QDomNode extentNode = layer_node.namedItem( QStringLiteral(
"extent" ) );
1648 if ( !extentNode.isNull() )
1655 const QDomNode asNode = layer_node.namedItem( QStringLiteral(
"auxiliaryLayer" ) );
1656 const QDomElement asElem = asNode.toElement();
1657 if ( !asElem.isNull() )
1659 mAuxiliaryLayerKey = asElem.attribute( QStringLiteral(
"key" ) );
1663 mServerProperties->readXml( layer_node );
1670 void QgsVectorLayer::setDataSourcePrivate(
const QString &dataSource,
const QString &baseName,
const QString &provider,
1677 setDataProvider( provider, options,
flags );
1687 bool loadDefaultStyleFlag =
false;
1690 loadDefaultStyleFlag =
true;
1696 std::unique_ptr< QgsScopedRuntimeProfile > profile;
1698 profile = std::make_unique< QgsScopedRuntimeProfile >( tr(
"Load layer style" ), QStringLiteral(
"projectload" ) );
1700 bool defaultLoadedFlag =
false;
1708 mSetLegendFromStyle =
false;
1713 if ( !defaultLoadedFlag && loadDefaultStyleFlag )
1721 std::unique_ptr< QgsFeatureRenderer > defaultRenderer( mDataProvider->
createRenderer() );
1722 if ( defaultRenderer )
1724 defaultLoadedFlag =
true;
1730 if ( !defaultLoadedFlag &&
isSpatial() )
1736 if ( !mSetLegendFromStyle )
1741 std::unique_ptr< QgsAbstractVectorLayerLabeling > defaultLabeling( mDataProvider->
createLabeling() );
1742 if ( defaultLabeling )
1749 styleChangedSignalBlocker.release();
1764 std::unique_ptr< QgsFeatureRenderer > defaultRenderer( mDataProvider->
createRenderer() );
1765 if ( defaultRenderer )
1779 delete mDataProvider;
1786 if ( provider.compare( QLatin1String(
"postgres" ) ) == 0 )
1788 const QString checkUnicityKey { QStringLiteral(
"checkPrimaryKeyUnicity" ) };
1790 if ( ! uri.hasParam( checkUnicityKey ) )
1792 uri.setParam( checkUnicityKey, mReadExtentFromXml ?
"0" :
"1" );
1797 std::unique_ptr< QgsScopedRuntimeProfile > profile;
1799 profile = std::make_unique< QgsScopedRuntimeProfile >( tr(
"Create %1 provider" ).arg( provider ), QStringLiteral(
"projectload" ) );
1802 if ( !mDataProvider )
1809 mDataProvider->setParent(
this );
1812 QgsDebugMsgLevel( QStringLiteral(
"Instantiated the data provider plugin" ), 2 );
1822 profile->switchTask( tr(
"Read layer metadata" ) );
1829 newMetadata.
combine( &mMetadata );
1832 QgsDebugMsgLevel( QStringLiteral(
"Set Data provider QgsLayerMetadata identifier[%1]" ).arg(
metadata().identifier() ), 4 );
1839 mWkbType = mDataProvider->
wkbType();
1858 profile->switchTask( tr(
"Read layer fields" ) );
1869 const QRegularExpression reg( R
"lit("[^"]+"\."([^"] + )"( \([^)]+\))?)lit" );
1870 const QRegularExpressionMatch match = reg.match(
name() );
1871 if ( match.hasMatch() )
1873 QStringList stuff = match.capturedTexts();
1874 QString lName = stuff[1];
1878 QMap<QString, QgsMapLayer *>::const_iterator it;
1879 for ( it = layers.constBegin(); it != layers.constEnd() && ( *it )->name() != lName; ++it )
1882 if ( it != layers.constEnd() && stuff.size() > 2 )
1884 lName +=
'.' + stuff[2].mid( 2, stuff[2].length() - 3 );
1887 if ( !lName.isEmpty() )
1897 else if ( provider == QLatin1String(
"ogr" ) )
1901 if (
mDataSource.right( 10 ) == QLatin1String(
"|layerid=0" ) )
1904 else if ( provider == QLatin1String(
"memory" ) )
1909 else if ( provider == QLatin1String(
"hana" ) )
1926 QDomDocument &document,
1931 QDomElement mapLayerNode = layer_node.toElement();
1933 if ( mapLayerNode.isNull() || (
"maplayer" != mapLayerNode.nodeName() ) )
1946 if ( mDataProvider )
1948 QDomElement provider = document.createElement( QStringLiteral(
"provider" ) );
1949 provider.setAttribute( QStringLiteral(
"encoding" ), mDataProvider->
encoding() );
1950 QDomText providerText = document.createTextNode(
providerType() );
1951 provider.appendChild( providerText );
1952 layer_node.appendChild( provider );
1956 mJoinBuffer->
writeXml( layer_node, document );
1959 QDomElement dependenciesElement = document.createElement( QStringLiteral(
"layerDependencies" ) );
1965 QDomElement depElem = document.createElement( QStringLiteral(
"layer" ) );
1966 depElem.setAttribute( QStringLiteral(
"id" ), dep.layerId() );
1967 dependenciesElement.appendChild( depElem );
1969 layer_node.appendChild( dependenciesElement );
1972 QDomElement dataDependenciesElement = document.createElement( QStringLiteral(
"dataDependencies" ) );
1977 QDomElement depElem = document.createElement( QStringLiteral(
"layer" ) );
1978 depElem.setAttribute( QStringLiteral(
"id" ), dep.layerId() );
1979 dataDependenciesElement.appendChild( depElem );
1981 layer_node.appendChild( dataDependenciesElement );
1984 mExpressionFieldBuffer->
writeXml( layer_node, document );
1989 QDomElement asElem = document.createElement( QStringLiteral(
"auxiliaryLayer" ) );
1990 if ( mAuxiliaryLayer )
1992 const QString pkField = mAuxiliaryLayer->joinInfo().targetFieldName();
1993 asElem.setAttribute( QStringLiteral(
"key" ), pkField );
1995 layer_node.appendChild( asElem );
1998 mServerProperties->writeXml( layer_node, document );
2002 return writeSymbology( layer_node, document, errorMsg, context );
2019 QStringList theURIParts = src.split(
'|' );
2021 src = theURIParts.join( QLatin1Char(
'|' ) );
2025 QStringList theURIParts = src.split(
'?' );
2027 src = theURIParts.join( QLatin1Char(
'?' ) );
2029 else if (
providerType() == QLatin1String(
"delimitedtext" ) )
2031 QUrl urlSource = QUrl::fromEncoded( src.toLatin1() );
2033 urlDest.setQuery( urlSource.query() );
2034 src = QString::fromLatin1( urlDest.toEncoded() );
2036 else if (
providerType() == QLatin1String(
"memory" ) )
2041 else if (
providerType() == QLatin1String(
"virtual" ) )
2043 QUrl urlSource = QUrl::fromEncoded( src.toLatin1() );
2044 QStringList theURIParts;
2046 QUrlQuery query = QUrlQuery( urlSource.query() );
2047 QList<QPair<QString, QString> > queryItems = query.queryItems();
2049 for (
int i = 0; i < queryItems.size(); i++ )
2051 QString key = queryItems.at( i ).first;
2052 QString value = queryItems.at( i ).second;
2053 if ( key == QLatin1String(
"layer" ) )
2056 theURIParts = value.split(
':' );
2057 theURIParts[1] = QUrl::fromPercentEncoding( theURIParts[1].toUtf8() );
2059 if ( theURIParts[0] == QLatin1String(
"delimitedtext" ) )
2061 QUrl urlSource = QUrl( theURIParts[1] );
2063 urlDest.setQuery( urlSource.query() );
2064 theURIParts[1] = QUrl::toPercentEncoding( urlDest.toString(), QByteArray(
"" ), QByteArray(
":" ) );
2069 theURIParts[1] = QUrl::toPercentEncoding( theURIParts[1] );
2072 queryItems[i].second = theURIParts.join( QLatin1Char(
':' ) ) ;
2076 query.setQueryItems( queryItems );
2078 QUrl urlDest = QUrl( urlSource );
2079 urlDest.setQuery( query.query() );
2080 src = QString::fromLatin1( urlDest.toEncoded() );
2094 if ( provider == QLatin1String(
"spatialite" ) )
2100 else if ( provider == QLatin1String(
"ogr" ) )
2102 QStringList theURIParts = src.split(
'|' );
2104 src = theURIParts.join( QLatin1Char(
'|' ) );
2106 else if ( provider == QLatin1String(
"gpx" ) )
2108 QStringList theURIParts = src.split(
'?' );
2110 src = theURIParts.join( QLatin1Char(
'?' ) );
2112 else if ( provider == QLatin1String(
"delimitedtext" ) )
2114 QUrl urlSource = QUrl::fromEncoded( src.toLatin1() );
2116 if ( !src.startsWith( QLatin1String(
"file:" ) ) )
2118 QUrl file = QUrl::fromLocalFile( src.left( src.indexOf(
'?' ) ) );
2119 urlSource.setScheme( QStringLiteral(
"file" ) );
2120 urlSource.setPath( file.path() );
2123 QUrl urlDest = QUrl::fromLocalFile( context.
pathResolver().
readPath( urlSource.toLocalFile() ) );
2124 urlDest.setQuery( urlSource.query() );
2125 src = QString::fromLatin1( urlDest.toEncoded() );
2127 else if ( provider == QLatin1String(
"virtual" ) )
2129 QUrl urlSource = QUrl::fromEncoded( src.toLatin1() );
2130 QStringList theURIParts;
2132 QUrlQuery query = QUrlQuery( urlSource.query() );
2133 QList<QPair<QString, QString> > queryItems = query.queryItems();
2135 for (
int i = 0; i < queryItems.size(); i++ )
2137 QString key = queryItems.at( i ).first;
2138 QString value = queryItems.at( i ).second;
2139 if ( key == QLatin1String(
"layer" ) )
2142 theURIParts = value.split(
':' );
2143 theURIParts[1] = QUrl::fromPercentEncoding( theURIParts[1].toUtf8() );
2145 if ( theURIParts[0] == QLatin1String(
"delimitedtext" ) )
2147 QUrl urlSource = QUrl( theURIParts[1] );
2149 if ( !theURIParts[1].startsWith( QLatin1String(
"file:" ) ) )
2151 QUrl file = QUrl::fromLocalFile( theURIParts[1].left( theURIParts[1].indexOf(
'?' ) ) );
2152 urlSource.setScheme( QStringLiteral(
"file" ) );
2153 urlSource.setPath( file.path() );
2156 QUrl urlDest = QUrl::fromLocalFile( context.
pathResolver().
readPath( urlSource.toLocalFile() ) );
2157 urlDest.setQuery( urlSource.query() );
2159 theURIParts[1] = urlDest.toString();
2166 theURIParts[1] = QUrl::toPercentEncoding( theURIParts[1] );
2167 queryItems[i].second = theURIParts.join( QLatin1Char(
':' ) ) ;
2171 query.setQueryItems( queryItems );
2173 QUrl urlDest = QUrl( urlSource );
2174 urlDest.setQuery( query.query() );
2175 src = QString::fromLatin1( urlDest.toEncoded() );
2197 if ( categories.testFlag(
Fields ) )
2199 if ( !mExpressionFieldBuffer )
2201 mExpressionFieldBuffer->
readXml( layerNode );
2213 QDomNodeList referencedLayersNodeList = layerNode.toElement().elementsByTagName( QStringLiteral(
"referencedLayers" ) );
2214 if ( referencedLayersNodeList.size() > 0 )
2216 const QDomNodeList relationNodes { referencedLayersNodeList.at( 0 ).childNodes() };
2217 for (
int i = 0; i < relationNodes.length(); ++i )
2219 const QDomElement relationElement = relationNodes.at( i ).toElement();
2226 QDomNodeList referencingLayersNodeList = layerNode.toElement().elementsByTagName( QStringLiteral(
"referencingLayers" ) );
2227 if ( referencingLayersNodeList.size() > 0 )
2229 const QDomNodeList relationNodes { referencingLayersNodeList.at( 0 ).childNodes() };
2230 for (
int i = 0; i < relationNodes.length(); ++i )
2232 const QDomElement relationElement = relationNodes.at( i ).toElement();
2238 QDomElement layerElement = layerNode.toElement();
2242 readStyle( layerNode, errorMessage, context, categories );
2244 if ( categories.testFlag(
MapTips ) )
2245 mMapTipTemplate = layerNode.namedItem( QStringLiteral(
"mapTip" ) ).toElement().text();
2248 mDisplayExpression = layerNode.namedItem( QStringLiteral(
"previewExpression" ) ).toElement().text();
2251 QString
displayField = layerNode.namedItem( QStringLiteral(
"displayfield" ) ).toElement().text();
2255 if ( mMapTipTemplate.isEmpty() && categories.testFlag(
MapTips ) )
2265 if ( categories.testFlag(
Actions ) )
2266 mActions->
readXml( layerNode );
2268 if ( categories.testFlag(
Fields ) )
2273 QDomNode aliasesNode = layerNode.namedItem( QStringLiteral(
"aliases" ) );
2274 if ( !aliasesNode.isNull() )
2276 QDomElement aliasElem;
2278 QDomNodeList aliasNodeList = aliasesNode.toElement().elementsByTagName( QStringLiteral(
"alias" ) );
2279 for (
int i = 0; i < aliasNodeList.size(); ++i )
2281 aliasElem = aliasNodeList.at( i ).toElement();
2284 if ( aliasElem.hasAttribute( QStringLiteral(
"field" ) ) )
2286 field = aliasElem.attribute( QStringLiteral(
"field" ) );
2290 int index = aliasElem.attribute( QStringLiteral(
"index" ) ).toInt();
2292 if ( index >= 0 && index <
fields().count() )
2298 if ( !aliasElem.attribute( QStringLiteral(
"name" ) ).isEmpty() )
2301 alias = context.
projectTranslator()->
translate( QStringLiteral(
"project:layers:%1:fieldaliases" ).arg( layerNode.namedItem( QStringLiteral(
"id" ) ).toElement().text() ), aliasElem.attribute( QStringLiteral(
"name" ) ) );
2302 QgsDebugMsgLevel(
"context" + QStringLiteral(
"project:layers:%1:fieldaliases" ).arg( layerNode.namedItem( QStringLiteral(
"id" ) ).toElement().text() ) +
" source " + aliasElem.attribute( QStringLiteral(
"name" ) ), 3 );
2307 alias = context.
projectTranslator()->
translate( QStringLiteral(
"project:layers:%1:fieldaliases" ).arg( layerNode.namedItem( QStringLiteral(
"id" ) ).toElement().text() ),
field );
2308 QgsDebugMsgLevel(
"context" + QStringLiteral(
"project:layers:%1:fieldaliases" ).arg( layerNode.namedItem( QStringLiteral(
"id" ) ).toElement().text() ) +
" source " +
field, 3 );
2310 if ( alias == aliasElem.attribute( QStringLiteral(
"field" ) ) )
2314 QgsDebugMsgLevel(
"field " +
field +
" origalias " + aliasElem.attribute( QStringLiteral(
"name" ) ) +
" trans " + alias, 3 );
2315 mAttributeAliasMap.insert(
field, alias );
2320 mDefaultExpressionMap.clear();
2321 QDomNode defaultsNode = layerNode.namedItem( QStringLiteral(
"defaults" ) );
2322 if ( !defaultsNode.isNull() )
2324 QDomNodeList defaultNodeList = defaultsNode.toElement().elementsByTagName( QStringLiteral(
"default" ) );
2325 for (
int i = 0; i < defaultNodeList.size(); ++i )
2327 QDomElement defaultElem = defaultNodeList.at( i ).toElement();
2329 QString
field = defaultElem.attribute( QStringLiteral(
"field" ), QString() );
2330 QString expression = defaultElem.attribute( QStringLiteral(
"expression" ), QString() );
2331 bool applyOnUpdate = defaultElem.attribute( QStringLiteral(
"applyOnUpdate" ), QStringLiteral(
"0" ) ) == QLatin1String(
"1" );
2332 if (
field.isEmpty() || expression.isEmpty() )
2340 mFieldConstraints.clear();
2341 mFieldConstraintStrength.clear();
2342 QDomNode constraintsNode = layerNode.namedItem( QStringLiteral(
"constraints" ) );
2343 if ( !constraintsNode.isNull() )
2345 QDomNodeList constraintNodeList = constraintsNode.toElement().elementsByTagName( QStringLiteral(
"constraint" ) );
2346 for (
int i = 0; i < constraintNodeList.size(); ++i )
2348 QDomElement constraintElem = constraintNodeList.at( i ).toElement();
2350 QString
field = constraintElem.attribute( QStringLiteral(
"field" ), QString() );
2351 int constraints = constraintElem.attribute( QStringLiteral(
"constraints" ), QStringLiteral(
"0" ) ).toInt();
2352 if (
field.isEmpty() || constraints == 0 )
2355 mFieldConstraints.insert(
field,
static_cast< QgsFieldConstraints::Constraints
>( constraints ) );
2357 int uniqueStrength = constraintElem.attribute( QStringLiteral(
"unique_strength" ), QStringLiteral(
"1" ) ).toInt();
2358 int notNullStrength = constraintElem.attribute( QStringLiteral(
"notnull_strength" ), QStringLiteral(
"1" ) ).toInt();
2359 int expStrength = constraintElem.attribute( QStringLiteral(
"exp_strength" ), QStringLiteral(
"1" ) ).toInt();
2366 mFieldConstraintExpressions.clear();
2367 QDomNode constraintExpressionsNode = layerNode.namedItem( QStringLiteral(
"constraintExpressions" ) );
2368 if ( !constraintExpressionsNode.isNull() )
2370 QDomNodeList constraintNodeList = constraintExpressionsNode.toElement().elementsByTagName( QStringLiteral(
"constraint" ) );
2371 for (
int i = 0; i < constraintNodeList.size(); ++i )
2373 QDomElement constraintElem = constraintNodeList.at( i ).toElement();
2375 QString
field = constraintElem.attribute( QStringLiteral(
"field" ), QString() );
2376 QString exp = constraintElem.attribute( QStringLiteral(
"exp" ), QString() );
2377 QString desc = constraintElem.attribute( QStringLiteral(
"desc" ), QString() );
2378 if (
field.isEmpty() || exp.isEmpty() )
2381 mFieldConstraintExpressions.insert(
field, qMakePair( exp, desc ) );
2389 if ( categories.testFlag(
Fields ) || categories.testFlag(
Forms ) )
2393 QDomElement widgetsElem = layerNode.namedItem( QStringLiteral(
"fieldConfiguration" ) ).toElement();
2394 QDomNodeList fieldConfigurationElementList = widgetsElem.elementsByTagName( QStringLiteral(
"field" ) );
2395 for (
int i = 0; i < fieldConfigurationElementList.size(); ++i )
2397 const QDomElement fieldConfigElement = fieldConfigurationElementList.at( i ).toElement();
2398 const QDomElement fieldWidgetElement = fieldConfigElement.elementsByTagName( QStringLiteral(
"editWidget" ) ).at( 0 ).toElement();
2400 QString fieldName = fieldConfigElement.attribute( QStringLiteral(
"name" ) );
2402 if ( categories.testFlag(
Fields ) )
2406 if ( categories.testFlag(
Forms ) )
2408 const QString widgetType = fieldWidgetElement.attribute( QStringLiteral(
"type" ) );
2409 const QDomElement cfgElem = fieldConfigElement.elementsByTagName( QStringLiteral(
"config" ) ).at( 0 ).toElement();
2410 const QDomElement optionsElem = cfgElem.childNodes().at( 0 ).toElement();
2412 if ( widgetType == QLatin1String(
"ValueRelation" ) )
2414 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() );
2417 mFieldWidgetSetups[fieldName] = setup;
2424 if ( categories.testFlag(
Fields ) )
2426 const QList<QPair<QString, QgsField::ConfigurationFlag>> legacyConfig
2431 for (
const auto &config : legacyConfig )
2433 QDomNode excludeNode = layerNode.namedItem( config.first );
2434 if ( !excludeNode.isNull() )
2436 QDomNodeList attributeNodeList = excludeNode.toElement().elementsByTagName( QStringLiteral(
"attribute" ) );
2437 for (
int i = 0; i < attributeNodeList.size(); ++i )
2439 QString fieldName = attributeNodeList.at( i ).toElement().text();
2440 if ( !mFieldConfigurationFlags.contains( fieldName ) )
2441 mFieldConfigurationFlags[fieldName] = config.second;
2443 mFieldConfigurationFlags[fieldName].setFlag( config.second,
true );
2450 mGeometryOptions->readXml( layerNode.namedItem( QStringLiteral(
"geometryOptions" ) ) );
2452 if ( categories.testFlag(
Forms ) )
2453 mEditFormConfig.
readXml( layerNode, context );
2457 mAttributeTableConfig.
readXml( layerNode );
2458 mConditionalStyles->
readXml( layerNode, context );
2459 mStoredExpressionManager->
readXml( layerNode );
2465 QDomElement mapLayerNode = layerNode.toElement();
2467 && mapLayerNode.attribute( QStringLiteral(
"readOnly" ), QStringLiteral(
"0" ) ).toInt() == 1 )
2472 if ( categories.testFlag(
Legend ) )
2476 const QDomElement legendElem = layerNode.firstChildElement( QStringLiteral(
"legend" ) );
2477 if ( !legendElem.isNull() )
2482 mSetLegendFromStyle =
true;
2510 if ( !rendererElement.isNull() )
2530 if ( categories.testFlag(
Labeling ) )
2534 QDomElement labelingElement = node.firstChildElement( QStringLiteral(
"labeling" ) );
2536 if ( labelingElement.isNull() ||
2537 ( labelingElement.attribute( QStringLiteral(
"type" ) ) == QLatin1String(
"simple" ) && labelingElement.firstChildElement( QStringLiteral(
"settings" ) ).isNull() ) )
2545 labeling = readLabelingFromCustomProperties();
2553 if ( node.toElement().hasAttribute( QStringLiteral(
"labelsEnabled" ) ) )
2554 mLabelsEnabled = node.toElement().attribute( QStringLiteral(
"labelsEnabled" ) ).toInt();
2556 mLabelsEnabled =
true;
2562 QDomNode blendModeNode = node.namedItem( QStringLiteral(
"blendMode" ) );
2563 if ( !blendModeNode.isNull() )
2565 QDomElement e = blendModeNode.toElement();
2570 QDomNode featureBlendModeNode = node.namedItem( QStringLiteral(
"featureBlendMode" ) );
2571 if ( !featureBlendModeNode.isNull() )
2573 QDomElement e = featureBlendModeNode.toElement();
2581 QDomNode layerTransparencyNode = node.namedItem( QStringLiteral(
"layerTransparency" ) );
2582 if ( !layerTransparencyNode.isNull() )
2584 QDomElement e = layerTransparencyNode.toElement();
2585 setOpacity( 1.0 - e.text().toInt() / 100.0 );
2587 QDomNode layerOpacityNode = node.namedItem( QStringLiteral(
"layerOpacity" ) );
2588 if ( !layerOpacityNode.isNull() )
2590 QDomElement e = layerOpacityNode.toElement();
2594 const bool hasScaleBasedVisibiliy { node.attributes().namedItem( QStringLiteral(
"hasScaleBasedVisibilityFlag" ) ).nodeValue() ==
'1' };
2597 const double maxScale { node.attributes().namedItem( QStringLiteral(
"maxScale" ) ).nodeValue().toDouble( &ok ) };
2602 const double minScale { node.attributes().namedItem( QStringLiteral(
"minScale" ) ).nodeValue().toDouble( &ok ) };
2608 QDomElement e = node.toElement();
2611 mSimplifyMethod.
setSimplifyHints(
static_cast< QgsVectorSimplifyMethod::SimplifyHints
>( e.attribute( QStringLiteral(
"simplifyDrawingHints" ), QStringLiteral(
"1" ) ).toInt() ) );
2613 mSimplifyMethod.
setThreshold( e.attribute( QStringLiteral(
"simplifyDrawingTol" ), QStringLiteral(
"1" ) ).toFloat() );
2614 mSimplifyMethod.
setForceLocalOptimization( e.attribute( QStringLiteral(
"simplifyLocal" ), QStringLiteral(
"1" ) ).toInt() );
2615 mSimplifyMethod.
setMaximumScale( e.attribute( QStringLiteral(
"simplifyMaxScale" ), QStringLiteral(
"1" ) ).toFloat() );
2618 mRenderer->
setReferenceScale( e.attribute( QStringLiteral(
"symbologyReferenceScale" ), QStringLiteral(
"-1" ) ).toDouble() );
2622 if ( categories.testFlag(
Diagrams ) )
2626 delete mDiagramRenderer;
2627 mDiagramRenderer =
nullptr;
2628 QDomElement singleCatDiagramElem = node.firstChildElement( QStringLiteral(
"SingleCategoryDiagramRenderer" ) );
2629 if ( !singleCatDiagramElem.isNull() )
2632 mDiagramRenderer->
readXml( singleCatDiagramElem, context );
2634 QDomElement linearDiagramElem = node.firstChildElement( QStringLiteral(
"LinearlyInterpolatedDiagramRenderer" ) );
2635 if ( !linearDiagramElem.isNull() )
2637 if ( linearDiagramElem.hasAttribute( QStringLiteral(
"classificationAttribute" ) ) )
2640 int idx = linearDiagramElem.attribute( QStringLiteral(
"classificationAttribute" ) ).toInt();
2641 if ( idx >= 0 && idx < mFields.
count() )
2642 linearDiagramElem.setAttribute( QStringLiteral(
"classificationField" ), mFields.
at( idx ).
name() );
2646 mDiagramRenderer->
readXml( linearDiagramElem, context );
2649 if ( mDiagramRenderer )
2651 QDomElement diagramSettingsElem = node.firstChildElement( QStringLiteral(
"DiagramLayerSettings" ) );
2652 if ( !diagramSettingsElem.isNull() )
2654 bool oldXPos = diagramSettingsElem.hasAttribute( QStringLiteral(
"xPosColumn" ) );
2655 bool oldYPos = diagramSettingsElem.hasAttribute( QStringLiteral(
"yPosColumn" ) );
2656 bool oldShow = diagramSettingsElem.hasAttribute( QStringLiteral(
"showColumn" ) );
2657 if ( oldXPos || oldYPos || oldShow )
2663 int xPosColumn = diagramSettingsElem.attribute( QStringLiteral(
"xPosColumn" ) ).toInt();
2664 if ( xPosColumn >= 0 && xPosColumn < mFields.
count() )
2669 int yPosColumn = diagramSettingsElem.attribute( QStringLiteral(
"yPosColumn" ) ).toInt();
2670 if ( yPosColumn >= 0 && yPosColumn < mFields.
count() )
2675 int showColumn = diagramSettingsElem.attribute( QStringLiteral(
"showColumn" ) ).toInt();
2676 if ( showColumn >= 0 && showColumn < mFields.
count() )
2679 QDomElement propertiesElem = diagramSettingsElem.ownerDocument().createElement( QStringLiteral(
"properties" ) );
2686 ddp.
writeXml( propertiesElem, defs );
2687 diagramSettingsElem.appendChild( propertiesElem );
2690 delete mDiagramLayerSettings;
2692 mDiagramLayerSettings->
readXml( diagramSettingsElem );
2698 styleChangedSignalBlocker.release();
2708 QDomElement layerElement = node.toElement();
2711 ( void )
writeStyle( node, doc, errorMessage, context, categories );
2714 mGeometryOptions->writeXml( node );
2719 if ( !legendElement.isNull() )
2720 node.appendChild( legendElement );
2727 QDomElement referencedLayersElement = doc.createElement( QStringLiteral(
"referencedLayers" ) );
2728 node.appendChild( referencedLayersElement );
2731 for (
const auto &rel : constReferencingRelations )
2740 QDomElement referencingLayersElement = doc.createElement( QStringLiteral(
"referencingLayers" ) );
2741 node.appendChild( referencedLayersElement );
2744 for (
const auto &rel : constReferencedRelations )
2755 if ( categories.testFlag(
Fields ) || categories.testFlag(
Forms ) )
2757 QDomElement fieldConfigurationElement;
2759 fieldConfigurationElement = doc.createElement( QStringLiteral(
"fieldConfiguration" ) );
2760 node.appendChild( fieldConfigurationElement );
2764 QDomElement fieldElement = doc.createElement( QStringLiteral(
"field" ) );
2765 fieldElement.setAttribute( QStringLiteral(
"name" ),
field.
name() );
2766 fieldConfigurationElement.appendChild( fieldElement );
2768 if ( categories.testFlag(
Fields ) )
2773 if ( categories.testFlag(
Forms ) )
2778 QDomElement editWidgetElement = doc.createElement( QStringLiteral(
"editWidget" ) );
2779 fieldElement.appendChild( editWidgetElement );
2781 QDomElement editWidgetConfigElement = doc.createElement( QStringLiteral(
"config" ) );
2784 editWidgetElement.appendChild( editWidgetConfigElement );
2790 if ( categories.testFlag(
Fields ) )
2793 QDomElement aliasElem = doc.createElement( QStringLiteral(
"aliases" ) );
2796 QDomElement aliasEntryElem = doc.createElement( QStringLiteral(
"alias" ) );
2797 aliasEntryElem.setAttribute( QStringLiteral(
"field" ),
field.
name() );
2799 aliasEntryElem.setAttribute( QStringLiteral(
"name" ),
field.
alias() );
2800 aliasElem.appendChild( aliasEntryElem );
2802 node.appendChild( aliasElem );
2805 QDomElement defaultsElem = doc.createElement( QStringLiteral(
"defaults" ) );
2808 QDomElement defaultElem = doc.createElement( QStringLiteral(
"default" ) );
2809 defaultElem.setAttribute( QStringLiteral(
"field" ),
field.
name() );
2812 defaultsElem.appendChild( defaultElem );
2814 node.appendChild( defaultsElem );
2817 QDomElement constraintsElem = doc.createElement( QStringLiteral(
"constraints" ) );
2820 QDomElement constraintElem = doc.createElement( QStringLiteral(
"constraint" ) );
2821 constraintElem.setAttribute( QStringLiteral(
"field" ),
field.
name() );
2826 constraintsElem.appendChild( constraintElem );
2828 node.appendChild( constraintsElem );
2831 QDomElement constraintExpressionsElem = doc.createElement( QStringLiteral(
"constraintExpressions" ) );
2834 QDomElement constraintExpressionElem = doc.createElement( QStringLiteral(
"constraint" ) );
2835 constraintExpressionElem.setAttribute( QStringLiteral(
"field" ),
field.
name() );
2838 constraintExpressionsElem.appendChild( constraintExpressionElem );
2840 node.appendChild( constraintExpressionsElem );
2843 if ( !mExpressionFieldBuffer )
2851 mExpressionFieldBuffer->
writeXml( node, doc );
2856 if ( categories.testFlag(
Actions ) )
2861 mAttributeTableConfig.
writeXml( node );
2862 mConditionalStyles->
writeXml( node, doc, context );
2863 mStoredExpressionManager->
writeXml( node );
2866 if ( categories.testFlag(
Forms ) )
2867 mEditFormConfig.
writeXml( node, context );
2871 node.toElement().setAttribute( QStringLiteral(
"readOnly" ), mReadOnly );
2876 QDomElement prevExpElem = doc.createElement( QStringLiteral(
"previewExpression" ) );
2877 QDomText prevExpText = doc.createTextNode( mDisplayExpression );
2878 prevExpElem.appendChild( prevExpText );
2879 node.appendChild( prevExpElem );
2883 if ( categories.testFlag(
MapTips ) )
2885 QDomElement mapTipElem = doc.createElement( QStringLiteral(
"mapTip" ) );
2886 QDomText mapTipText = doc.createTextNode( mMapTipTemplate );
2887 mapTipElem.appendChild( mapTipText );
2888 node.toElement().appendChild( mapTipElem );
2897 QDomElement mapLayerNode = node.toElement();
2910 QDomElement rendererElement = mRenderer->
save( doc, context );
2911 node.appendChild( rendererElement );
2915 if ( categories.testFlag(
Labeling ) )
2919 QDomElement labelingElement = mLabeling->
save( doc, context );
2920 node.appendChild( labelingElement );
2922 mapLayerNode.setAttribute( QStringLiteral(
"labelsEnabled" ), mLabelsEnabled ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
2928 mapLayerNode.setAttribute( QStringLiteral(
"simplifyDrawingHints" ), QString::number( mSimplifyMethod.
simplifyHints() ) );
2929 mapLayerNode.setAttribute( QStringLiteral(
"simplifyAlgorithm" ), QString::number( mSimplifyMethod.
simplifyAlgorithm() ) );
2930 mapLayerNode.setAttribute( QStringLiteral(
"simplifyDrawingTol" ), QString::number( mSimplifyMethod.
threshold() ) );
2931 mapLayerNode.setAttribute( QStringLiteral(
"simplifyLocal" ), mSimplifyMethod.
forceLocalOptimization() ? 1 : 0 );
2932 mapLayerNode.setAttribute( QStringLiteral(
"simplifyMaxScale" ), QString::number( mSimplifyMethod.
maximumScale() ) );
2944 QDomElement blendModeElem = doc.createElement( QStringLiteral(
"blendMode" ) );
2946 blendModeElem.appendChild( blendModeText );
2947 node.appendChild( blendModeElem );
2950 QDomElement featureBlendModeElem = doc.createElement( QStringLiteral(
"featureBlendMode" ) );
2952 featureBlendModeElem.appendChild( featureBlendModeText );
2953 node.appendChild( featureBlendModeElem );
2959 QDomElement layerOpacityElem = doc.createElement( QStringLiteral(
"layerOpacity" ) );
2960 QDomText layerOpacityText = doc.createTextNode( QString::number(
opacity() ) );
2961 layerOpacityElem.appendChild( layerOpacityText );
2962 node.appendChild( layerOpacityElem );
2963 mapLayerNode.setAttribute( QStringLiteral(
"hasScaleBasedVisibilityFlag" ),
hasScaleBasedVisibility() ? 1 : 0 );
2964 mapLayerNode.setAttribute( QStringLiteral(
"maxScale" ),
maximumScale() );
2965 mapLayerNode.setAttribute( QStringLiteral(
"minScale" ),
minimumScale() );
2967 mapLayerNode.setAttribute( QStringLiteral(
"symbologyReferenceScale" ), mRenderer ? mRenderer->
referenceScale() : -1 );
2970 if ( categories.testFlag(
Diagrams ) && mDiagramRenderer )
2972 mDiagramRenderer->
writeXml( mapLayerNode, doc, context );
2973 if ( mDiagramLayerSettings )
2974 mDiagramLayerSettings->
writeXml( mapLayerNode, doc );
2983 QDomElement nameElem = node.firstChildElement( QStringLiteral(
"Name" ) );
2984 if ( nameElem.isNull() )
2986 errorMessage = QStringLiteral(
"Warning: Name element not found within NamedLayer while it's required." );
3002 readSldLabeling( node );
3004 styleChangedSignalBlocker.release();
3012 Q_UNUSED( errorMessage )
3014 QVariantMap localProps = QVariantMap( props );
3023 QDomElement nameNode = doc.createElement( QStringLiteral(
"se:Name" ) );
3024 nameNode.appendChild( doc.createTextNode(
name() ) );
3025 node.appendChild( nameNode );
3027 QDomElement userStyleElem = doc.createElement( QStringLiteral(
"UserStyle" ) );
3028 node.appendChild( userStyleElem );
3030 QDomElement nameElem = doc.createElement( QStringLiteral(
"se:Name" ) );
3031 nameElem.appendChild( doc.createTextNode(
name() ) );
3033 userStyleElem.appendChild( nameElem );
3035 QDomElement featureTypeStyleElem = doc.createElement( QStringLiteral(
"se:FeatureTypeStyle" ) );
3036 userStyleElem.appendChild( featureTypeStyleElem );
3038 mRenderer->
toSld( doc, featureTypeStyleElem, localProps );
3041 mLabeling->
toSld( featureTypeStyleElem, localProps );
3050 if ( !mEditBuffer || !mDataProvider )
3055 if ( mGeometryOptions->isActive() )
3056 mGeometryOptions->apply( geom );
3065 if ( !skipDefaultValue && !mDefaultValueOnUpdateFields.isEmpty() )
3066 updateDefaultValues( fid );
3074 bool result =
false;
3088 if ( mEditBuffer && mDataProvider )
3097 if ( result && !skipDefaultValues && !mDefaultValueOnUpdateFields.isEmpty() )
3098 updateDefaultValues( fid );
3113 for (
auto it = newValues.constBegin(); it != newValues.constEnd(); ++it )
3115 const int field = it.key();
3116 const QVariant newValue = it.value();
3119 if ( oldValues.contains(
field ) )
3120 oldValue = oldValues[
field];
3125 newValuesJoin[
field] = newValue;
3126 oldValuesJoin[
field] = oldValue;
3133 newValuesNotJoin[
field] = newValue;
3134 oldValuesNotJoin[
field] = oldValue;
3143 if ( ! newValuesJoin.isEmpty() && mJoinBuffer )
3148 if ( ! newValuesNotJoin.isEmpty() && mEditBuffer && mDataProvider )
3153 if ( result && !skipDefaultValues && !mDefaultValueOnUpdateFields.isEmpty() )
3155 updateDefaultValues( fid );
3163 if ( !mEditBuffer || !mDataProvider )
3171 if ( attIndex < 0 || attIndex >=
fields().count() )
3175 mFields[ attIndex ].setAlias( QString() );
3176 if ( mAttributeAliasMap.contains(
name ) )
3178 mAttributeAliasMap.remove(
name );
3180 mEditFormConfig.setFields( mFields );
3187 if ( index < 0 || index >=
fields().count() )
3194 if ( mExpressionFieldBuffer )
3210 if ( !mEditBuffer || !mDataProvider )
3226 if ( attIndex < 0 || attIndex >=
fields().count() )
3231 mAttributeAliasMap.insert(
name, aliasString );
3232 mFields[ attIndex ].setAlias( aliasString );
3233 mEditFormConfig.setFields( mFields );
3239 if ( index < 0 || index >=
fields().count() )
3247 if ( index >= 0 && index < mFields.
count() )
3255 return mAttributeAliasMap;
3260 QSet<QString> excludeList;
3261 QMap< QString, QgsField::ConfigurationFlags >::const_iterator flagsIt = mFieldConfigurationFlags.constBegin();
3262 for ( ; flagsIt != mFieldConfigurationFlags.constEnd(); ++flagsIt )
3266 excludeList << flagsIt.key();
3274 QMap< QString, QgsField::ConfigurationFlags >::iterator flagsIt = mFieldConfigurationFlags.begin();
3275 for ( ; flagsIt != mFieldConfigurationFlags.end(); ++flagsIt )
3284 QSet<QString> excludeList;
3285 QMap< QString, QgsField::ConfigurationFlags >::const_iterator flagsIt = mFieldConfigurationFlags.constBegin();
3286 for ( ; flagsIt != mFieldConfigurationFlags.constEnd(); ++flagsIt )
3290 excludeList << flagsIt.key();
3298 QMap< QString, QgsField::ConfigurationFlags >::iterator flagsIt = mFieldConfigurationFlags.begin();
3299 for ( ; flagsIt != mFieldConfigurationFlags.end(); ++flagsIt )
3308 if ( index < 0 || index >=
fields().count() )
3317 if ( !mEditBuffer || !mDataProvider )
3325 bool deleted =
false;
3328 QList<int> attrList = qgis::setToList( qgis::listToSet( attrs ) );
3330 std::sort( attrList.begin(), attrList.end(), std::greater<int>() );
3332 for (
int attr : std::as_const( attrList ) )
3348 if ( context && context->
cascade )
3351 const bool hasRelationsOrJoins = !relations.empty() || mJoinBuffer->
containsJoins();
3352 if ( hasRelationsOrJoins )
3357 if ( handledFeatureIds.contains( fid ) )
3365 handledFeatureIds << fid;
3383 while ( relatedFeaturesIt.
nextFeature( childFeature ) )
3385 childFeatureIds.insert( childFeature.
id() );
3387 if ( childFeatureIds.count() > 0 )
3389 relation.referencingLayer()->startEditing();
3390 relation.referencingLayer()->deleteFeatures( childFeatureIds, context );
3410 bool res = deleteFeatureCascade( fid, context );
3423 const auto constFids = fids;
3425 res = deleteFeatureCascade( fid, context ) && res;
3429 mSelectedFeatureIds.subtract( fids );
3444 if ( !mDataProvider )
3445 return pkAttributesList;
3448 for (
int i = 0; i < mFields.
count(); ++i )
3452 pkAttributesList << i;
3455 return pkAttributesList;
3460 if ( !mDataProvider )
3471 if ( mEditBuffer && !deletedFeatures.empty() )
3473 if ( addedFeatures.size() > deletedFeatures.size() )
3474 return QgsFeatureSource::FeatureAvailability::FeaturesAvailable;
3476 return QgsFeatureSource::FeatureAvailability::FeaturesMaybeAvailable;
3479 if ( ( !mEditBuffer || addedFeatures.empty() ) && mDataProvider && mDataProvider->
empty() )
3480 return QgsFeatureSource::FeatureAvailability::NoFeaturesAvailable;
3482 return QgsFeatureSource::FeatureAvailability::FeaturesAvailable;
3490 mCommitErrors.clear();
3492 if ( !mDataProvider )
3494 mCommitErrors << tr(
"ERROR: no provider" );
3500 mCommitErrors << tr(
"ERROR: layer not editable" );
3506 if ( !mAllowCommit )
3509 mCommitChangesActive =
true;
3511 bool success =
false;
3517 mCommitChangesActive =
false;
3519 if ( !mDeletedFids.empty() )
3522 mDeletedFids.clear();
3561 return mCommitErrors;
3574 if ( !mDataProvider )
3576 mCommitErrors << tr(
"ERROR: no provider" );
3602 mEditBuffer =
nullptr;
3607 if ( rollbackExtent )
3618 return mSelectedFeatureIds.size();
3623 return mSelectedFeatureIds;
3629 features.reserve( mSelectedFeatureIds.count() );
3636 features.push_back( f );
3644 if ( mSelectedFeatureIds.isEmpty() )
3650 if ( mSelectedFeatureIds.count() == 1 )
3651 request.
setFilterFid( *mSelectedFeatureIds.constBegin() );
3660 if ( !mEditBuffer || !mDataProvider )
3663 if ( mGeometryOptions->isActive() )
3665 for (
auto feature = features.begin(); feature != features.end(); ++feature )
3668 mGeometryOptions->apply( geom );
3710 if ( !mDisplayExpression.isEmpty() || mFields.
isEmpty() )
3712 return mDisplayExpression;
3717 if ( !candidateName.isEmpty() )
3730 return ( mEditBuffer && mDataProvider );
3739 bool QgsVectorLayer::isReadOnly()
const
3747 if ( readonly && mEditBuffer )
3750 mReadOnly = readonly;
3757 if ( ! mDataProvider )
3766 return mEditBuffer && mEditBuffer->
isModified();
3771 bool auxiliaryField =
false;
3775 return auxiliaryField;
3782 auxiliaryField =
true;
3785 return auxiliaryField;
3796 if ( r != mRenderer )
3800 mSymbolFeatureCounted =
false;
3801 mSymbolFeatureCountMap.clear();
3802 mSymbolFeatureIdMap.clear();
3807 if ( refreshRate <= 0 )
3809 mRefreshRendererTimer->stop();
3810 mRefreshRendererTimer->setInterval( 0 );
3814 mRefreshRendererTimer->setInterval( 1000 / refreshRate );
3815 mRefreshRendererTimer->start();
3828 mRendererGenerators << generator;
3834 for (
int i = mRendererGenerators.count() - 1; i >= 0; --i )
3836 if ( mRendererGenerators.at( i )->id() ==
id )
3838 delete mRendererGenerators.at( i );
3839 mRendererGenerators.removeAt( i );
3846 QList< const QgsFeatureRendererGenerator * > res;
3854 if ( !mDataProvider )
3860 QString ignoredError;
3864 mEditCommandActive =
true;
3870 if ( !mDataProvider )
3875 mEditCommandActive =
false;
3876 if ( !mDeletedFids.isEmpty() )
3880 mSelectedFeatureIds.subtract( mDeletedFids );
3883 mDeletedFids.clear();
3890 if ( !mDataProvider )
3901 std::unique_ptr< QUndoCommand > command = std::make_unique< QUndoCommand >();
3902 command->setObsolete(
true );
3905 mEditCommandActive =
false;
3906 mDeletedFids.clear();
3912 return mJoinBuffer->
addJoin( joinInfo );
3918 return mJoinBuffer->
removeJoin( joinLayerId );
3951 if ( oi < 0 || oi >= mExpressionFieldBuffer->
expressions().size() )
3954 return mExpressionFieldBuffer->
expressions().at( oi ).cachedExpression.expression();
3965 if ( !mDataProvider )
3970 mFields = mDataProvider->
fields();
3980 if ( mExpressionFieldBuffer )
3984 QMap< QString, QString >::const_iterator aliasIt = mAttributeAliasMap.constBegin();
3985 for ( ; aliasIt != mAttributeAliasMap.constEnd(); ++aliasIt )
3991 mFields[ index ].setAlias( aliasIt.value() );
3995 QMap< QString, QgsField::ConfigurationFlags >::const_iterator flagsIt = mFieldConfigurationFlags.constBegin();
3996 for ( ; flagsIt != mFieldConfigurationFlags.constEnd(); ++flagsIt )
4002 mFields[index].setConfigurationFlags( flagsIt.value() );
4006 mDefaultValueOnUpdateFields.clear();
4007 QMap< QString, QgsDefaultValue >::const_iterator defaultIt = mDefaultExpressionMap.constBegin();
4008 for ( ; defaultIt != mDefaultExpressionMap.constEnd(); ++defaultIt )
4010 int index = mFields.
lookupField( defaultIt.key() );
4014 mFields[ index ].setDefaultValueDefinition( defaultIt.value() );
4015 if ( defaultIt.value().applyOnUpdate() )
4016 mDefaultValueOnUpdateFields.insert( index );
4019 QMap< QString, QgsFieldConstraints::Constraints >::const_iterator constraintIt = mFieldConstraints.constBegin();
4020 for ( ; constraintIt != mFieldConstraints.constEnd(); ++constraintIt )
4022 int index = mFields.
lookupField( constraintIt.key() );
4035 mFields[ index ].setConstraints( constraints );
4038 QMap< QString, QPair< QString, QString > >::const_iterator constraintExpIt = mFieldConstraintExpressions.constBegin();
4039 for ( ; constraintExpIt != mFieldConstraintExpressions.constEnd(); ++constraintExpIt )
4041 int index = mFields.
lookupField( constraintExpIt.key() );
4052 mFields[ index ].setConstraints( constraints );
4056 for ( ; constraintStrengthIt != mFieldConstraintStrength.constEnd(); ++constraintStrengthIt )
4058 int index = mFields.
lookupField( constraintStrengthIt.key().first );
4068 constraints.
setConstraintStrength( constraintStrengthIt.key().second, constraintStrengthIt.value() );
4069 mFields[ index ].setConstraints( constraints );
4072 auto fieldWidgetIterator = mFieldWidgetSetups.constBegin();
4073 for ( ; fieldWidgetIterator != mFieldWidgetSetups.constEnd(); ++ fieldWidgetIterator )
4075 int index = mFields.
indexOf( fieldWidgetIterator.key() );
4079 mFields[index].setEditorWidgetSetup( fieldWidgetIterator.value() );
4082 if ( oldFields != mFields )
4085 mEditFormConfig.setFields( mFields );
4093 if ( index < 0 || index >= mFields.
count() || !mDataProvider )
4097 if ( expression.isEmpty() )
4101 std::unique_ptr< QgsExpressionContext > tempContext;
4106 evalContext = tempContext.get();
4139 if ( index < 0 || index >= mFields.
count() )
4144 mDefaultExpressionMap.insert( mFields.
at( index ).
name(), definition );
4148 mDefaultExpressionMap.remove( mFields.
at( index ).
name() );
4155 if ( index < 0 || index >= mFields.
count() )
4164 if ( !mDataProvider )
4179 if ( mEditBuffer && ! mDataProvider->
transaction() )
4183 for (
const QVariant &v : constUniqueValues )
4185 vals << v.toString();
4189 QMapIterator< QgsFeatureId, QgsFeature > addedIt( added );
4190 while ( addedIt.hasNext() && ( limit < 0 ||
uniqueValues.count() < limit ) )
4193 QVariant v = addedIt.value().attribute( index );
4196 QString vs = v.toString();
4197 if ( !vals.contains( vs ) )
4206 while ( it.hasNext() && ( limit < 0 ||
uniqueValues.count() < limit ) )
4209 QVariant v = it.value().value( index );
4212 QString vs = v.toString();
4213 if ( !vals.contains( vs ) )
4246 .setSubsetOfAttributes( attList ) );
4249 QVariant currentValue;
4250 QHash<QString, QVariant> val;
4254 val.insert( currentValue.toString(), currentValue );
4255 if ( limit >= 0 && val.size() >= limit )
4261 return qgis::listToSet( val.values() );
4265 Q_ASSERT_X(
false,
"QgsVectorLayer::uniqueValues()",
"Unknown source of the field!" );
4271 QStringList results;
4272 if ( !mDataProvider )
4287 if ( mEditBuffer && ! mDataProvider->
transaction() )
4290 QMapIterator< QgsFeatureId, QgsFeature > addedIt( added );
4291 while ( addedIt.hasNext() && ( limit < 0 || results.count() < limit ) && ( !feedback || !feedback->
isCanceled() ) )
4294 QVariant v = addedIt.value().attribute( index );
4297 QString vs = v.toString();
4298 if ( vs.contains( substring, Qt::CaseInsensitive ) && !results.contains( vs ) )
4306 while ( it.hasNext() && ( limit < 0 || results.count() < limit ) && ( !feedback || !feedback->
isCanceled() ) )
4309 QVariant v = it.value().value( index );
4312 QString vs = v.toString();
4313 if ( vs.contains( substring, Qt::CaseInsensitive ) && !results.contains( vs ) )
4344 QString fieldName = mFields.
at( index ).
name();
4345 request.
setFilterExpression( QStringLiteral(
"\"%1\" ILIKE '%%2%'" ).arg( fieldName, substring ) );
4349 QString currentValue;
4352 currentValue = f.
attribute( index ).toString();
4353 if ( !results.contains( currentValue ) )
4354 results << currentValue;
4356 if ( ( limit >= 0 && results.size() >= limit ) || ( feedback && feedback->
isCanceled() ) )
4366 Q_ASSERT_X(
false,
"QgsVectorLayer::uniqueStringsMatching()",
"Unknown source of the field!" );
4373 minimumOrMaximumValue( index, &minimum,
nullptr );
4380 minimumOrMaximumValue( index,
nullptr, &maximum );
4386 minimumOrMaximumValue( index, &minimum, &maximum );
4389 void QgsVectorLayer::minimumOrMaximumValue(
int index, QVariant *minimum, QVariant *maximum )
const
4392 *minimum = QVariant();
4394 *maximum = QVariant();
4396 if ( !mDataProvider )
4416 if ( mEditBuffer && ! mDataProvider->
transaction() )
4419 QMapIterator< QgsFeatureId, QgsFeature > addedIt( added );
4420 while ( addedIt.hasNext() )
4423 const QVariant v = addedIt.value().attribute( index );
4431 while ( it.hasNext() )
4434 const QVariant v = it.value().value( index );
4470 .setSubsetOfAttributes( attList ) );
4473 bool firstValue =
true;
4476 const QVariant currentValue = f.
attribute( index );
4477 if ( currentValue.isNull() )
4483 *minimum = currentValue;
4485 *maximum = currentValue;
4490 if ( minimum && currentValue.isValid() &&
qgsVariantLessThan( currentValue, *minimum ) )
4491 *minimum = currentValue;
4493 *maximum = currentValue;
4500 Q_ASSERT_X(
false,
"QgsVectorLayer::minimumOrMaximumValue()",
"Unknown source of the field!" );
4503 void QgsVectorLayer::createEditBuffer()
4537 void QgsVectorLayer::clearEditBuffer()
4540 mEditBuffer =
nullptr;
4552 if ( !mDataProvider )
4555 *
error = tr(
"Layer is invalid" );
4561 if ( attrIndex >= 0 )
4568 bool providerOk =
false;
4569 QVariant val = mDataProvider->
aggregate(
aggregate, attrIndex, parameters, context, providerOk, fids );
4583 c.setFidsFilter( *fids );
4584 c.setParameters( parameters );
4585 bool aggregateOk =
false;
4586 const QVariant result =
c.calculate(
aggregate, fieldOrExpression, context, &aggregateOk, feedback );
4589 if ( !aggregateOk &&
error )
4607 return mFeatureBlendMode;
4610 void QgsVectorLayer::readSldLabeling(
const QDomNode &node )
4615 QDomElement element = node.toElement();
4616 if ( element.isNull() )
4619 QDomElement userStyleElem = element.firstChildElement( QStringLiteral(
"UserStyle" ) );
4620 if ( userStyleElem.isNull() )
4622 QgsDebugMsgLevel( QStringLiteral(
"Info: UserStyle element not found." ), 4 );
4626 QDomElement featTypeStyleElem = userStyleElem.firstChildElement( QStringLiteral(
"FeatureTypeStyle" ) );
4627 if ( featTypeStyleElem.isNull() )
4629 QgsDebugMsgLevel( QStringLiteral(
"Info: FeatureTypeStyle element not found." ), 4 );
4634 QDomElement mergedFeatTypeStyle = featTypeStyleElem.cloneNode(
false ).toElement();
4639 bool needRuleBasedLabeling =
false;
4642 while ( !featTypeStyleElem.isNull() )
4644 QDomElement ruleElem = featTypeStyleElem.firstChildElement( QStringLiteral(
"Rule" ) );
4645 while ( !ruleElem.isNull() )
4649 bool hasTextSymbolizer =
false;
4650 bool hasRuleBased =
false;
4651 QDomElement ruleChildElem = ruleElem.firstChildElement();
4652 while ( !ruleChildElem.isNull() )
4655 if ( ruleChildElem.localName() == QLatin1String(
"Filter" ) ||
4656 ruleChildElem.localName() == QLatin1String(
"MinScaleDenominator" ) ||
4657 ruleChildElem.localName() == QLatin1String(
"MaxScaleDenominator" ) )
4659 hasRuleBased =
true;
4662 else if ( ruleChildElem.localName() == QLatin1String(
"TextSymbolizer" ) )
4664 QgsDebugMsgLevel( QStringLiteral(
"Info: TextSymbolizer element found" ), 4 );
4665 hasTextSymbolizer =
true;
4668 ruleChildElem = ruleChildElem.nextSiblingElement();
4671 if ( hasTextSymbolizer )
4676 mergedFeatTypeStyle.appendChild( ruleElem.cloneNode().toElement() );
4680 QgsDebugMsgLevel( QStringLiteral(
"Info: Filter or Min/MaxScaleDenominator element found: need a RuleBasedLabeling" ), 4 );
4681 needRuleBasedLabeling =
true;
4686 if ( ruleCount > 1 )
4688 QgsDebugMsgLevel( QStringLiteral(
"Info: More Rule elements found: need a RuleBasedLabeling" ), 4 );
4689 needRuleBasedLabeling =
true;
4693 if ( ruleCount == 0 )
4695 needRuleBasedLabeling =
false;
4698 ruleElem = ruleElem.nextSiblingElement( QStringLiteral(
"Rule" ) );
4700 featTypeStyleElem = featTypeStyleElem.nextSiblingElement( QStringLiteral(
"FeatureTypeStyle" ) );
4703 if ( ruleCount == 0 )
4705 QgsDebugMsgLevel( QStringLiteral(
"Info: No TextSymbolizer element." ), 4 );
4709 QDomElement ruleElem = mergedFeatTypeStyle.firstChildElement( QStringLiteral(
"Rule" ) );
4711 if ( needRuleBasedLabeling )
4715 while ( !ruleElem.isNull() )
4718 QString label, description, filterExp;
4719 int scaleMinDenom = 0, scaleMaxDenom = 0;
4723 QDomElement childElem = ruleElem.firstChildElement();
4724 while ( !childElem.isNull() )
4726 if ( childElem.localName() == QLatin1String(
"Name" ) )
4730 if ( label.isEmpty() )
4731 label = childElem.firstChild().nodeValue();
4733 else if ( childElem.localName() == QLatin1String(
"Description" ) )
4736 QDomElement titleElem = childElem.firstChildElement( QStringLiteral(
"Title" ) );
4737 if ( !titleElem.isNull() )
4739 label = titleElem.firstChild().nodeValue();
4742 QDomElement abstractElem = childElem.firstChildElement( QStringLiteral(
"Abstract" ) );
4743 if ( !abstractElem.isNull() )
4745 description = abstractElem.firstChild().nodeValue();
4748 else if ( childElem.localName() == QLatin1String(
"Abstract" ) )
4751 description = childElem.firstChild().nodeValue();
4753 else if ( childElem.localName() == QLatin1String(
"Title" ) )
4756 label = childElem.firstChild().nodeValue();
4758 else if ( childElem.localName() == QLatin1String(
"Filter" ) )
4774 else if ( childElem.localName() == QLatin1String(
"MinScaleDenominator" ) )
4777 int v = childElem.firstChild().nodeValue().toInt( &ok );
4781 else if ( childElem.localName() == QLatin1String(
"MaxScaleDenominator" ) )
4784 int v = childElem.firstChild().nodeValue().toInt( &ok );
4788 else if ( childElem.localName() == QLatin1String(
"TextSymbolizer" ) )
4790 readSldTextSymbolizer( childElem, settings );
4793 childElem = childElem.nextSiblingElement();
4799 ruleElem = ruleElem.nextSiblingElement();
4809 QDomElement textSymbolizerElem = ruleElem.firstChildElement( QStringLiteral(
"TextSymbolizer" ) );
4811 if ( readSldTextSymbolizer( textSymbolizerElem, s ) )
4819 bool QgsVectorLayer::readSldTextSymbolizer(
const QDomNode &node,
QgsPalLayerSettings &settings )
const
4821 if ( node.localName() != QLatin1String(
"TextSymbolizer" ) )
4823 QgsDebugMsgLevel( QStringLiteral(
"Not a TextSymbolizer element: %1" ).arg( node.localName() ), 3 );
4826 QDomElement textSymbolizerElem = node.toElement();
4828 QDomElement labelElem = textSymbolizerElem.firstChildElement( QStringLiteral(
"Label" ) );
4829 if ( !labelElem.isNull() )
4831 QDomElement propertyNameElem = labelElem.firstChildElement( QStringLiteral(
"PropertyName" ) );
4832 if ( !propertyNameElem.isNull() )
4837 QString labelAttribute = propertyNameElem.text();
4841 int fieldIndex = mFields.
lookupField( labelAttribute );
4842 if ( fieldIndex == -1 )
4846 if ( !exp.hasEvalError() )
4852 QgsDebugMsgLevel( QStringLiteral(
"SLD label attribute error: %1" ).arg( exp.evalErrorString() ), 3 );
4858 QgsDebugMsgLevel( QStringLiteral(
"Info: PropertyName element not found." ), 4 );
4869 if ( textSymbolizerElem.hasAttribute( QStringLiteral(
"uom" ) ) )
4874 QString fontFamily = QStringLiteral(
"Sans-Serif" );
4875 int fontPointSize = 10;
4877 int fontWeight = -1;
4878 bool fontItalic =
false;
4879 bool fontUnderline =
false;
4882 QDomElement fontElem = textSymbolizerElem.firstChildElement( QStringLiteral(
"Font" ) );
4883 if ( !fontElem.isNull() )
4886 for ( QgsStringMap::iterator it = fontSvgParams.begin(); it != fontSvgParams.end(); ++it )
4888 QgsDebugMsgLevel( QStringLiteral(
"found fontSvgParams %1: %2" ).arg( it.key(), it.value() ), 4 );
4890 if ( it.key() == QLatin1String(
"font-family" ) )
4892 fontFamily = it.value();
4894 else if ( it.key() == QLatin1String(
"font-style" ) )
4896 fontItalic = ( it.value() == QLatin1String(
"italic" ) ) || ( it.value() == QLatin1String(
"Italic" ) );
4898 else if ( it.key() == QLatin1String(
"font-size" ) )
4901 int fontSize = it.value().toInt( &ok );
4904 fontPointSize = fontSize;
4905 fontUnitSize = sldUnitSize;
4908 else if ( it.key() == QLatin1String(
"font-weight" ) )
4910 if ( ( it.value() == QLatin1String(
"bold" ) ) || ( it.value() == QLatin1String(
"Bold" ) ) )
4911 fontWeight = QFont::Bold;
4913 else if ( it.key() == QLatin1String(
"font-underline" ) )
4915 fontUnderline = ( it.value() == QLatin1String(
"underline" ) ) || ( it.value() == QLatin1String(
"Underline" ) );
4921 QFont font( fontFamily, fontPointSize, fontWeight, fontItalic );
4922 font.setUnderline( fontUnderline );
4924 format.
setSize( fontPointSize );
4928 QDomElement fillElem = textSymbolizerElem.firstChildElement( QStringLiteral(
"Fill" ) );
4930 Qt::BrushStyle textBrush = Qt::SolidPattern;
4932 if ( textColor.isValid() )
4934 QgsDebugMsgLevel( QStringLiteral(
"Info: textColor %1." ).arg( QVariant( textColor ).toString() ), 4 );
4941 QDomElement haloElem = textSymbolizerElem.firstChildElement( QStringLiteral(
"Halo" ) );
4942 if ( !haloElem.isNull() )
4947 QDomElement radiusElem = haloElem.firstChildElement( QStringLiteral(
"Radius" ) );
4948 if ( !radiusElem.isNull() )
4951 double bufferSize = radiusElem.text().toDouble( &ok );
4954 bufferSettings.
setSize( bufferSize );
4959 QDomElement haloFillElem = haloElem.firstChildElement( QStringLiteral(
"Fill" ) );
4961 Qt::BrushStyle bufferBrush = Qt::SolidPattern;
4963 if ( bufferColor.isValid() )
4965 QgsDebugMsgLevel( QStringLiteral(
"Info: bufferColor %1." ).arg( QVariant( bufferColor ).toString() ), 4 );
4966 bufferSettings.
setColor( bufferColor );
4971 QDomElement labelPlacementElem = textSymbolizerElem.firstChildElement( QStringLiteral(
"LabelPlacement" ) );
4972 if ( !labelPlacementElem.isNull() )
4975 QDomElement pointPlacementElem = labelPlacementElem.firstChildElement( QStringLiteral(
"PointPlacement" ) );
4976 if ( !pointPlacementElem.isNull() )
4984 QDomElement displacementElem = pointPlacementElem.firstChildElement( QStringLiteral(
"Displacement" ) );
4985 if ( !displacementElem.isNull() )
4987 QDomElement displacementXElem = displacementElem.firstChildElement( QStringLiteral(
"DisplacementX" ) );
4988 if ( !displacementXElem.isNull() )
4991 double xOffset = displacementXElem.text().toDouble( &ok );
4998 QDomElement displacementYElem = displacementElem.firstChildElement( QStringLiteral(
"DisplacementY" ) );
4999 if ( !displacementYElem.isNull() )
5002 double yOffset = displacementYElem.text().toDouble( &ok );
5010 QDomElement anchorPointElem = pointPlacementElem.firstChildElement( QStringLiteral(
"AnchorPoint" ) );
5011 if ( !anchorPointElem.isNull() )
5013 QDomElement anchorPointXElem = anchorPointElem.firstChildElement( QStringLiteral(
"AnchorPointX" ) );
5014 if ( !anchorPointXElem.isNull() )
5017 double xOffset = anchorPointXElem.text().toDouble( &ok );
5024 QDomElement anchorPointYElem = anchorPointElem.firstChildElement( QStringLiteral(
"AnchorPointY" ) );
5025 if ( !anchorPointYElem.isNull() )
5028 double yOffset = anchorPointYElem.text().toDouble( &ok );
5037 QDomElement rotationElem = pointPlacementElem.firstChildElement( QStringLiteral(
"Rotation" ) );
5038 if ( !rotationElem.isNull() )
5041 double rotation = rotationElem.text().toDouble( &ok );
5051 QDomElement linePlacementElem = labelPlacementElem.firstChildElement( QStringLiteral(
"LinePlacement" ) );
5052 if ( !linePlacementElem.isNull() )
5061 QDomElement vendorOptionElem = textSymbolizerElem.firstChildElement( QStringLiteral(
"VendorOption" ) );
5062 while ( !vendorOptionElem.isNull() && vendorOptionElem.localName() == QLatin1String(
"VendorOption" ) )
5064 QString optionName = vendorOptionElem.attribute( QStringLiteral(
"name" ) );
5065 QString optionValue;
5066 if ( vendorOptionElem.firstChild().nodeType() == QDomNode::TextNode )
5068 optionValue = vendorOptionElem.firstChild().nodeValue();
5072 if ( vendorOptionElem.firstChild().nodeType() == QDomNode::ElementNode &&
5073 vendorOptionElem.firstChild().localName() == QLatin1String(
"Literal" ) )
5075 QgsDebugMsg( vendorOptionElem.firstChild().localName() );
5076 optionValue = vendorOptionElem.firstChild().firstChild().nodeValue();
5080 QgsDebugMsg( QStringLiteral(
"unexpected child of %1 named %2" ).arg( vendorOptionElem.localName(), optionName ) );
5084 if ( !optionName.isEmpty() && !optionValue.isEmpty() )
5086 vendorOptions[ optionName ] = optionValue;
5089 vendorOptionElem = vendorOptionElem.nextSiblingElement();
5091 if ( !vendorOptions.isEmpty() )
5093 for ( QgsStringMap::iterator it = vendorOptions.begin(); it != vendorOptions.end(); ++it )
5095 if ( it.key() == QLatin1String(
"underlineText" ) && it.value() == QLatin1String(
"true" ) )
5097 font.setUnderline(
true );
5100 else if ( it.key() == QLatin1String(
"strikethroughText" ) && it.value() == QLatin1String(
"true" ) )
5102 font.setStrikeOut(
true );
5105 else if ( it.key() == QLatin1String(
"maxDisplacement" ) )
5109 else if ( it.key() == QLatin1String(
"followLine" ) && it.value() == QLatin1String(
"true" ) )
5120 else if ( it.key() == QLatin1String(
"maxAngleDelta" ) )
5123 double angle = it.value().toDouble( &ok );
5131 else if ( it.key() == QLatin1String(
"conflictResolution" ) && it.value() == QLatin1String(
"false" ) )
5135 else if ( it.key() == QLatin1String(
"forceLeftToRight" ) && it.value() == QLatin1String(
"false" ) )
5137 settings.
upsidedownLabels = Qgis::UpsideDownLabelHandling::AlwaysAllowUpsideDown;
5139 else if ( it.key() == QLatin1String(
"group" ) && it.value() == QLatin1String(
"yes" ) )
5143 else if ( it.key() == QLatin1String(
"labelAllGroup" ) && it.value() == QLatin1String(
"true" ) )
5157 return mEditFormConfig;
5166 mEditFormConfig.onRelationsLoaded();
5172 return mMapTipTemplate;
5177 if ( mMapTipTemplate == mapTip )
5180 mMapTipTemplate = mapTip;
5215 if ( !mDiagramLayerSettings )
5217 *mDiagramLayerSettings = s;
5223 QString myMetadata = QStringLiteral(
"<html><head></head>\n<body>\n" );
5228 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Information from provider" ) + QStringLiteral(
"</h1>\n<hr>\n" );
5229 myMetadata += QLatin1String(
"<table class=\"list-view\">\n" );
5234 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Storage" ) + QStringLiteral(
"</td><td>" ) +
storageType() + QStringLiteral(
"</td></tr>\n" );
5240 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Comment" ) + QStringLiteral(
"</td><td>" ) +
dataComment() + QStringLiteral(
"</td></tr>\n" );
5247 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Encoding" ) + QStringLiteral(
"</td><td>" ) + provider->
encoding() + QStringLiteral(
"</td></tr>\n" );
5262 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Geometry" ) + QStringLiteral(
"</td><td>" ) + typeString + QStringLiteral(
"</td></tr>\n" );
5266 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Extent" ) + QStringLiteral(
"</td><td>" ) +
extent().
toString() + QStringLiteral(
"</td></tr>\n" );
5270 QLocale locale = QLocale();
5271 locale.setNumberOptions( locale.numberOptions() &= ~QLocale::NumberOption::OmitGroupSeparator );
5272 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" )
5273 + tr(
"Feature count" ) + QStringLiteral(
"</td><td>" )
5275 + QStringLiteral(
"</td></tr>\n" );
5278 myMetadata += QLatin1String(
"</table>\n<br><br>" );
5287 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Identification" ) + QStringLiteral(
"</h1>\n<hr>\n" );
5289 myMetadata += QLatin1String(
"<br><br>\n" );
5292 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Extent" ) + QStringLiteral(
"</h1>\n<hr>\n" );
5294 myMetadata += QLatin1String(
"<br><br>\n" );
5297 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Access" ) + QStringLiteral(
"</h1>\n<hr>\n" );
5299 myMetadata += QLatin1String(
"<br><br>\n" );
5302 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Fields" ) + QStringLiteral(
"</h1>\n<hr>\n<table class=\"list-view\">\n" );
5306 if ( !pkAttrList.isEmpty() )
5308 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Primary key attributes" ) + QStringLiteral(
"</td><td>" );
5309 const auto constPkAttrList = pkAttrList;
5310 for (
int idx : constPkAttrList )
5314 myMetadata += QLatin1String(
"</td></tr>\n" );
5320 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Count" ) + QStringLiteral(
"</td><td>" ) + QString::number( myFields.
size() ) + QStringLiteral(
"</td></tr>\n" );
5322 myMetadata += QLatin1String(
"</table>\n<br><table width=\"100%\" class=\"tabular-view\">\n" );
5323 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" );
5325 for (
int i = 0; i < myFields.
size(); ++i )
5330 rowClass = QStringLiteral(
"class=\"odd-row\"" );
5331 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" );
5335 myMetadata += QLatin1String(
"</table>\n<br><br>" );
5338 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Contacts" ) + QStringLiteral(
"</h1>\n<hr>\n" );
5340 myMetadata += QLatin1String(
"<br><br>\n" );
5343 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Links" ) + QStringLiteral(
"</h1>\n<hr>\n" );
5345 myMetadata += QLatin1String(
"<br><br>\n" );
5348 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"History" ) + QStringLiteral(
"</h1>\n<hr>\n" );
5350 myMetadata += QLatin1String(
"<br><br>\n" );
5352 myMetadata += QLatin1String(
"\n</body>\n</html>\n" );
5356 void QgsVectorLayer::invalidateSymbolCountedFlag()
5358 mSymbolFeatureCounted =
false;
5361 void QgsVectorLayer::onFeatureCounterCompleted()
5364 mFeatureCounter =
nullptr;
5367 void QgsVectorLayer::onFeatureCounterTerminated()
5369 mFeatureCounter =
nullptr;
5372 void QgsVectorLayer::onJoinedFieldsChanged()
5378 void QgsVectorLayer::onFeatureDeleted(
QgsFeatureId fid )
5380 if ( mEditCommandActive || mCommitChangesActive )
5382 mDeletedFids << fid;
5386 mSelectedFeatureIds.remove( fid );
5393 void QgsVectorLayer::onRelationsLoaded()
5395 mEditFormConfig.onRelationsLoaded();
5398 void QgsVectorLayer::onSymbolsCounted()
5400 if ( mFeatureCounter )
5402 mSymbolFeatureCounted =
true;
5416 return mWeakRelations;
5436 bool useAsDefault,
const QString &uiFileContent, QString &msgError, QgsMapLayer::StyleCategories categories )
5439 QString sldStyle, qmlStyle;
5440 QDomDocument qmlDocument, sldDocument;
5443 if ( !msgError.isNull() )
5447 qmlStyle = qmlDocument.toString();
5450 if ( !msgError.isNull() )
5454 sldStyle = sldDocument.toString();
5458 description, uiFileContent, useAsDefault, msgError );
5472 QString joinKey = mAuxiliaryLayerKey;
5473 if ( !key.isEmpty() )
5476 if ( storage.
isValid() && !joinKey.isEmpty() )
5499 mAuxiliaryLayerKey.clear();
5501 if ( mAuxiliaryLayer )
5514 mAuxiliaryLayer.reset( alayer );
5515 if ( mAuxiliaryLayer )
5516 mAuxiliaryLayer->setParent(
this );
5522 return mAuxiliaryLayer.get();
5527 return mAuxiliaryLayer.get();
5533 QString returnMessage;
5534 QString qml, errorMsg;
5539 if ( !qml.isEmpty() )
5541 QDomDocument myDocument( QStringLiteral(
"qgis" ) );
5542 myDocument.setContent( qml );
5544 returnMessage = QObject::tr(
"Loaded from Provider" );
5554 return returnMessage;
5559 if ( mDataProvider )
5564 void QgsVectorLayer::emitDataChanged()
5566 if ( mDataChangedFired )
5571 mDataChangedFired =
true;
5573 mDataChangedFired =
false;
5576 void QgsVectorLayer::onAfterCommitChangesDependency()
5578 mDataChangedFired =
true;
5580 mDataChangedFired =
false;
5585 QSet<QgsMapLayerDependency> deps;
5586 const auto constODeps = oDeps;
5593 QSet<QgsMapLayerDependency> toAdd = deps -
dependencies();
5610 if ( mDataProvider )
5631 if ( ! toAdd.isEmpty() )
5639 if ( fieldIndex < 0 || fieldIndex >= mFields.
count() || !mDataProvider )
5640 return QgsFieldConstraints::Constraints();
5655 QMap< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrength > m;
5657 if ( fieldIndex < 0 || fieldIndex >= mFields.
count() )
5660 QString
name = mFields.
at( fieldIndex ).
name();
5663 for ( ; conIt != mFieldConstraintStrength.constEnd(); ++conIt )
5665 if ( conIt.key().first ==
name )
5667 m[ conIt.key().second ] = mFieldConstraintStrength.value( conIt.key() );
5676 if ( index < 0 || index >= mFields.
count() )
5682 QgsFieldConstraints::Constraints constraints = mFieldConstraints.value(
name, QgsFieldConstraints::Constraints() );
5683 constraints |= constraint;
5684 mFieldConstraints.insert(
name, constraints );
5686 mFieldConstraintStrength.insert( qMakePair(
name, constraint ), strength );
5693 if ( index < 0 || index >= mFields.
count() )
5699 QgsFieldConstraints::Constraints constraints = mFieldConstraints.value(
name, QgsFieldConstraints::Constraints() );
5700 constraints &= ~constraint;
5701 mFieldConstraints.insert(
name, constraints );
5703 mFieldConstraintStrength.remove( qMakePair(
name, constraint ) );
5710 if ( index < 0 || index >= mFields.
count() )
5718 if ( index < 0 || index >= mFields.
count() )
5726 if ( index < 0 || index >= mFields.
count() )
5729 if ( expression.isEmpty() )
5731 mFieldConstraintExpressions.remove( mFields.
at( index ).
name() );
5735 mFieldConstraintExpressions.insert( mFields.
at( index ).
name(), qMakePair( expression, description ) );
5742 if ( index < 0 || index >= mFields.
count() )
5745 mFieldConfigurationFlags.insert( mFields.
at( index ).
name(),
flags );
5751 if ( index < 0 || index >= mFields.
count() )
5754 flags.setFlag( flag, active );
5761 if ( index < 0 || index >= mFields.
count() )
5769 if ( index < 0 || index >= mFields.
count() )
5773 mFieldWidgetSetups.remove( mFields.
at( index ).
name() );
5775 mFieldWidgetSetups.insert( mFields.
at( index ).
name(), setup );
5782 if ( index < 0 || index >= mFields.
count() )
5791 if (
customProperty( QStringLiteral(
"labeling" ) ).toString() == QLatin1String(
"pal" ) )
5793 if (
customProperty( QStringLiteral(
"labeling/enabled" ), QVariant(
false ) ).toBool() )
5797 settings.readFromLayerCustomProperties(
this );
5804 for (
const QString &key : constCustomPropertyKeys )
5806 if ( key.startsWith( QLatin1String(
"labeling/" ) ) )
5816 return mAllowCommit;
5830 return mGeometryOptions.get();
5840 return mReadExtentFromXml;
5843 void QgsVectorLayer::onDirtyTransaction(
const QString &sql,
const QString &name )
5846 if ( tr && mEditBuffer )
5848 qobject_cast<QgsVectorLayerEditPassthrough *>( mEditBuffer )->update( tr, sql,
name );
5854 QList<QgsVectorLayer *> layers;
5855 QMap<QgsVectorLayer *, QgsFeatureIds>::const_iterator i;
5858 if ( includeAuxiliaryLayers || !qobject_cast< QgsAuxiliaryLayer * >( i.key() ) )
5859 layers.append( i.key() );
5866 return mHandledFeatures[layer];
Abstract base class for curved geometry type.
void setRenderer(QgsFeatureRenderer *r)
Sets the feature renderer which will be invoked to represent this layer in 2D map views.
QString sourceName() const FINAL
Returns a friendly display name for the source.
@ OriginProvider
Field comes from the underlying data provider of the vector layer (originIndex = index in provider's ...
@ NoGeometry
Geometry is not required. It may still be returned if e.g. required for a filter condition.
Counts the features in a QgsVectorLayer in task. You should most likely not use this directly and ins...
void setDiagramRenderer(QgsDiagramRenderer *r)
Sets diagram rendering object (takes ownership)
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const FINAL
Queries the layer for features specified in request.
void willBeDeleted()
Emitted in the destructor when the layer is about to be deleted, but it is still in a perfectly valid...
QString crsHtmlMetadata() const
Returns a HTML fragment containing the layer's CRS metadata, for use in the htmlMetadata() method.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units used for the buffer size.
bool loadDefaultStyle
Set to true if the default layer style should be loaded.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
static void writeXml(const QgsVectorLayer *layer, WeakRelationType type, const QgsRelation &relation, QDomNode &node, QDomDocument &doc)
Writes a weak relation infoto an XML structure.
QgsRelationManager relationManager
QgsCoordinateReferenceSystem crs
bool addFeatures(QgsFeatureList &features, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) FINAL
Adds a list of features to the sink.
void beforeRemovingExpressionField(int idx)
Will be emitted, when an expression field is going to be deleted from this vector layer.
void emitStyleChanged()
Triggers an emission of the styleChanged() signal.
void writeXml(QDomNode &layer_node, QDomDocument &document) const
Saves expressions to xml under the layer node.
Q_INVOKABLE void removeSelection()
Clear selection.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the scope.
bool useEstimatedMetadata() const
Returns true if estimated metadata should be used for the connection.
virtual QString getStyleFromDatabase(const QString &styleId, QString &msgError)
Returns the named style corresponding to style id provided.
void setReadExtentFromXml(bool readExtentFromXml)
Flag allowing to indicate if the extent has to be read from the XML document when data source has no ...
void setForceLocalOptimization(bool localOptimization)
Sets where the simplification executes, after fetch the geometries from provider, or when supported,...
void readCommonStyle(const QDomElement &layerElement, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories)
Read style data common to all layer types.
void dependenciesChanged()
Emitted when dependencies are changed.
Qgis::LabelPlacement placement
Label placement mode.
bool diagramsEnabled() const
Returns whether the layer contains diagrams which are enabled and should be drawn.
@ OriginEdit
Field has been temporarily added in editing mode (originIndex = index in the list of added attributes...
QUuid addAction(QgsAction::ActionType type, const QString &name, const QString &command, bool capture=false)
Add an action with the given name and action details.
double height() const SIP_HOLDGIL
Returns the height of the rectangle.
Q_INVOKABLE void selectByIds(const QgsFeatureIds &ids, Qgis::SelectBehavior behavior=Qgis::SelectBehavior::SetSelection)
Selects matching features using a list of feature IDs.
@ DeleteFeatures
Allows deletion of features.
@ UnknownCount
Provider returned an unknown feature count.
QPainter::CompositionMode featureBlendMode() const
Returns the current blending mode for features.
static QgsProperty fromField(const QString &fieldName, bool isActive=true)
Returns a new FieldBasedProperty created from the specified field name.
static QgsFeatureRenderer * defaultRenderer(QgsWkbTypes::GeometryType geomType)
Returns a new renderer - used by default in vector layers.
virtual SpatialIndexPresence hasSpatialIndex() const
Returns an enum value representing the presence of a valid spatial index on the source,...
QgsExpressionContextScope * createExpressionContextScope() const FINAL
This method needs to be reimplemented in all classes which implement this interface and return an exp...
virtual void resolveReferences(QgsProject *project)
Resolve references to other layers (kept as layer IDs after reading XML) into layer objects.
QgsFeatureIds symbolFeatureIds(const QString &legendKey) const
Ids of features rendered with specified legend key.
Class for storing the component parts of a RDBMS data source URI (e.g. a Postgres data source).
static QgsExpression * expressionFromOgcFilter(const QDomElement &element, QgsVectorLayer *layer=nullptr)
Parse XML with OGC filter into QGIS expression.
@ SemiTransparentCircle
Semi-transparent circle marker.
Utility class for calculating aggregates for a field (or expression) over the features from a vector ...
@ CreateRenderer
Provider can create feature renderers using backend-specific formatting information....
QString qgsEnumValueToKey(const T &value, bool *returnOk=nullptr)
Returns the value for the given key of an enum.
Contains information about the context in which a coordinate transform is executed.
void setConstraintExpression(const QString &expression, const QString &description=QString())
Set the constraint expression for the field.
Q_INVOKABLE QgsWkbTypes::Type wkbType() const FINAL
Returns the WKBType or WKBUnknown in case of error.
static QString displayString(Type type) SIP_HOLDGIL
Returns a non-translated display string type for a WKB type, e.g., the geometry name used in WKT geom...
@ FlagTrustLayerMetadata
Trust layer metadata. Improves layer load time by skipping expensive checks like primary key unicity,...
Q_INVOKABLE void selectAll()
Select all the features.
QString password() const
Returns the password stored in the URI.
QgsAbstractProfileGenerator * createProfileGenerator(const QgsProfileRequest &request) override
Given a profile request, returns a new profile generator ready for generating elevation profiles.
double angleOffset
Label rotation, in degrees clockwise.
void setFont(const QFont &font)
Sets the font used for rendering text.
virtual QString dataComment() const override
Returns a short comment for the data that this provider is providing access to (e....
void configChanged()
Emitted whenever the configuration is changed.
@ FlagReadExtentFromXml
Read extent from xml and skip get extent from provider.
void editingStopped()
Emitted when edited changes have been successfully written to the data provider.
A child rule for QgsRuleBasedLabeling.
RenderUnit
Rendering size units.
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),...
virtual QgsAttributeList pkAttributeIndexes() const
Returns list of indexes of fields that make up the primary key.
The QgsDefaultValue class provides a container for managing client side default values for fields.
virtual void updateExtents(bool force=false)
Update the extents for the layer.
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.
QgsVectorDataProvider * dataProvider() FINAL
Returns the layer's data provider, it may be nullptr.
virtual bool isModified() const
Returns true if the provider has been modified since the last commit.
void setConstraint(Constraint constraint, ConstraintOrigin origin=ConstraintOriginLayer)
Sets a constraint on the field.
Setting options for creating vector data providers.
void combineExtentWith(const QgsRectangle &rect)
Expands the rectangle so that it covers both the original rectangle and the given rectangle.
BlendMode
Blending modes enum defining the available composition modes that can be used when rendering a layer.
QgsExpressionContextScope * popScope()
Removes the last scope from the expression context and return it.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
void set(const QgsPointXY &p1, const QgsPointXY &p2, bool normalize=true)
Sets the rectangle from two QgsPoints.
void updateFields()
Will regenerate the fields property of this layer by obtaining all fields from the dataProvider,...
The class is used as a container of context for various read/write operations on other objects.
@ ExactIntersect
Use exact geometry intersection (slower) instead of bounding boxes.
double maxCurvedCharAngleOut
Maximum angle between outside curved label characters (valid range -20.0 to -95.0)
void minimumAndMaximumValue(int index, QVariant &minimum, QVariant &maximum) const
Calculates both the minimum and maximum value for an attribute column.
QString evalErrorString() const
Returns evaluation error.
Class allowing to manage the auxiliary storage for a vector layer.
long long featureCount() const FINAL
Returns feature count including changes which have not yet been committed If you need only the count ...
void featuresDeleted(const QgsFeatureIds &fids)
Emitted when features have been deleted.
void raiseError(const QString &msg) const
Signals an error in this provider.
@ VectorLayer
Vector layer.
ConfigurationFlag
Configuration flags for fields These flags are meant to be user-configurable and are not describing a...
QSet< QString > referencedColumns() const
Gets list of columns referenced by the expression.
Point geometry type, with support for z-dimension and m-values.
bool isEmpty() const
Checks whether the container is empty.
void writeXml(QDomNode &layer_node, QDomDocument &document) const
Saves mVectorJoins to xml under the layer node.
@ Normal
A normal relation.
bool rollBack(QStringList &rollbackErrors, bool stopEditing=true, QgsVectorLayer *vectorLayer=nullptr)
Stops a current editing operation on vectorLayer and discards any uncommitted edits.
void setMapTipTemplate(const QString &mapTipTemplate)
The mapTip is a pretty, html representation for feature information.
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...
void committedAttributesAdded(const QString &layerId, const QList< QgsField > &addedAttributes)
Emitted when attributes are added to the provider if not in transaction mode.
QString attributeAlias(int index) const
Returns the alias of an attribute name or a null string if there is no alias.
void setDefaultValueDefinition(int index, const QgsDefaultValue &definition)
Sets the definition of the expression to use when calculating the default value for a field.
#define QgsDebugMsgLevel(str, level)
virtual bool addAttribute(const QgsField &field)
Adds an attribute field (but does not commit it) returns true if the field was added.
Contains settings for how a map layer will be labeled.
void setFlags(QgsMapLayer::LayerFlags flags)
Returns the flags for this layer.
void committedGeometriesChanges(const QString &layerId, const QgsGeometryMap &changedGeometries)
QString getStyleById(const QString &providerKey, const QString &uri, const QString &styleId, QString &errCause)
Gets a layer style defined by styleId.
Base class for storage of map layer elevation properties.
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
QMap< QString, QgsMapLayer * > mapLayers(const bool validOnly=false) const
Returns a map of all registered layers by layer ID.
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
QHash< QString, QgsFeatureIds > symbolFeatureIdMap() const
Returns the QgsFeatureIds for each symbol.
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified symbology visitor, causing it to visit all symbols associated with the renderer...
Q_INVOKABLE void setCustomProperty(const QString &key, const QVariant &value)
Set a custom property for layer.
void setEnabled(bool enabled)
Sets whether the text buffer will be drawn.
virtual void handlePostCloneOperations(QgsVectorDataProvider *source)
Handles any post-clone operations required after this vector data provider was cloned from the source...
Qgis::VectorEditResult deleteVertex(QgsFeatureId featureId, int vertex)
Deletes a vertex from a feature.
A bundle of parameters controlling aggregate calculation.
Stores information about constraints which may be present on a field.
bool qgsVariantLessThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is less than the second.
QgsMapLayer::ReadFlags mReadFlags
Read flags. It's up to the subclass to respect these when restoring state from XML.
QString encoding() const
Returns the encoding which is used for accessing data.
QgsFields fields() const override=0
Returns the fields associated with this data provider.
void beforeRollBack()
Emitted before changes are rolled back.
void setThreshold(float threshold)
Sets the simplification threshold of the vector layer managed.
SimplifyHint
Simplification flags for fast rendering of features.
virtual bool setSubsetString(const QString &subset, bool updateFeatureCount=true)
Set the subset string used to create a subset of features in the layer.
Context for cascade delete features.
bool writeXml(QDomNode &node, QDomDocument &doc, const QgsReadWriteContext &context) const
Writes the condition styles state to a DOM node.
QgsCoordinateTransformContext transformContext
Coordinate transform context.
virtual bool importNamedStyle(QDomDocument &doc, QString &errorMsg, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories)
Import the properties of this layer from a QDomDocument.
@ None
No flag is defined.
const QgsExpressionNode * rootNode() const
Returns the root node of the expression.
An expression node which takes it value from a feature's field.
virtual bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags())
Adds a single feature to the sink.
@ FlagTrustDataSource
Trust datasource config (primary key unicity, geometry type and srid, etc). Improves provider load ti...
QgsPathResolver pathResolver() const
Returns path resolver object with considering whether the project uses absolute or relative paths and...
@ RenderPoints
Points (e.g., for font sizes)
void beforeEditingStarted()
Emitted before editing on this layer is started.
QgsMapLayerType
Types of layers that can be added to a map.
bool isSqlQuery() const
Returns true if the layer is a query (SQL) layer.
int addExpressionField(const QString &exp, const QgsField &fld)
Add a new field which is calculated by the expression specified.
int count() const
Returns number of items.
Container of fields for a vector layer.
double yMinimum() const SIP_HOLDGIL
Returns the y minimum value (bottom side of rectangle).
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.
void writeCustomProperties(QDomNode &layerNode, QDomDocument &doc) const
Write custom properties to project file.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
T qgsFlagKeysToValue(const QString &keys, const T &defaultValue, bool tryValueAsKey=true, bool *returnOk=nullptr)
Returns the value corresponding to the given keys of a flag.
Qgis::VectorEditResult deleteVertex(QgsFeatureId featureId, int vertex)
Deletes a vertex from a feature.
QgsGeometryOptions * geometryOptions() const
Configuration and logic to apply automatically on any edit happening on this layer.
QSet< QgsMapLayerDependency > dependencies() const FINAL
Gets the list of dependencies.
bool isAuxiliaryField(int index, int &srcIndex) const
Returns true if the field comes from the auxiliary layer, false otherwise.
double yOffset
Vertical offset of label.
void attributeDeleted(int idx)
Will be emitted, when an attribute has been deleted from this vector layer.
@ AddRingNotClosed
The input ring is not closed.
static void mergeScaleDependencies(double mScaleMinDenom, double mScaleMaxDenom, QVariantMap &props)
Merges the local scale limits, if any, with the ones already in the map, if any.
@ AttributeTable
Attribute table settings: choice and order of columns, conditional styling.
QString constraintExpression() const
Returns the constraint expression for the field, if set.
Q_DECL_DEPRECATED QSet< QString > excludeAttributesWms() const
A set of attributes that are not advertised in WMS requests with QGIS server.
Abstract base class for objects which generate elevation profiles.
SimplifyAlgorithm simplifyAlgorithm() const
Gets the local simplification algorithm of the vector layer managed.
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.
@ SelectionIsGreaterThanOne
More than one features were selected.
void setAllowCommit(bool allowCommit)
Controls, if the layer is allowed to commit changes.
bool isCanceled() const SIP_HOLDGIL
Tells whether the operation has been canceled already.
static QString geometryDisplayString(GeometryType type) SIP_HOLDGIL
Returns a display string for a geometry type.
QString constraintExpression(int index) const
Returns the constraint expression for for a specified field index, if set.
virtual bool empty() const
Returns true if the layer does not contain any feature.
The QgsGeometryOptions class contains options to automatically adjust geometries to constraints on a ...
Contains information about the context of a rendering operation.
@ AddToSelection
Add selection to current selection.
void setMinimal() SIP_HOLDGIL
Set a rectangle so that min corner is at max and max corner is at min.
virtual QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context) const
Writes configuration to a DOM element, to be used later with readXml()
static QgsProject * instance()
Returns the QgsProject singleton instance.
void beforeCommitChanges(bool stopEditing)
Emitted before changes are committed to the data provider.
const QgsVectorLayerJoinInfo * joinForFieldIndex(int index, const QgsFields &fields, int &sourceFieldIndex) const
Finds the vector join for a layer field index.
@ Composition
Fix relation, related elements are part of the parent and a parent copy will copy any children or del...
static double rendererFrameRate(const QgsFeatureRenderer *renderer)
Calculates the frame rate (in frames per second) at which the given renderer must be redrawn.
QString typeName() const
Gets the field type.
void setDatabase(const QString &database)
Sets the URI database name.
An interface for classes which can visit style entity (e.g. symbol) nodes (using the visitor pattern)...
bool writeXml(QDomNode &layer_node) const
Writes the actions out in XML format.
bool isSpatial() const FINAL
Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeome...
@ Double
Double value (including negative values)
void readXml(const QDomNode &layer_node)
Reads joins from project file.
bool isValid() const
Returns if this default value should be applied.
virtual QgsTransaction * transaction() const
Returns the transaction this data provider is included in, if any.
virtual bool deleteStyleFromDatabase(const QString &styleId, QString &msgError)
Deletes a style from the database.
QgsAuxiliaryLayer * auxiliaryLayer()
Returns the current auxiliary layer.
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
void setDiagramLayerSettings(const QgsDiagramLayerSettings &s)
void guessDefaultsFromFields(const QgsFields &fields)
Attempts to setup the temporal properties by scanning a set of fields and looking for standard naming...
This class is a composition of two QSettings instances:
long long featureCount() const override=0
Number of features in the layer.
@ Fields
Aliases, widgets, WMS/WFS, expressions, constraints, virtual fields.
Type
The WKB type describes the number of dimensions a geometry has.
virtual QSet< QVariant > uniqueValues(int fieldIndex, int limit=-1) const
Returns the set of unique values contained within the specified fieldIndex from this source.
void setBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering a layer.
void allowCommitChanged()
Emitted whenever the allowCommitChanged() property of this layer changes.
void featureDeleted(QgsFeatureId fid)
Emitted when a feature has been deleted.
virtual bool addFeature(QgsFeature &f)
Adds a feature.
Q_INVOKABLE bool startEditing()
Makes the layer editable.
bool readStyle(const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories) FINAL
void readCustomProperties(const QDomNode &layerNode, const QString &keyStartsWith=QString())
Read custom properties from project file.
void setSimplifyHints(SimplifyHints simplifyHints)
Sets the simplification hints of the vector layer managed.
virtual bool isSaveAndLoadStyleToDatabaseSupported() const
It returns false by default.
This class allows including a set of layers in a database-side transaction, provided the layer data p...
void subsetStringChanged()
Emitted when the layer's subset string has changed.
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
virtual void toSld(QDomNode &parent, const QVariantMap &props) const
Writes the SE 1.1 TextSymbolizer element based on the current layer labeling settings.
void editingStarted()
Emitted when editing on this layer has started.
void setFields(const QgsFields &fields)
Convenience function for setting a fields for the scope.
const QgsDiagramRenderer * diagramRenderer() const
QString capabilitiesString() const
Capabilities for this layer, comma separated and translated.
Constraint
Constraints which may be present on a field.
void updateExpression(int index, const QString &exp)
Changes the expression at a given index.
void editFormConfigChanged()
Will be emitted whenever the edit form configuration of this layer changes.
void dataChanged()
Emitted whenever a change is made to the data provider which may have caused changes in the provider'...
QString htmlMetadata() const FINAL
Obtain a formatted HTML string containing assorted metadata for this layer.
The QgsConditionalLayerStyles class holds conditional style information for a layer....
Line string geometry type, with support for z-dimension and m-values.
QgsCoordinateTransformContext transformContext() const
Returns data provider coordinate transform context.
void layerModified()
Emitted when modifications has been done on layer.
void fullExtentCalculated()
Emitted whenever a deferred extent calculation is completed by the provider.
Q_INVOKABLE QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
virtual QString dataSourceUri(bool expandAuthConfig=false) const
Gets the data source specification.
QgsFieldConstraints::Constraints fieldConstraints(int fieldIndex) const
Returns any constraints which are present at the provider for a specified field index.
void setConstraintExpression(int index, const QString &expression, const QString &description=QString())
Sets the constraint expression for the specified field index.
Q_INVOKABLE QStringList customPropertyKeys() const
Returns list of all keys within custom properties.
QgsVectorDataProviderTemporalCapabilities * temporalCapabilities() override
Returns the provider's temporal capabilities.
void afterCommitChanges()
Emitted after changes are committed to the data provider.
void updateExpressionField(int index, const QString &exp)
Changes the expression used to define an expression based (virtual) field.
QList< int > QgsAttributeList
virtual bool isSqlQuery() const
Returns true if the layer is a query (SQL) layer.
void setAuxiliaryLayer(QgsAuxiliaryLayer *layer=nullptr)
Sets the current auxiliary layer.
@ IntersectSelection
Modify current selection to include only select features which match.
QgsMapLayerLegend * legend() const
Can be nullptr.
void updateFields(QgsFields &fields)
Updates field map with joined attributes.
An interface for objects which generate feature renderers for vector layers.
bool accept(QgsStyleEntityVisitorInterface *visitor) const override
@ AllowOverlapIfRequired
Avoids overlapping labels when possible, but permit overlaps if labels for features cannot otherwise ...
void setLabelsEnabled(bool enabled)
Sets whether labels should be enabled for the layer.
virtual bool deleteAttribute(int attr)
Deletes an attribute field (but does not commit it)
QMap< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrength > fieldConstraintsAndStrength(int fieldIndex) const
Returns a map of constraint with their strength for a specific field of the layer.
static QgsFeatureRenderer * load(QDomElement &symbologyElem, const QgsReadWriteContext &context)
create a renderer from XML element
virtual void setMetadata(const QgsLayerMetadata &metadata)
Sets the layer's metadata store.
void setMergeLines(bool merge)
Sets whether connected line features with identical label text should be merged prior to generating l...
QString joinLayerId() const
ID of the joined layer - may be used to resolve reference to the joined layer.
@ Show
Whether to show the diagram.
void beginEditCommand(const QString &text)
Create edit command for undo/redo operations.
static Q_DECL_DEPRECATED void drawVertexMarker(double x, double y, QPainter &p, Qgis::VertexMarkerType type, int vertexSize)
Draws a vertex symbol at (screen) coordinates x, y.
void removeExpression(int index)
Remove an expression from the buffer.
void setCrs(const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
Sets layer's spatial reference system.
void attributeValueChanged(QgsFeatureId fid, int idx, const QVariant &)
QgsExpressionContext & expressionContext()
Returns the expression context used to evaluate expressions.
A rectangle specified with double values.
@ ConstraintNotNull
Field may not be null.
@ SubsetOfAttributes
Fetch only a subset of attributes (setSubsetOfAttributes sets this flag)
void committedFeaturesAdded(const QString &layerId, const QgsFeatureList &addedFeatures)
Emitted when features are added to the provider if not in transaction mode.
bool commitChanges(QStringList &commitErrors, bool stopEditing=true, QgsVectorLayer *vectorLayer=nullptr)
Attempts to commit to the underlying data provider any buffered changes made since the last to call t...
Rule based labeling for a vector layer.
bool deleteStyleById_t(const QString &uri, QString styleID, QString &errCause)
bool isValid() const
Returns the status of the auxiliary storage currently defined.
void committedAttributesAdded(const QString &layerId, const QList< QgsField > &addedAttributes)
void setFieldConstraint(int index, QgsFieldConstraints::Constraint constraint, QgsFieldConstraints::ConstraintStrength strength=QgsFieldConstraints::ConstraintStrengthHard)
Sets a constraint for a specified field index.
virtual void setEncoding(const QString &e)
Set encoding used for accessing data from layer.
QVariant defaultValue(int index, const QgsFeature &feature=QgsFeature(), QgsExpressionContext *context=nullptr) const
Returns the calculated default value for the specified field index.
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).
void geometryChanged(QgsFeatureId fid, const QgsGeometry &geom)
Emitted when a feature's geometry is changed.
bool mShouldValidateCrs
true if the layer's CRS should be validated and invalid CRSes are not permitted.
QString port() const
Returns the port stored in the URI.
void updateFields(QgsFields &flds) const
Adds fields with the expressions buffered in this object to a QgsFields object.
virtual QVariant defaultValue(int fieldIndex) const
Returns any literal default values which are present at the provider for a specified field index.
void clear()
Clear error messages.
bool isEditable() const FINAL
Returns true if the provider is in editing mode.
QString mProviderKey
Data provider key (name of the data provider)
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
QgsCoordinateReferenceSystem fallbackCrs
Fallback layer coordinate reference system.
int addTopologicalPoints(const QgsGeometry &geom)
Adds topological points for every vertex of the geometry.
QgsFeatureRequest & setExpressionContext(const QgsExpressionContext &context)
Sets the expression context used to evaluate filter expressions.
@ Rendering
Rendering: scale visibility, simplify method, opacity.
QgsFeatureRequest & setFilterFid(QgsFeatureId fid)
Sets the feature ID that should be fetched.
QgsCoordinateTransformContext transformContext() const
Returns data provider coordinate transform context.
@ PositionY
Y-coordinate data defined diagram position.
Base class for utility classes that encapsulate information necessary for rendering of map layers.
ConfigurationFlags configurationFlags
void setEditorWidgetSetup(int index, const QgsEditorWidgetSetup &setup)
The editor widget setup defines which QgsFieldFormatter and editor widget will be used for the field ...
QString providerType() const
Returns the provider type (provider key) for this layer.
const QgsLabelPlacementSettings & placementSettings() const
Returns the label placement settings.
long addTask(QgsTask *task, int priority=0)
Adds a task to the manager.
void readXml(const QDomNode &layer_node)
Reads expressions from project file.
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...
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
void taskCompleted()
Will be emitted by task to indicate its successful completion.
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).
void removeFieldAlias(int index)
Removes an alias (a display name) for attributes to display in dialogs.
void setConstraintStrength(Constraint constraint, ConstraintStrength strength)
Sets the strength of a constraint.
float maximumScale() const
Gets the maximum scale at which the layer should be simplified.
double referenceScale() const
Returns the symbology reference scale.
QgsAuxiliaryLayer * createAuxiliaryLayer(const QgsField &field, QgsVectorLayer *layer) const
Creates an auxiliary layer for a vector layer.
bool qgsVariantGreaterThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is greater than the second.
virtual bool changeGeometry(QgsFeatureId fid, const QgsGeometry &geom)
Change feature's geometry.
bool renameAttribute(int index, const QString &newName)
Renames an attribute field (but does not commit it).
static QgsPainting::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode.
@ SelectAtId
Fast access to features using their ID.
virtual QgsFeatureIds allFeatureIds() const
Returns a list of all feature IDs for features present in the source.
void normalize()
Normalize the rectangle so it has non-negative width/height.
@ GeometryOptions
Geometry validation configuration.
bool writeXml(QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context) const FINAL
Writes vector layer specific state to project file Dom node.
void writeXml(QDomElement &layerElem, QDomDocument &doc) const
Writes the diagram settings to a DOM element.
bool simplifyDrawingCanbeApplied(const QgsRenderContext &renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint) const
Returns whether the VectorLayer can apply the specified simplification hint.
QString targetFieldName() const
Returns name of the field of our layer that will be used for join.
QgsEditorWidgetSetup editorWidgetSetup(int index) const
The editor widget setup defines which QgsFieldFormatter and editor widget will be used for the field ...
void triggerRepaint(bool deferredUpdate=false)
Will advise the map canvas (and any other interested party) that this layer requires to be repainted.
void dataSourceChanged()
Emitted whenever the layer's data source has been changed.
bool deleteStyleById(const QString &providerKey, const QString &uri, const QString &styleId, QString &errCause)
Deletes a layer style defined by styleId.
QgsFeatureIds handledFeatures(QgsVectorLayer *layer) const
Returns a list of feature IDs from the specified layer affected by the delete operation.
double xOffset
Horizontal offset of label.
This is a container for configuration of the attribute table. The configuration is specific for one v...
@ ReadLayerMetadata
Provider can read layer metadata from data store. Since QGIS 3.0. See QgsDataProvider::layerMetadata(...
QgsFields fields() const FINAL
Returns the list of fields of this layer.
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...
double xMaximum() const SIP_HOLDGIL
Returns the x maximum value (right side of rectangle).
QString qgsFlagValueToKeys(const T &value, bool *returnOk=nullptr)
Returns the value for the given keys of a flag.
@ FlagDontResolveLayers
Don't resolve layer paths or create data providers for layers.
Container for all settings relating to text rendering.
void setColor(const QColor &color)
Sets the color that text will be rendered in.
This class wraps a request for features to a vector layer (or directly its vector data provider).
virtual QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context)
Stores renderer properties to an XML element.
QgsMapLayer::LayerFlags flags() const
Returns the flags for this layer.
void setLabeling(QgsAbstractVectorLayerLabeling *labeling)
Sets labeling configuration.
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.
virtual Q_INVOKABLE QgsVectorDataProvider::Capabilities capabilities() const
Returns flags containing the supported capabilities.
QString writePath(const QString &filename) const
Prepare a filename to save it to the project file.
void committedFeaturesAdded(const QString &layerId, const QgsFeatureList &addedFeatures)
QString dataComment() const
Returns a description for this layer as defined in the data provider.
static QgsAbstractVectorLayerLabeling * create(const QDomElement &element, const QgsReadWriteContext &context)
Try to create instance of an implementation based on the XML data.
static QString typeToString(QgsMapLayerType type)
Converts a map layer type to a string value.
static const int EditingCapabilities
Bitmask of all provider's editing capabilities.
QgsLayerMetadata metadata
Allows entering a context category and takes care of leaving this category on deletion of the class....
bool hasEvalError() const
Returns true if an error occurred when evaluating last input.
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 featureBlendModeChanged(QPainter::CompositionMode blendMode)
Signal emitted when setFeatureBlendMode() is called.
virtual void reloadData()
Reloads the data from the source for providers with data caches to synchronize, changes in the data s...
QVariant minimumValue(int index) const override
Returns the minimum value of an attribute.
bool mValid
Indicates if the layer is valid and can be drawn.
const QgsProjectTranslator * projectTranslator() const
Returns the project translator.
void endEditCommand()
Finish edit command and add it to undo/redo stack.
void removeFieldConstraint(int index, QgsFieldConstraints::Constraint constraint)
Removes a constraint for a specified field index.
void committedAttributeValuesChanges(const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues)
Emitted when attribute value changes are saved to the provider if not in transaction mode.
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...
virtual void setExtent(const QgsRectangle &rect)
Sets the extent.
MAYBE_UNUSED NODISCARD QgsReadWriteContextCategoryPopper enterCategory(const QString &category, const QString &details=QString()) const
Push a category to the stack.
@ SelectionIsEmpty
No features were selected.
void readXml(const QDomElement &elem)
Reads the diagram settings from a DOM element.
Q_INVOKABLE bool commitChanges(bool stopEditing=true)
Attempts to commit to the underlying data provider any buffered changes made since the last to call t...
@ Horizontal
Arranges horizontal candidates scattered throughout a polygon feature. Applies to polygon layers only...
void setFieldConfigurationFlags(int index, QgsField::ConfigurationFlags flags)
Sets the configuration flags of the field at given index.
int addTopologicalPoints(const QgsGeometry &geom)
Adds topological points for every vertex of the geometry.
QgsMapLayerTemporalProperties * temporalProperties() override
Returns the layer's temporal properties.
QString username() const
Returns the username stored in the URI.
virtual bool deleteFeature(QgsFeatureId fid)
Delete a feature from the layer (but does not commit it)
void featureDeleted(QgsFeatureId fid)
QStringList commitErrors() const
Returns a list containing any error messages generated when attempting to commit changes to the layer...
void setGeometry(const QgsGeometry &geometry)
Set the feature's geometry.
int translateFeature(QgsFeatureId featureId, double dx, double dy)
Translates feature by dx, dy.
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),...
bool isActive() const
Returns true if the temporal property is active.
QList< QgsRelation > referencedRelations(const QgsVectorLayer *layer=nullptr) const
Gets all relations where this layer is the referenced part (i.e.
QgsAttributeList deletedAttributeIds() const
Returns a list of deleted attributes fields which are not committed.
void committedAttributeValuesChanges(const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues)
bool changeAttributeValues(QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues=QgsAttributeMap())
Changes attributes' values in joined layers.
QString parserErrorString() const
Returns parser error.
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)
void setExtent(const QgsRectangle &rect) FINAL
Sets the extent.
@ FlagLoadDefaultStyle
Reset the layer's style to the default for the datasource.
void reselect()
Reselects the previous set of selected features.
VertexMarkerType
Editing vertex markers, used for showing vertices during a edit operation.
void writeCustomSymbology(QDomElement &element, QDomDocument &doc, QString &errorMessage) const
Signal emitted whenever the symbology (QML-file) for this layer is being written.
Q_INVOKABLE bool deleteSelectedFeatures(int *deletedCount=nullptr, QgsVectorLayer::DeleteContext *context=nullptr)
Deletes the selected features.
static QVariant readVariant(const QDomElement &element)
Read a QVariant from a QDomElement.
bool isValid() const
Returns the validity of this feature.
void selectionChanged(const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect)
Emitted when selection was changed.
Q_INVOKABLE bool rollBack(bool deleteBuffer=true)
Stops a current editing operation and discards any uncommitted edits.
QList< QgsWeakRelation > weakRelations() const
Returns the layer's weak relations as specified in the layer's style.
void readStyleManager(const QDomNode &layerNode)
Read style manager's configuration (if any). To be called by subclasses.
const QList< QgsVectorLayerJoinInfo > vectorJoins() const
void featureAdded(QgsFeatureId fid)
void writeCommonStyle(QDomElement &layerElement, QDomDocument &document, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) const
Write style data common to all layer types.
QgsRectangle sourceExtent() const FINAL
Returns the extent of all geometries from the source.
Q_DECL_DEPRECATED Qgis::GeometryOperationResult addRing(const QVector< QgsPointXY > &ring, QgsFeatureId *featureId=nullptr)
Adds a ring to polygon/multipolygon features.
friend class QgsVectorLayerEditBuffer
Q_DECL_DEPRECATED Qgis::GeometryOperationResult addRing(const QVector< QgsPointXY > &ring, const QgsFeatureIds &targetFeatureIds=QgsFeatureIds(), QgsFeatureId *modifiedFeatureId=nullptr)
Adds a ring to polygon/multipolygon features.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
@ OriginUnknown
It has not been specified where the field comes from.
virtual bool enterUpdateMode()
Enter update mode.
void styleChanged()
Signal emitted whenever a change affects the layer's style.
bool equals(const QgsGeometry &geometry) const
Test if this geometry is exactly equal to another geometry.
void writeXml(QDomNode &node) const
Serialize to XML on layer save.
void repaintRequested(bool deferredUpdate=false)
By emitting this signal the layer tells that either appearance or content have been changed and any v...
const QgsAbstractVectorLayerLabeling * labeling() const
Access to const labeling configuration.
void relationsLoaded()
Emitted when the relations were loaded after reading a project.
Q_INVOKABLE int translateFeature(QgsFeatureId featureId, double dx, double dy)
Translates feature by dx, dy.
virtual QgsRectangle extent() const
Returns the extent of the layer.
@ ConstraintOriginLayer
Constraint was set by layer.
bool readXml(const QDomNode &layerNode)
Reads the stored expressions in in XML format.
void readOnlyChanged()
Emitted when the read only state of this layer is changed.
QString generalHtmlMetadata() const
Returns an HTML fragment containing general metadata information, for use in the htmlMetadata() metho...
Q_INVOKABLE void invertSelectionInRectangle(QgsRectangle &rect)
Inverts selection of features found within the search rectangle (in layer's coordinates)
static QgsMapLayerLegend * defaultVectorLegend(QgsVectorLayer *vl)
Create new legend implementation for vector layer.
T flagValue(const QString &key, const T &defaultValue, const Section section=NoSection)
Returns the setting value for a setting based on a flag.
QgsChangedAttributesMap changedAttributeValues() const
Returns a map of features with changed attributes values which are not committed.
virtual QSet< QgsMapLayerDependency > dependencies() const
Gets the list of layer ids on which this layer depends.
void attributeValueChanged(QgsFeatureId fid, int idx, const QVariant &value)
Emitted whenever an attribute value change is done in the edit buffer.
SpatialIndexPresence
Enumeration of spatial index presence states.
Manages joined fields for a vector layer.
const Q_INVOKABLE QgsFeatureIds & selectedFeatureIds() const
Returns a list of the selected features IDs in this layer.
static QPainter::CompositionMode getCompositionMode(QgsPainting::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode.
QSet< QgsMapLayerDependency > mDependencies
List of layers that may modify this layer on modification.
QList< QgsAction > actions(const QString &actionScope=QString()) const
Returns a list of actions that are available in the given action scope.
void setMaximumScale(double scale)
Sets the maximum map scale (i.e.
@ InvalidLayer
Edit failed due to invalid layer.
QgsDefaultValue defaultValueDefinition
QString constraintDescription(int index) const
Returns the descriptive name for the constraint expression for a specified field index.
virtual void toSld(QDomDocument &doc, QDomElement &element, const QVariantMap &props=QVariantMap()) const
used from subclasses to create SLD Rule elements following SLD v1.1 specs
void afterRollBack()
Emitted after changes are rolled back.
static QgsTaskManager * taskManager()
Returns the application's task manager, used for managing application wide background task handling.
QMap< QgsVectorLayer *, QgsFeatureIds > mHandledFeatures
QSet< QVariant > uniqueValues(int fieldIndex, int limit=-1) const FINAL
Calculates a list of unique values contained within an attribute in the layer.
virtual void setOpacity(double opacity)
Sets the opacity for the layer, where opacity is a value between 0 (totally transparent) and 1....
#define RENDERER_TAG_NAME
void setFormat(const QgsTextFormat &format)
Sets the label text formatting settings, e.g., font settings, buffer settings, etc.
GeometryOperationResult
Success or failure of a geometry operation.
~QgsVectorLayer() override
int size() const
Returns number of items.
FieldOrigin fieldOrigin(int fieldIdx) const
Returns the field's origin (value from an enumeration).
void reload() FINAL
Synchronises with changes in the datasource.
void addExpression(const QString &exp, const QgsField &fld)
Add an expression to the buffer.
QList< QgsFeature > QgsFeatureList
QMap< int, QVariant > QgsAttributeMap
virtual void setTransformContext(const QgsCoordinateTransformContext &transformContext) override
Sets the coordinate transform context to transformContext.
void attributeDeleted(int idx)
QList< QgsRelation > referencingRelations(int idx) const
Returns the layer's relations, where the foreign key is on this layer.
void setDefaultsFromDataProviderTemporalCapabilities(const QgsDataProviderTemporalCapabilities *capabilities) override
Sets the layers temporal settings to appropriate defaults based on a provider's temporal capabilities...
Stores the settings for rendering of all diagrams for a layer.
void committedFeaturesRemoved(const QString &layerId, const QgsFeatureIds &deletedFeatureIds)
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...
@ ConstraintUnique
Field must have a unique value.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
bool addFeatures(QgsFeatureList &features, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) override
Adds a list of features in joined layers.
bool isValid() const
Returns whether this CRS is correctly initialized and usable.
Vector layer specific subclass of QgsMapLayerElevationProperties.
@ OverPoint
Arranges candidates over a point (or centroid of a polygon), or at a preset offset from the point....
bool writeXml(QDomNode &layerNode) const
Writes the stored expressions out in XML format.
bool readExtentFromXml() const
Returns true if the extent is read from the XML document when data source has no metadata,...
Implementation of map layer temporal properties for vector layers.
static QgsRuntimeProfiler * profiler()
Returns the application runtime profiler.
static void warning(const QString &msg)
Goes to qWarning.
void removeExpressionField(int index)
Removes an expression field.
const QgsVectorJoinList & vectorJoins() const
Definition for a property.
virtual QgsFeatureRenderer * createRenderer(const QVariantMap &configuration=QVariantMap()) const
Creates a new vector layer feature renderer, using provider backend specific information.
Encapsulates properties and constraints relating to fetching elevation profiles from different source...
virtual QString storageType() const
Returns the permanent storage type for this layer as a friendly name.
QgsVectorLayerJoinInfo joinInfo() const
Returns information to use for joining with primary key and so on.
const QgsLabelLineSettings & lineSettings() const
Returns the label line settings, which contain settings related to how the label engine places and fo...
QVariant attribute(const QString &name) const
Lookup attribute value by attribute name.
QVariant maximumValue(int index) const FINAL
Returns the maximum value for an attribute column or an invalid variant in case of error.
float threshold() const
Gets the simplification threshold of the vector layer managed.
virtual void rollBack()
Stop editing and discard the edits.
void taskTerminated()
Will be emitted by task if it has terminated for any reason other then completion (e....
QgsFeatureRequest & setFilterFids(const QgsFeatureIds &fids)
Sets the feature IDs that should be fetched.
void removeFeatureRendererGenerator(const QString &id)
Removes the feature renderer with matching id from the layer.
Evaluates and returns the diagram settings relating to a diagram for a specific feature.
QgsActionManager * actions()
Returns all layer actions defined on this layer.
Base class for storage of map layer temporal properties.
QString mDataSource
Data source description string, varies by layer type.
Q_DECL_DEPRECATED Qgis::GeometryOperationResult splitParts(const QVector< QgsPointXY > &splitLine, bool topologicalEditing=false)
Splits parts cut by the given line.
void setDisplayExpression(const QString &displayExpression)
Set the preview expression, used to create a human readable preview string.
QgsVectorLayerEditBufferGroup * editBufferGroup() const
Returns the parent edit buffer group for this edit buffer, or nullptr if not part of a group.
bool writeSld(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QVariantMap &props=QVariantMap()) const
Writes the symbology of the layer into the document provided in SLD 1.1 format.
QList< QgsExpressionFieldBuffer::ExpressionField > expressions() const
void attributeAdded(int idx)
QgsAttributeList primaryKeyAttributes() const
Returns the list of attributes which make up the layer's primary keys.
static QgsStringMap getSvgParameterList(QDomElement &element)
void setMaximumScale(float maximumScale)
Sets the maximum scale at which the layer should be simplified.
Defines left outer join from our vector layer to some other vector layer. The join is done based on [...
void layerModified()
Emitted when modifications has been done on layer.
Buffers information about expression fields for a vector layer.
bool startEditing(QgsVectorLayer *vectorLayer=nullptr)
Makes the layer editable.
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
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.
double xMinimum() const SIP_HOLDGIL
Returns the x minimum value (left side of rectangle).
ConstraintStrength constraintStrength(Constraint constraint) const
Returns the strength of a field constraint, or ConstraintStrengthNotSet if the constraint is not pres...
virtual bool renameAttribute(int attr, const QString &newName)
Renames an attribute field (but does not commit it)
QgsFeatureSource::SpatialIndexPresence hasSpatialIndex() const override
QString constraintDescription() const
Returns the descriptive name for the constraint expression.
virtual Qgis::VectorLayerTypeFlags vectorLayerTypeFlags() const
Returns the vector layer type flags.
bool readSld(const QDomNode &node, QString &errorMessage) FINAL
friend class QgsVectorLayerEditPassthrough
@ AddRingNotInExistingFeature
The input ring doesn't have any existing ring to fit into.
QMap< QgsFeatureId, QgsFeature > QgsFeatureMap
Container for settings relating to a text buffer.
Q_INVOKABLE QgsFeatureList selectedFeatures() const
Returns a copy of the user-selected features.
Q_DECL_DEPRECATED QSet< QString > excludeAttributesWfs() const
A set of attributes that are not advertised in WFS requests with QGIS server.
void mapTipTemplateChanged()
Emitted when the map tip changes.
@ Success
Edit operation was successful.
void removeCustomProperty(const QString &key)
Remove a custom property from layer.
virtual QList< QgsDiagramSettings > diagramSettings() const =0
Returns list with all diagram settings in the renderer.
virtual void saveStyleToDatabase(const QString &name, const QString &description, bool useAsDefault, const QString &uiFileContent, QString &msgError, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories)
Saves named and sld style of the layer to the style table in the db.
QgsFeatureRequest & setNoAttributes()
Set that no attributes will be fetched.
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
QString host() const
Returns the host name stored in the URI.
QSet< QgsFeatureId > QgsFeatureIds
double minimumScale() const
Returns the minimum map scale (i.e.
void rendererChanged()
Signal emitted when renderer is changed.
bool forceLocalOptimization() const
Gets where the simplification executes, after fetch the geometries from provider, or when supported,...
QgsDefaultValue defaultValueDefinition(int index) const
Returns the definition of the expression used when calculating the default value for a field.
double maximumScale() const
Returns the maximum map scale (i.e.
bool removeJoin(const QString &joinLayerId)
Removes a vector layer join.
friend class QgsVectorLayer
virtual void writeXml(QDomElement &layerElem, QDomDocument &doc, const QgsReadWriteContext &context) const =0
Writes diagram state to a DOM element.
This class represents a coordinate reference system (CRS).
QgsFieldConstraints::Constraints fieldConstraints(int fieldIndex) const
Returns any constraints which are present for a specified field index.
QVariant evaluate()
Evaluate the feature and return the result.
Q_INVOKABLE void invertSelection()
Selects not selected features and deselects selected ones.
Abstract base class - its implementations define different approaches to the labeling of a vector lay...
Single scope for storing variables and functions for use within a QgsExpressionContext....
void raiseError(const QString &msg)
Signals an error related to this vector layer.
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings for fast rendering of features.
Utility class that encapsulates an action based on vector attributes.
QVariant minimumValue(int index) const FINAL
Returns the minimum value for an attribute column or an invalid variant in case of error.
static QgsUnitTypes::RenderUnit decodeSldUom(const QString &str, double *scaleFactor=nullptr)
Decodes a SLD unit of measure string to a render unit.
QHash< QString, long long > symbolFeatureCountMap() const
Returns the count for each symbol.
Qgis::UpsideDownLabelHandling upsidedownLabels
Controls whether upside down labels are displayed and how they are handled.
QgsRectangle extent() const FINAL
Returns the extent of the layer.
bool readXml(const QDomNode &layer_node)
Reads the actions in in XML format.
QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
Qgis::VectorLayerTypeFlags vectorLayerTypeFlags() const
Returns the vector layer type flags.
A class to represent a 2D point.
void beforeAddingExpressionField(const QString &fieldName)
Will be emitted, when an expression field is going to be added to this vector layer.
void committedAttributesDeleted(const QString &layerId, const QgsAttributeList &deletedAttributes)
Signals emitted after committing changes.
bool isEmpty() const
Returns true if the configuration is empty, ie it contains no columns.
QgsCurve * clone() const override=0
Clones the geometry by performing a deep copy.
QgsFeatureIterator getSelectedFeatures(QgsFeatureRequest request=QgsFeatureRequest()) const
Returns an iterator of the selected features.
Implementation of QgsAbstractProfileGenerator for vector layers.
void dataChanged()
Data of layer changed.
QString loadStyle(const QString &providerKey, const QString &uri, QString &errCause)
Loads a layer style defined by uri.
bool readXml(const QDomNode &layer_node, QgsReadWriteContext &context) FINAL
Reads vector layer specific state from project file Dom node.
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
void deselect(QgsFeatureId featureId)
Deselects feature by its ID.
SelectBehavior
Specifies how a selection should be applied.
bool commitChanges(QStringList &commitErrors, bool stopEditing=true)
Attempts to commit any changes to disk.
Setting options for loading vector layers.
QgsFeatureIds deletedFeatureIds() const
Returns a list of deleted feature IDs which are not committed.
const QgsDiagramLayerSettings * diagramLayerSettings() const
Renders the diagrams for all features with the same settings.
virtual void setTransformContext(const QgsCoordinateTransformContext &transformContext)
Sets data coordinate transform context to transformContext.
QString publicSource() const
Gets a version of the internal layer definition that has sensitive bits removed (for example,...
FeatureAvailability
Possible return value for hasFeatures() to determine if a source is empty.
QString readPath(const QString &filename) const
Turn filename read from the project file to an absolute path.
bool setAttribute(int field, const QVariant &attr)
Sets an attribute's value by field index.
void displayExpressionChanged()
Emitted when the display expression changes.
QString source() const
Returns the source for the layer.
void editCommandDestroyed()
Signal emitted, when an edit command is destroyed.
QgsVectorLayerElevationProperties * clone() const override
Creates a clone of the properties.
void setDataSource(const QString &dataSource, const QString &baseName, const QString &provider, bool loadDefaultStyleFlag=false)
Updates the data source of the layer.
QMap< QString, QString > QgsStringMap
void writeStyleManager(QDomNode &layerNode, QDomDocument &doc) const
Write style manager's configuration (if exists). To be called by subclasses.
void setBuffer(const QgsTextBufferSettings &bufferSettings)
Sets the text's buffer settings.
QString fieldName
Name of field (or an expression) to use for label text.
void setScaleBasedVisibility(bool enabled)
Sets whether scale based visibility is enabled for the layer.
@ Legend
Legend settings (since QGIS 3.16)
SimplifyAlgorithm
Types of local simplification algorithms that can be used.
void setSimplifyAlgorithm(SimplifyAlgorithm simplifyAlgorithm)
Sets the local simplification algorithm of the vector layer managed.
void setCoordinateSystem()
Setup the coordinate system transformation for the layer.
double yMaximum() const SIP_HOLDGIL
Returns the y maximum value (top side of rectangle).
Q_DECL_DEPRECATED Qgis::GeometryOperationResult splitFeatures(const QVector< QgsPointXY > &splitLine, bool topologicalEditing=false)
Splits features cut by the given line.
Q_INVOKABLE QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
QgsCoordinateTransformContext transformContext() const
Returns the layer data provider coordinate transform context or a default transform context if the la...
Basic implementation of the labeling interface.
bool readXml(const QDomNode &node, const QgsReadWriteContext &context)
Reads the condition styles state from a DOM node.
@ OriginExpression
Field is calculated from an expression.
Aggregate
Available aggregates to calculate.
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.
void cancel() override
Notifies the task that it should terminate.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
static bool fillFromSld(QDomElement &element, Qt::BrushStyle &brushStyle, QColor &color)
void setAttributeTableConfig(const QgsAttributeTableConfig &attributeTableConfig)
Sets the attribute table configuration object.
bool nextFeature(QgsFeature &f)
bool deleteFeatures(const QgsFeatureIds &fids, DeleteContext *context=nullptr)
Deletes a set of features from the layer (but does not commit it)
bool addJoin(const QgsVectorLayerJoinInfo &joinInfo)
Joins another vector layer to this layer.
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.
QVector< QgsPoint > QgsPointSequence
QString attributeDisplayName(int index) const
Convenience function that returns the attribute alias if defined or the field name else.
int listStyles_t(const QString &uri, QStringList &ids, QStringList &names, QStringList &descriptions, QString &errCause)
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
A geometry is the spatial representation of a feature.
virtual void readXml(const QDomElement &elem, const QgsReadWriteContext &context)=0
Reads diagram state from a DOM element.
Q_DECL_DEPRECATED void setExcludeAttributesWfs(const QSet< QString > &att)
A set of attributes that are not advertised in WFS requests with QGIS server.
@ Referencing
The layer is referencing.
void destroyEditCommand()
Destroy active command and reverts all changes in it.
bool qgsVariantEqual(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether they are equal, two NULL values are always treated a...
@ SpatialIndexUnknown
Spatial index presence cannot be determined, index may or may not exist.
void setName(const QString &name)
Set the display name of the layer.
virtual QgsAbstractVectorLayerLabeling * createLabeling(const QVariantMap &configuration=QVariantMap()) const
Creates labeling settings, using provider backend specific information.
Represents a vector layer which manages a vector based data sets.
bool hasGeometry() const
Returns true if the feature has an associated geometry.
double width() const SIP_HOLDGIL
Returns the width of the rectangle.
QList< QgsVectorLayer * > handledLayers(bool includeAuxiliaryLayers=true) const
Returns a list of all layers affected by the delete operation.
void committedAttributesDeleted(const QString &layerId, const QgsAttributeList &deletedAttributes)
Emitted when attributes are deleted from the provider if not in transaction mode.
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)...
void appendChild(QgsRuleBasedLabeling::Rule *rule)
add child rule, take ownership, sets this as parent
void geometryChanged(QgsFeatureId fid, const QgsGeometry &geometry)
Emitted whenever a geometry change is done in the edit buffer.
QgsEditFormConfig editFormConfig
bool setReadOnly(bool readonly=true)
Makes layer read-only (editing disabled) or not.
QVariant maximumValue(int index) const override
Returns the maximum value of an attribute.
Base class for all map layer types. This is the base class for all map layer types (vector,...
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....
void editCommandStarted(const QString &text)
Signal emitted when a new edit command has been started.
Q_DECL_DEPRECATED void setExcludeAttributesWms(const QSet< QString > &att)
A set of attributes that are not advertised in WMS requests with QGIS server.
This class models dependencies with or between map layers.
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.
@ Success
Operation succeeded.
void setReferenceScale(double scale)
Sets the symbology reference scale.
virtual QgsRectangle extent() const =0
Returns the extent of the layer.
QgsAttributeTableConfig attributeTableConfig() const
Returns the attribute table configuration object.
QgsGeometry getGeometry(QgsFeatureId fid) const
Queries the layer for the geometry at the given id.
VectorEditResult
Specifies the result of a vector layer edit operation.
virtual bool changeAttributeValue(QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue=QVariant())
Changed an attribute value (but does not commit it)
void dirtied(const QString &sql, const QString &name)
Emitted if a sql query is executed and the underlying data is modified.
QgsGeometryMap changedGeometries() const
Returns a map of features with changed geometries which are not committed.
T qgsEnumKeyToValue(const QString &key, const T &defaultValue, bool tryValueAsKey=true, bool *returnOk=nullptr)
Returns the value corresponding to the given key of an enum.
static QgsWeakRelation readXml(const QgsVectorLayer *layer, WeakRelationType type, const QDomNode &node, const QgsPathResolver resolver)
Returns a weak relation for the given layer.
void setSize(double size)
Sets the size of the buffer.
void recalculateExtents() const
This is used to send a request that any mapcanvas using this layer update its extents.
double maxCurvedCharAngleIn
Maximum angle between inside curved label characters (valid range 20.0 to 60.0).
void setFieldConfigurationFlag(int index, QgsField::ConfigurationFlag flag, bool active)
Sets the given configuration flag for the field at given index to be active or not.
@ ConstraintExpression
Field has an expression constraint set. See constraintExpression().
QString capabilitiesString() const
Returns the above in friendly format.
void select(QgsFeatureId featureId)
Selects feature by its ID.
Manages stored expressions regarding creation, modification and storing in the project.
QgsConditionalLayerStyles * conditionalStyles() const
Returns the conditional styles that are set for this layer.
static QString quotedColumnRef(QString name)
Returns a quoted column reference (in double quotes)
bool setDependencies(const QSet< QgsMapLayerDependency > &layers) FINAL
Sets the list of dependencies.
bool isExpression
true if this label is made from a expression string, e.g., FieldName || 'mm'
QString database() const
Returns the database name stored in the URI.
FeatureAvailability hasFeatures() const FINAL
Determines if this vector layer has features.
int fieldOriginIndex(int fieldIdx) const
Returns the field's origin index (its meaning is specific to each type of origin).
QgsFieldConstraints constraints
virtual bool commitChanges(QStringList &commitErrors)
Attempts to commit any changes to disk.
static GeometryType geometryType(Type type) SIP_HOLDGIL
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
void styleLoaded(QgsMapLayer::StyleCategories categories)
Emitted when a style has been loaded.
void symbolFeatureCountMapChanged()
Emitted when the feature count for symbols on this layer has been recalculated.
void beforeModifiedCheck() const
Emitted when the layer is checked for modifications. Use for last-minute additions.
void setColor(const QColor &color)
Sets the color for the buffer.
@ LayerConfiguration
General configuration: identifiable, removable, searchable, display expression, read-only.
bool containsJoins() const
Quick way to test if there is any join at all.
Class providing some utility methods to manage auxiliary storage.
QgsVectorLayerFeatureCounter * countSymbolFeatures(bool storeSymbolFids=false)
Count features for symbols.
Q_DECL_DEPRECATED Qgis::GeometryOperationResult addPart(const QVector< QgsPointXY > &ring, QgsFeatureId featureId)
Adds a new part polygon to a multipart feature.
QgsUnitTypes::RenderUnit offsetUnits
Units for offsets of label.
void supportsEditingChanged()
Emitted when the read only state or the data provider of this layer is changed.
@ Referenced
The layer is referenced.
QString uri(bool expandAuthConfig=true) const
Returns the complete URI as a string.
bool deleteFeature(QgsFeatureId fid, QgsVectorLayer::DeleteContext *context=nullptr) const
Deletes a feature from joined layers.
QUndoStack * undoStack()
Returns pointer to layer's undo stack.
bool needsGeometry() const
Returns true if the expression uses feature geometry for some computation.
@ CustomProperties
Custom properties (by plugins for instance)
void setMinimumScale(double scale)
Sets the minimum map scale (i.e.
void setEditFormConfig(const QgsEditFormConfig &editFormConfig)
Sets the editFormConfig (configuration) of the form used to represent this vector layer.
QString storageType() const
Returns the permanent storage type for this layer as a friendly name.
void setSizeUnit(QgsUnitTypes::RenderUnit unit)
Sets the units for the size of rendered text.
Q_DECL_DEPRECATED Qgis::GeometryOperationResult splitFeatures(const QVector< QgsPointXY > &splitLine, bool topologicalEditing=false)
Splits features cut by the given line.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
Q_INVOKABLE void selectByRect(QgsRectangle &rect, Qgis::SelectBehavior behavior=Qgis::SelectBehavior::SetSelection)
Selects features found within the search rectangle (in layer's coordinates)
QString createSavepoint(QString &error)
creates a save point returns empty string on error returns the last created savepoint if it's not dir...
A vector of attributes. Mostly equal to QVector<QVariant>.
SimplifyHints simplifyHints() const
Gets the simplification hints of the vector layer managed.
This is the base class for vector data providers.
@ SetSelection
Set selection, removing any existing selection.
QgsProject * project() const
Returns the parent project if this map layer is added to a project.
QString displayName() const
Returns the name to use when displaying this field.
virtual bool deleteAttribute(int attr)
Deletes an attribute field (but does not commit it).
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Q_INVOKABLE QgsRectangle boundingBoxOfSelected() const
Returns the bounding box of the selected features. If there is no selection, QgsRectangle(0,...
QList< const QgsFeatureRendererGenerator * > featureRendererGenerators() const
Returns a list of the feature renderer generators owned by the layer.
void setProperty(int key, const QgsProperty &property)
Adds a property to the collection and takes ownership of it.
bool deleteFeature(QgsFeatureId fid, DeleteContext *context=nullptr)
Deletes a feature from the layer (but does not commit it).
virtual bool leaveUpdateMode()
Leave update mode.
bool isField() const
Checks whether an expression consists only of a single field reference.
virtual QString subsetString() const
Returns the subset definition string (typically sql) currently in use by the layer and used by the pr...
QVariant aggregate(QgsAggregateCalculator::Aggregate aggregate, const QString &fieldOrExpression, const QgsAggregateCalculator::AggregateParameters ¶meters=QgsAggregateCalculator::AggregateParameters(), QgsExpressionContext *context=nullptr, bool *ok=nullptr, QgsFeatureIds *fids=nullptr, QgsFeedback *feedback=nullptr, QString *error=nullptr) const
Calculates an aggregated value from the layer's features.
QString loadStyle_t(const QString &uri, QString &errCause)
bool readSymbology(const QDomNode &layerNode, QString &errorMessage, QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories) FINAL
Storage and management of actions associated with a layer.
@ PerimeterCurved
Arranges candidates following the curvature of a polygon's boundary. Applies to polygon layers only.
bool writeSymbology(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories) const FINAL
virtual QgsLayerMetadata layerMetadata() const
Returns layer metadata collected from the provider's source.
bool isModified() const override
Returns true if the provider has been modified since the last commit.
bool changeAttributeValue(QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue=QVariant())
Changes attribute value in joined layers.
bool hasParserError() const
Returns true if an error occurred when parsing the input expression.
void updatedFields()
Emitted whenever the fields available from this layer have been changed.
QgsFeature getFeature(QgsFeatureId fid) const
Queries the layer for the feature with the given id.
@ ConstraintOriginProvider
Constraint was set at data provider.
void attributeAdded(int idx)
Will be emitted, when a new attribute has been added to this vector layer.
int selectedFeatureCount() const
Returns the number of features that are selected in this layer.
T enumValue(const QString &key, const T &defaultValue, const Section section=NoSection)
Returns the setting value for a setting based on an enum.
@ PositionX
X-coordinate data defined diagram position.
ConstraintStrength
Strength of constraints.
bool deleteAttributes(const QList< int > &attrs)
Deletes a list of attribute fields (but does not commit it)
static int expressionToLayerFieldIndex(const QString &expression, const QgsVectorLayer *layer)
Attempts to resolve an expression to a field index from the given layer.
void setSize(double size)
Sets the size for rendered text.
virtual bool isClosed() const SIP_HOLDGIL
Returns true if the curve is closed.
int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
double rendererScale() const
Returns the renderer map scale.
bool allowCommit() const
Controls, if the layer is allowed to commit changes.
@ Line
Arranges candidates parallel to a generalised line representing the feature or parallel to a polygon'...
void setValid(bool valid)
Sets whether layer is valid or not.
QgsEditorWidgetSetup editorWidgetSetup() const
Gets the editor widget setup for the field.
QgsExpressionContext createExpressionContext() const FINAL
This method needs to be reimplemented in all classes which implement this interface and return an exp...
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
void renameExpression(int index, const QString &name)
Renames an expression field at a given index.
Class for parsing and evaluation of expressions (formerly called "search strings")....
QgsWkbTypes::Type fallbackWkbType
Fallback geometry type.
Q_DECL_DEPRECATED Qgis::GeometryOperationResult addPart(const QList< QgsPointXY > &ring)
Adds a new part polygon to a multipart feature.
bool updateFeature(QgsFeature &feature, bool skipDefaultValues=false)
Updates an existing feature in the layer, replacing the attributes and geometry for the feature with ...
QString displayExpression
@ RemoveFromSelection
Remove from current selection.
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.
QgsCoordinateReferenceSystem sourceCrs() const FINAL
Returns the coordinate reference system for features in the source.
static QDomElement writeVariant(const QVariant &value, QDomDocument &doc)
Write a QVariant to a QDomElement.
QgsWkbTypes::GeometryType type
void updateFields(QgsFields &fields)
Updates fields.
int mBlockStyleChangedSignal
If non-zero, the styleChanged signal should not be emitted.
Wrapper for iterator of features from vector data provider or vector layer.
QString displayField() const
This is a shorthand for accessing the displayExpression if it is a simple field.
QgsVectorLayer * clone() const override
Returns a new instance equivalent to this one.
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 ...
Q_INVOKABLE QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=QgsFeatureSink::Flags()) FINAL
Adds a single feature to the sink.
Q_INVOKABLE void modifySelection(const QgsFeatureIds &selectIds, const QgsFeatureIds &deselectIds)
Modifies the current selection on this layer.
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified symbology visitor, causing it to visit all symbols associated with the labeling...
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
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)
@ HideFromWfs
Field is not available if layer is served as WFS from QGIS server.
virtual void exportSldStyle(QDomDocument &doc, QString &errorMsg) const
Export the properties of this layer as SLD style in a QDomDocument.
bool useRenderingOptimization() const
Returns true if the rendering optimization (geometry simplification) can be executed.
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 ...
void joinedFieldsChanged()
Emitted whenever the list of joined fields changes (e.g.
void setProviderType(const QString &providerType)
Sets the providerType (provider key)
void resolveReferences(QgsProject *project) FINAL
Resolves references to other layers (kept as layer IDs after reading XML) into layer objects.
QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext) FINAL
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context.
virtual bool changeAttributeValues(QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues)
Changes values of attributes (but does not commit it).
bool removeJoin(const QString &joinLayerId)
Removes a vector layer join.
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.
@ LayerNotEditable
Cannot edit layer.
void setOverlapHandling(Qgis::LabelOverlapHandling handling)
Sets the technique used to handle overlapping labels.
@ InvalidInputGeometryType
The input geometry (ring, part, split line, etc.) has not the correct geometry type.
QString expression() const
Returns the original, unmodified expression string.
QString expressionField(int index) const
Returns the expression used for a given expression field.
Resolves relative paths into absolute paths and vice versa. Used for writing.
Q_INVOKABLE void selectByExpression(const QString &expression, Qgis::SelectBehavior behavior=Qgis::SelectBehavior::SetSelection, QgsExpressionContext *context=nullptr)
Selects matching features using an expression.
void readXml(const QDomNode &node)
Deserialize to XML on layer load.
QgsFeatureMap addedFeatures() const
Returns a map of new features which are not committed.
bool skipCrsValidation
Controls whether the layer is allowed to have an invalid/unknown CRS.
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
void setDefaultsFromLayer(QgsMapLayer *layer) override
Sets default properties based on sensible choices for the given map layer.
@ CreateLabeling
Provider can set labeling settings using backend-specific formatting information. Since QGIS 3....
@ HideFromWms
Field is not available if layer is served as WMS from QGIS server.
void setLegend(QgsMapLayerLegend *legend)
Assign a legend controller to the map layer.
int indexFromName(const QString &fieldName) const
Gets the field index from the field name.
QgsField::ConfigurationFlags fieldConfigurationFlags(int index) const
Returns the configuration flags of the field at given 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...
@ AroundPoint
Arranges candidates in a circle around a point (or centroid of a polygon). Applies to point or polygo...
static QString guessFriendlyIdentifierField(const QgsFields &fields, bool *foundFriendly=nullptr)
Given a set of fields, attempts to pick the "most useful" field for user-friendly identification of f...
void setProviderEncoding(const QString &encoding)
Sets the text encoding of the data provider.
friend class QgsVectorLayerFeatureSource
Q_DECL_DEPRECATED Qgis::GeometryOperationResult splitParts(const QVector< QgsPointXY > &splitLine, bool topologicalEditing=false)
Splits parts cut by the given line.
@ OriginJoin
Field comes from a joined layer (originIndex / 1000 = index of the join, originIndex % 1000 = index w...
virtual bool addFeatures(QgsFeatureList &features)
Insert a copy of the given features into the layer (but does not commit it)
void setFieldAlias(int index, const QString &aliasString)
Sets an alias (a display name) for attributes to display in dialogs.
QgsWkbTypes::Type wkbType() const override=0
Returns the geometry type which is returned by this layer.
void resolveReferences(QgsProject *project)
Resolves layer IDs of joined layers using given project's available layers.
virtual bool isValid() const =0
Returns true if this is a valid layer.
virtual void updateExtents()
Update the extents of the layer.
bool loadAuxiliaryLayer(const QgsAuxiliaryStorage &storage, const QString &key=QString())
Loads the auxiliary layer for this vector layer.
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn.
virtual void readXml(const QDomElement &elem, const QgsReadWriteContext &context)
Reads configuration from a DOM element previously written by writeXml()
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.
Implementation of threaded rendering for vector layers.
void committedFeaturesRemoved(const QString &layerId, const QgsFeatureIds &deletedFeatureIds)
Emitted when features are deleted from the provider if not in transaction mode.
ConstraintOrigin constraintOrigin(Constraint constraint) const
Returns the origin of a field constraint, or ConstraintOriginNotSet if the constraint is not present ...
void addFeatureRendererGenerator(QgsFeatureRendererGenerator *generator)
Adds a new feature renderer generator to the layer.
virtual bool writeXml(QDomElement &collectionElem, const QgsPropertiesDefinition &definitions) const
Writes the current state of the property collection into an XML element.
void committedGeometriesChanges(const QString &layerId, const QgsGeometryMap &changedGeometries)
Emitted when geometry changes are saved to the provider if not in transaction mode.
void setFeatureBlendMode(QPainter::CompositionMode blendMode)
Sets the blending mode used for rendering each feature.
QString getStyleById_t(const QString &uri, QString styleID, QString &errCause)
@ BufferedGroups
Buffered transactional editing means that all editable layers in the buffered transaction group are t...
QStringList names() const
Returns a list with field names.
int indexOf(const QString &fieldName) const
Gets the field index from the field name.
const QgsPathResolver & pathResolver() const
Returns path resolver for conversion between relative and absolute paths.
virtual bool setSubsetString(const QString &subset)
Sets the string (typically sql) used to define a subset of the layer.
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
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
void editCommandEnded()
Signal emitted, when an edit command successfully ended.
virtual QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) const =0
Returns labeling configuration as XML element.
virtual QgsCoordinateReferenceSystem crs() const =0
Returns the coordinate system for the data source.
void setSimplifyMethod(const QgsVectorSimplifyMethod &simplifyMethod)
Sets the simplification settings for fast rendering of features.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
QgsFeatureRenderer * renderer()
Returns the feature renderer used for rendering the features in the layer in 2D map views.
bool addAttribute(const QgsField &field)
Add an attribute field (but does not commit it) returns true if the field was added.
virtual QgsError error() const
Gets current status error.
static QgsRectangle readRectangle(const QDomElement &element)
void readCustomSymbology(const QDomElement &element, QString &errorMessage)
Signal emitted whenever the symbology (QML-file) for this layer is being read.
bool addJoin(const QgsVectorLayerJoinInfo &joinInfo)
Joins another vector layer to this layer.
Encapsulate a field in an attribute table or data source.
QgsMapLayerElevationProperties * elevationProperties() override
Returns the layer's elevation properties.
@ Curved
Arranges candidates following the curvature of a line feature. Applies to line layers only.
void update(const QgsFields &fields)
Update the configuration with the given fields.
void featureAdded(QgsFeatureId fid)
Emitted when a new feature has been added to the layer.