28 #include <QPainterPath> 30 #include <QProgressDialog> 34 #include <QStringBuilder> 35 #if QT_VERSION >= 0x050900 36 #include <QUndoCommand> 98 #ifdef TESTPROVIDERLIB 104 const QString &qmlStyle,
105 const QString &sldStyle,
106 const QString &styleName,
107 const QString &styleDescription,
108 const QString &uiFileContent,
122 QStringList &descriptions,
140 const QString &baseName,
141 const QString &providerKey,
143 :
QgsMapLayer( VectorLayer, baseName, vectorLayerPath )
144 , mProviderKey( providerKey )
145 , mAuxiliaryLayer( nullptr )
146 , mAuxiliaryLayerKey( QString() )
147 , mReadExtentFromXml( options.readExtentFromXml )
153 mJoinBuffer->setParent(
this );
158 if ( !vectorLayerPath.isEmpty() && !mProviderKey.isEmpty() )
173 mSimplifyMethod.
setThreshold( settings.
value( QStringLiteral(
"qgis/simplifyDrawingTol" ), mSimplifyMethod.
threshold() ).toFloat() );
186 delete mDataProvider;
189 delete mExpressionFieldBuffer;
191 delete mDiagramLayerSettings;
192 delete mDiagramRenderer;
197 delete mConditionalStyles;
199 if ( mFeatureCounter )
200 mFeatureCounter->
cancel();
208 QList<QgsVectorLayerJoinInfo> joins =
vectorJoins();
265 auto constraintIt = constraints.constBegin();
266 for ( ; constraintIt != constraints.constEnd(); ++ constraintIt )
348 p.setPen( QColor( 50, 100, 120, 200 ) );
349 p.setBrush( QColor( 200, 200, 210, 120 ) );
350 p.drawEllipse( x - m, y - m, m * 2 + 1, m * 2 + 1 );
354 p.setPen( QColor( 255, 0, 0 ) );
355 p.drawLine( x - m, y + m, x + m, y - m );
356 p.drawLine( x - m, y - m, x + m, y + m );
362 mSelectedFeatureIds.insert( fid );
369 mSelectedFeatureIds.unite( featureIds );
376 mSelectedFeatureIds.remove( fid );
383 mSelectedFeatureIds.subtract( featureIds );
396 .setFilterRect( rect )
403 newSelection << feat.
id();
432 newSelection << feat.
id();
454 bool matches = exp.
evaluate( &context ).toBool();
458 newSelection << feat.
id();
462 newSelection << feat.
id();
481 newSelection = mSelectedFeatureIds + ids;
485 newSelection = mSelectedFeatureIds - ids;
489 newSelection = mSelectedFeatureIds.intersect( ids );
493 QgsFeatureIds deselectedFeatures = mSelectedFeatureIds - newSelection;
494 mSelectedFeatureIds = newSelection;
502 if ( !intersectingIds.isEmpty() )
504 QgsDebugMsgLevel( QStringLiteral(
"Trying to select and deselect the same item at the same time. Unsure what to do. Selecting dubious items." ), 3 );
507 mSelectedFeatureIds -= deselectIds;
508 mSelectedFeatureIds += selectIds;
516 ids.subtract( mSelectedFeatureIds );
531 .setFilterRect( rect )
541 if ( mSelectedFeatureIds.contains( fet.
id() ) )
543 deselectIds << fet.
id();
547 selectIds << fet.
id();
556 if ( mSelectedFeatureIds.isEmpty() )
564 return mDataProvider;
569 return mDataProvider;
574 if (
mValid && mDataProvider && mDataProvider->
encoding() != encoding )
583 delete mDiagramRenderer;
584 mDiagramRenderer = r;
591 if (
mValid && mDataProvider )
597 QgsDebugMsgLevel( QStringLiteral(
"invalid layer or pointer to mDataProvider is null" ), 3 );
607 QgsDebugMsg( QStringLiteral(
"WARNING: This code should never be reached. Problems may occur..." ) );
631 .setFilterFids( mSelectedFeatureIds )
649 if ( mSelectedFeatureIds.contains( fet.
id() ) )
660 if ( retval.
width() == 0.0 || retval.
height() == 0.0 )
669 retval.
set( -1.0, -1.0, 1.0, 1.0 );
678 return mLabelsEnabled &&
static_cast< bool >( mLabeling );
683 mLabelsEnabled = enabled;
688 if ( !mDiagramRenderer || !mDiagramLayerSettings )
691 QList<QgsDiagramSettings> settingList = mDiagramRenderer->
diagramSettings();
692 if ( !settingList.isEmpty() )
694 return settingList.at( 0 ).enabled;
701 if ( !mSymbolFeatureCounted )
704 return mSymbolFeatureCountMap.value( legendKey );
709 if ( mSymbolFeatureCounted || mFeatureCounter )
710 return mFeatureCounter;
712 mSymbolFeatureCountMap.clear();
717 return mFeatureCounter;
719 if ( !mDataProvider )
722 return mFeatureCounter;
727 return mFeatureCounter;
730 if ( !mFeatureCounter )
739 return mFeatureCounter;
745 if ( force || !mReadExtentFromXml || ( mReadExtentFromXml && mXmlExtent.
isNull() ) )
746 mValidExtent =
false;
757 if ( !mDefaultValueOnUpdateFields.isEmpty() )
762 int size = mFields.
size();
763 for (
int idx : qgis::as_const( mDefaultValueOnUpdateFields ) )
765 if ( idx < 0 || idx >= size )
783 if ( !mValidExtent && mLazyExtent && mDataProvider && !mDataProvider->
hasMetadata() && mReadExtentFromXml && !mXmlExtent.
isNull() )
790 if ( !mValidExtent && mLazyExtent && mDataProvider )
807 if ( !
mValid || !mDataProvider )
809 QgsDebugMsgLevel( QStringLiteral(
"invoked with invalid layer or null mDataProvider" ), 3 );
831 if ( it->hasGeometry() )
877 if ( !
mValid || !mDataProvider )
879 QgsDebugMsgLevel( QStringLiteral(
"invoked with invalid layer or null mDataProvider" ), 3 );
887 if ( !
mValid || !mDataProvider )
889 QgsDebugMsgLevel( QStringLiteral(
"invoked with invalid layer or null mDataProvider" ), 3 );
916 double maximumSimplificationScale = mSimplifyMethod.
maximumScale();
919 return !( maximumSimplificationScale > 1 && renderContext.
rendererScale() <= maximumSimplificationScale );
926 return mConditionalStyles;
931 if ( !
mValid || !mDataProvider )
939 if ( !
mValid || !mEditBuffer || !mDataProvider )
942 bool success = mEditBuffer->
addFeature( feature );
957 if ( !mEditBuffer || !mDataProvider )
963 if ( currentFeature.
isValid() )
965 bool hasChanged =
false;
966 bool hasError =
false;
976 QgsDebugMsgLevel( QStringLiteral(
"geometry of feature %1 could not be changed." ).arg( updatedFeature.
id() ), 3 );
983 for (
int attr = 0; attr < fa.count(); ++attr )
985 if ( fa.at( attr ) != ca.at( attr ) )
993 QgsDebugMsgLevel( QStringLiteral(
"attribute %1 of feature %2 could not be changed." ).arg( attr ).arg( updatedFeature.
id() ), 3 );
998 if ( hasChanged && !mDefaultValueOnUpdateFields.isEmpty() && !skipDefaultValues )
999 updateDefaultValues( updatedFeature.
id(), updatedFeature );
1005 QgsDebugMsgLevel( QStringLiteral(
"feature %1 could not be retrieved" ).arg( updatedFeature.
id() ), 3 );
1013 if ( !
mValid || !mEditBuffer || !mDataProvider )
1017 bool result = utils.
insertVertex( x, y, atFeatureId, beforeVertex );
1026 if ( !
mValid || !mEditBuffer || !mDataProvider )
1030 bool result = utils.
insertVertex( point, atFeatureId, beforeVertex );
1039 if ( !
mValid || !mEditBuffer || !mDataProvider )
1043 bool result = utils.
moveVertex( x, y, atFeatureId, atVertex );
1052 if ( !
mValid || !mEditBuffer || !mDataProvider )
1056 bool result = utils.
moveVertex( p, atFeatureId, atVertex );
1065 if ( !
mValid || !mEditBuffer || !mDataProvider )
1090 int count = mSelectedFeatureIds.size();
1103 *deletedCount = deleted;
1106 return deleted == count;
1111 if ( !
mValid || !mEditBuffer || !mDataProvider )
1112 return QgsGeometry::OperationResult::LayerNotEditable;
1118 if ( !mSelectedFeatureIds.isEmpty() )
1120 result = utils.
addRing( ring, mSelectedFeatureIds, featureId );
1123 if ( result != QgsGeometry::OperationResult::Success )
1134 if ( !
mValid || !mEditBuffer || !mDataProvider )
1137 return QgsGeometry::OperationResult::LayerNotEditable;
1142 return QgsGeometry::OperationResult::InvalidInputGeometryType;
1148 return QgsGeometry::OperationResult::AddRingNotClosed;
1155 if ( !mSelectedFeatureIds.isEmpty() )
1157 result = utils.
addRing( static_cast< QgsCurve * >( ring->
clone() ), mSelectedFeatureIds, featureId );
1160 if ( result != QgsGeometry::OperationResult::Success )
1172 if ( !
mValid || !mEditBuffer || !mDataProvider )
1173 return QgsGeometry::OperationResult::LayerNotEditable;
1177 if ( mSelectedFeatureIds.empty() )
1180 return QgsGeometry::OperationResult::SelectionIsEmpty;
1182 else if ( mSelectedFeatureIds.size() > 1 )
1185 return QgsGeometry::OperationResult::SelectionIsGreaterThanOne;
1191 if ( result == QgsGeometry::OperationResult::Success )
1198 if ( !
mValid || !mEditBuffer || !mDataProvider )
1199 return QgsGeometry::OperationResult::LayerNotEditable;
1203 if ( mSelectedFeatureIds.empty() )
1206 return QgsGeometry::OperationResult::SelectionIsEmpty;
1208 else if ( mSelectedFeatureIds.size() > 1 )
1211 return QgsGeometry::OperationResult::SelectionIsGreaterThanOne;
1217 if ( result == QgsGeometry::OperationResult::Success )
1224 if ( !
mValid || !mEditBuffer || !mDataProvider )
1225 return QgsGeometry::OperationResult::LayerNotEditable;
1229 if ( mSelectedFeatureIds.empty() )
1232 return QgsGeometry::OperationResult::SelectionIsEmpty;
1234 else if ( mSelectedFeatureIds.size() > 1 )
1237 return QgsGeometry::OperationResult::SelectionIsGreaterThanOne;
1243 if ( result == QgsGeometry::OperationResult::Success )
1250 if ( !
mValid || !mEditBuffer || !mDataProvider )
1251 return QgsGeometry::OperationResult::LayerNotEditable;
1256 if ( result == QgsGeometry::OperationResult::Success )
1263 if ( !
mValid || !mEditBuffer || !mDataProvider )
1264 return QgsGeometry::OperationResult::LayerNotEditable;
1267 return utils.
splitParts( splitLine, topologicalEditing );
1272 if ( !
mValid || !mEditBuffer || !mDataProvider )
1273 return QgsGeometry::OperationResult::LayerNotEditable;
1276 return utils.
splitFeatures( splitLine, topologicalEditing );
1281 if ( !
mValid || !mEditBuffer || !mDataProvider )
1290 if ( !
mValid || !mEditBuffer || !mDataProvider )
1299 if ( mLabeling == labeling )
1308 if ( !
mValid || !mDataProvider )
1373 QDomNode pkeyNode = layer_node.namedItem( QStringLiteral(
"provider" ) );
1375 if ( pkeyNode.isNull() )
1377 mProviderKey.clear();
1381 QDomElement pkeyElt = pkeyNode.toElement();
1382 mProviderKey = pkeyElt.text();
1386 if ( !mProviderKey.isNull() )
1391 else if (
mDataSource.contains( QLatin1String(
"dbname=" ) ) )
1393 mProviderKey = QStringLiteral(
"postgres" );
1397 mProviderKey = QStringLiteral(
"ogr" );
1401 if ( !setDataProvider( mProviderKey, options ) )
1406 QDomElement pkeyElem = pkeyNode.toElement();
1407 if ( !pkeyElem.isNull() )
1409 QString encodingString = pkeyElem.attribute( QStringLiteral(
"encoding" ) );
1410 if ( !encodingString.isEmpty() )
1417 mJoinBuffer->
readXml( layer_node );
1429 QDomNode depsNode = layer_node.namedItem( QStringLiteral(
"dataDependencies" ) );
1430 QDomNodeList depsNodes = depsNode.childNodes();
1431 QSet<QgsMapLayerDependency> sources;
1432 for (
int i = 0; i < depsNodes.count(); i++ )
1434 QString
source = depsNodes.at( i ).toElement().attribute( QStringLiteral(
"id" ) );
1440 QDomElement legendElem = layer_node.firstChildElement( QStringLiteral(
"legend" ) );
1441 if ( !legendElem.isNull() )
1442 legend->
readXml( legendElem, context );
1446 if ( mReadExtentFromXml )
1448 QDomNode extentNode = layer_node.namedItem( QStringLiteral(
"extent" ) );
1449 if ( !extentNode.isNull() )
1456 const QDomNode asNode = layer_node.namedItem( QStringLiteral(
"auxiliaryLayer" ) );
1457 const QDomElement asElem = asNode.toElement();
1458 if ( !asElem.isNull() )
1460 mAuxiliaryLayerKey = asElem.attribute( QStringLiteral(
"key" ) );
1471 setDataSource( dataSource, baseName, provider, options, loadDefaultStyleFlag );
1480 setDataProvider( provider, options );
1491 bool defaultLoadedFlag =
false;
1496 std::unique_ptr< QgsFeatureRenderer > defaultRenderer( mDataProvider->
createRenderer() );
1497 if ( defaultRenderer )
1499 defaultLoadedFlag =
true;
1506 if ( !defaultLoadedFlag && loadDefaultStyleFlag )
1512 if ( !defaultLoadedFlag &&
isSpatial() )
1529 std::unique_ptr< QgsFeatureRenderer > defaultRenderer( mDataProvider->
createRenderer() );
1530 if ( defaultRenderer )
1544 mProviderKey = provider;
1548 QString checkUnicityKey = QStringLiteral(
"checkPrimaryKeyUnicity" );
1550 if ( provider.compare( QLatin1String(
"postgres" ) ) == 0 )
1554 if ( uri.
hasParam( checkUnicityKey ) )
1557 uri.
setParam( checkUnicityKey, mReadExtentFromXml ?
"0" :
"1" );
1558 dataSource = uri.
uri(
false );
1561 delete mDataProvider;
1563 if ( !mDataProvider )
1569 mDataProvider->setParent(
this );
1572 QgsDebugMsgLevel( QStringLiteral(
"Instantiated the data provider plugin" ), 2 );
1584 QgsDebugMsgLevel( QString(
"Set Data provider QgsLayerMetadata identifier[%1]" ).arg(
metadata().identifier() ), 4 );
1591 mWkbType = mDataProvider->
wkbType();
1595 if ( mProviderKey == QLatin1String(
"postgres" ) )
1600 QRegExp reg( R
"lit("[^"]+"\."([^"] + )"( \([^)]+\))?)lit" ); 1601 if ( reg.indexIn(
name() ) >= 0 )
1603 QStringList stuff = reg.capturedTexts();
1604 QString lName = stuff[1];
1608 QMap<QString, QgsMapLayer *>::const_iterator it;
1609 for ( it = layers.constBegin(); it != layers.constEnd() && ( *it )->name() != lName; ++it )
1612 if ( it != layers.constEnd() && stuff.size() > 2 )
1614 lName +=
'.' + stuff[2].mid( 2, stuff[2].length() - 3 );
1617 if ( !lName.isEmpty() )
1626 if ( dataProviderUri.hasParam( checkUnicityKey ) )
1630 else if ( mProviderKey == QLatin1String(
"osm" ) )
1635 else if ( provider == QLatin1String(
"ogr" ) )
1639 if (
mDataSource.right( 10 ) == QLatin1String(
"|layerid=0" ) )
1642 else if ( provider == QStringLiteral(
"memory" ) )
1659 QDomDocument &document,
1664 QDomElement mapLayerNode = layer_node.toElement();
1666 if ( mapLayerNode.isNull() || (
"maplayer" != mapLayerNode.nodeName() ) )
1672 mapLayerNode.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"vector" ) );
1678 if ( mDataProvider )
1680 QDomElement provider = document.createElement( QStringLiteral(
"provider" ) );
1681 provider.setAttribute( QStringLiteral(
"encoding" ), mDataProvider->
encoding() );
1682 QDomText providerText = document.createTextNode(
providerType() );
1683 provider.appendChild( providerText );
1684 layer_node.appendChild( provider );
1688 mJoinBuffer->
writeXml( layer_node, document );
1691 QDomElement dependenciesElement = document.createElement( QStringLiteral(
"layerDependencies" ) );
1696 QDomElement depElem = document.createElement( QStringLiteral(
"layer" ) );
1697 depElem.setAttribute( QStringLiteral(
"id" ), dep.
layerId() );
1698 dependenciesElement.appendChild( depElem );
1700 layer_node.appendChild( dependenciesElement );
1703 QDomElement dataDependenciesElement = document.createElement( QStringLiteral(
"dataDependencies" ) );
1708 QDomElement depElem = document.createElement( QStringLiteral(
"layer" ) );
1709 depElem.setAttribute( QStringLiteral(
"id" ), dep.
layerId() );
1710 dataDependenciesElement.appendChild( depElem );
1712 layer_node.appendChild( dataDependenciesElement );
1717 QDomElement legendElement =
legend()->
writeXml( document, context );
1718 if ( !legendElement.isNull() )
1719 layer_node.appendChild( legendElement );
1723 mExpressionFieldBuffer->
writeXml( layer_node, document );
1728 QDomElement asElem = document.createElement( QStringLiteral(
"auxiliaryLayer" ) );
1729 if ( mAuxiliaryLayer )
1731 const QString pkField = mAuxiliaryLayer->joinInfo().targetFieldName();
1732 asElem.setAttribute( QStringLiteral(
"key" ), pkField );
1734 layer_node.appendChild( asElem );
1738 return writeSymbology( layer_node, document, errorMsg, context );
1743 QString src( source );
1755 QStringList theURIParts = src.split(
'|' );
1757 src = theURIParts.join( QStringLiteral(
"|" ) );
1761 QStringList theURIParts = src.split(
'?' );
1763 src = theURIParts.join( QStringLiteral(
"?" ) );
1765 else if (
providerType() == QLatin1String(
"delimitedtext" ) )
1767 QUrl urlSource = QUrl::fromEncoded( src.toLatin1() );
1769 urlDest.setQueryItems( urlSource.queryItems() );
1770 src = QString::fromLatin1( urlDest.toEncoded() );
1772 else if (
providerType() == QLatin1String(
"memory" ) )
1787 QString src( source );
1789 if ( provider == QLatin1String(
"spatialite" ) )
1795 else if ( provider == QLatin1String(
"ogr" ) )
1797 QStringList theURIParts = src.split(
'|' );
1799 src = theURIParts.join( QStringLiteral(
"|" ) );
1801 else if ( provider == QLatin1String(
"gpx" ) )
1803 QStringList theURIParts = src.split(
'?' );
1805 src = theURIParts.join( QStringLiteral(
"?" ) );
1807 else if ( provider == QLatin1String(
"delimitedtext" ) )
1809 QUrl urlSource = QUrl::fromEncoded( src.toLatin1() );
1811 if ( !src.startsWith( QLatin1String(
"file:" ) ) )
1813 QUrl file = QUrl::fromLocalFile( src.left( src.indexOf(
'?' ) ) );
1814 urlSource.setScheme( QStringLiteral(
"file" ) );
1815 urlSource.setPath( file.path() );
1818 QUrl urlDest = QUrl::fromLocalFile( context.
pathResolver().
readPath( urlSource.toLocalFile() ) );
1819 urlDest.setQueryItems( urlSource.queryItems() );
1820 src = QString::fromLatin1( urlDest.toEncoded() );
1843 if ( !mExpressionFieldBuffer )
1845 mExpressionFieldBuffer->
readXml( layerNode );
1849 QDomElement layerElement = layerNode.toElement();
1852 readStyle( layerNode, errorMessage, context );
1854 mDisplayExpression = layerNode.namedItem( QStringLiteral(
"previewExpression" ) ).toElement().text();
1855 mMapTipTemplate = layerNode.namedItem( QStringLiteral(
"mapTip" ) ).toElement().text();
1857 QString
displayField = layerNode.namedItem( QStringLiteral(
"displayfield" ) ).toElement().text();
1863 if ( mMapTipTemplate.isEmpty() )
1864 mMapTipTemplate = displayField;
1868 if ( mDisplayExpression.isEmpty() )
1873 mActions->
readXml( layerNode );
1875 mAttributeAliasMap.clear();
1876 QDomNode aliasesNode = layerNode.namedItem( QStringLiteral(
"aliases" ) );
1877 if ( !aliasesNode.isNull() )
1879 QDomElement aliasElem;
1881 QDomNodeList aliasNodeList = aliasesNode.toElement().elementsByTagName( QStringLiteral(
"alias" ) );
1882 for (
int i = 0; i < aliasNodeList.size(); ++i )
1884 aliasElem = aliasNodeList.at( i ).toElement();
1887 if ( aliasElem.hasAttribute( QStringLiteral(
"field" ) ) )
1889 field = aliasElem.attribute( QStringLiteral(
"field" ) );
1893 int index = aliasElem.attribute( QStringLiteral(
"index" ) ).toInt();
1895 if ( index >= 0 && index <
fields().count() )
1899 mAttributeAliasMap.insert( field, aliasElem.attribute( QStringLiteral(
"name" ) ) );
1904 mDefaultExpressionMap.clear();
1905 QDomNode defaultsNode = layerNode.namedItem( QStringLiteral(
"defaults" ) );
1906 if ( !defaultsNode.isNull() )
1908 QDomNodeList defaultNodeList = defaultsNode.toElement().elementsByTagName( QStringLiteral(
"default" ) );
1909 for (
int i = 0; i < defaultNodeList.size(); ++i )
1911 QDomElement defaultElem = defaultNodeList.at( i ).toElement();
1913 QString field = defaultElem.attribute( QStringLiteral(
"field" ), QString() );
1914 QString expression = defaultElem.attribute( QStringLiteral(
"expression" ), QString() );
1915 bool applyOnUpdate = defaultElem.attribute( QStringLiteral(
"applyOnUpdate" ), QStringLiteral(
"0" ) ) == QLatin1String(
"1" );
1916 if ( field.isEmpty() || expression.isEmpty() )
1919 mDefaultExpressionMap.insert( field,
QgsDefaultValue( expression, applyOnUpdate ) );
1924 mFieldConstraints.clear();
1925 mFieldConstraintStrength.clear();
1926 QDomNode constraintsNode = layerNode.namedItem( QStringLiteral(
"constraints" ) );
1927 if ( !constraintsNode.isNull() )
1929 QDomNodeList constraintNodeList = constraintsNode.toElement().elementsByTagName( QStringLiteral(
"constraint" ) );
1930 for (
int i = 0; i < constraintNodeList.size(); ++i )
1932 QDomElement constraintElem = constraintNodeList.at( i ).toElement();
1934 QString field = constraintElem.attribute( QStringLiteral(
"field" ), QString() );
1935 int constraints = constraintElem.attribute( QStringLiteral(
"constraints" ), QStringLiteral(
"0" ) ).toInt();
1936 if ( field.isEmpty() || constraints == 0 )
1939 mFieldConstraints.insert( field, static_cast< QgsFieldConstraints::Constraints >( constraints ) );
1941 int uniqueStrength = constraintElem.attribute( QStringLiteral(
"unique_strength" ), QStringLiteral(
"1" ) ).toInt();
1942 int notNullStrength = constraintElem.attribute( QStringLiteral(
"notnull_strength" ), QStringLiteral(
"1" ) ).toInt();
1943 int expStrength = constraintElem.attribute( QStringLiteral(
"exp_strength" ), QStringLiteral(
"1" ) ).toInt();
1950 mFieldConstraintExpressions.clear();
1951 QDomNode constraintExpressionsNode = layerNode.namedItem( QStringLiteral(
"constraintExpressions" ) );
1952 if ( !constraintExpressionsNode.isNull() )
1954 QDomNodeList constraintNodeList = constraintExpressionsNode.toElement().elementsByTagName( QStringLiteral(
"constraint" ) );
1955 for (
int i = 0; i < constraintNodeList.size(); ++i )
1957 QDomElement constraintElem = constraintNodeList.at( i ).toElement();
1959 QString field = constraintElem.attribute( QStringLiteral(
"field" ), QString() );
1960 QString exp = constraintElem.attribute( QStringLiteral(
"exp" ), QString() );
1961 QString desc = constraintElem.attribute( QStringLiteral(
"desc" ), QString() );
1962 if ( field.isEmpty() || exp.isEmpty() )
1965 mFieldConstraintExpressions.insert( field, qMakePair( exp, desc ) );
1972 mExcludeAttributesWMS.clear();
1973 QDomNode excludeWMSNode = layerNode.namedItem( QStringLiteral(
"excludeAttributesWMS" ) );
1974 if ( !excludeWMSNode.isNull() )
1976 QDomNodeList attributeNodeList = excludeWMSNode.toElement().elementsByTagName( QStringLiteral(
"attribute" ) );
1977 for (
int i = 0; i < attributeNodeList.size(); ++i )
1979 mExcludeAttributesWMS.insert( attributeNodeList.at( i ).toElement().text() );
1983 mExcludeAttributesWFS.clear();
1984 QDomNode excludeWFSNode = layerNode.namedItem( QStringLiteral(
"excludeAttributesWFS" ) );
1985 if ( !excludeWFSNode.isNull() )
1987 QDomNodeList attributeNodeList = excludeWFSNode.toElement().elementsByTagName( QStringLiteral(
"attribute" ) );
1988 for (
int i = 0; i < attributeNodeList.size(); ++i )
1990 mExcludeAttributesWFS.insert( attributeNodeList.at( i ).toElement().text() );
1995 QDomElement widgetsElem = layerNode.namedItem( QStringLiteral(
"fieldConfiguration" ) ).toElement();
1997 QDomNodeList fieldConfigurationElementList = widgetsElem.elementsByTagName( QStringLiteral(
"field" ) );
1999 for (
int i = 0; i < fieldConfigurationElementList.size(); ++i )
2001 const QDomElement fieldConfigElement = fieldConfigurationElementList.at( i ).toElement();
2002 const QDomElement fieldWidgetElement = fieldConfigElement.elementsByTagName( QStringLiteral(
"editWidget" ) ).at( 0 ).toElement();
2004 QString fieldName = fieldConfigElement.attribute( QStringLiteral(
"name" ) );
2006 const QString widgetType = fieldWidgetElement.attribute( QStringLiteral(
"type" ) );
2007 const QDomElement cfgElem = fieldConfigElement.elementsByTagName( QStringLiteral(
"config" ) ).at( 0 ).toElement();
2008 const QDomElement optionsElem = cfgElem.childNodes().at( 0 ).toElement();
2011 mFieldWidgetSetups[fieldName] = setup;
2014 mEditFormConfig.
readXml( layerNode, context );
2016 mAttributeTableConfig.
readXml( layerNode );
2018 mConditionalStyles->
readXml( layerNode, context );
2022 QDomElement mapLayerNode = layerNode.toElement();
2023 if ( mapLayerNode.attribute( QStringLiteral(
"readOnly" ), QStringLiteral(
"0" ) ).toInt() == 1 )
2040 if ( !rendererElement.isNull() )
2060 QDomElement labelingElement = node.firstChildElement( QStringLiteral(
"labeling" ) );
2062 if ( labelingElement.isNull() ||
2063 ( labelingElement.attribute( QStringLiteral(
"type" ) ) == QLatin1String(
"simple" ) && labelingElement.firstChildElement( QStringLiteral(
"settings" ) ).isNull() ) )
2071 labeling = readLabelingFromCustomProperties();
2079 if ( node.toElement().hasAttribute( QStringLiteral(
"labelsEnabled" ) ) )
2080 mLabelsEnabled = node.toElement().attribute( QStringLiteral(
"labelsEnabled" ) ).toInt();
2082 mLabelsEnabled =
true;
2085 QDomNode blendModeNode = node.namedItem( QStringLiteral(
"blendMode" ) );
2086 if ( !blendModeNode.isNull() )
2088 QDomElement e = blendModeNode.toElement();
2093 QDomNode featureBlendModeNode = node.namedItem( QStringLiteral(
"featureBlendMode" ) );
2094 if ( !featureBlendModeNode.isNull() )
2096 QDomElement e = featureBlendModeNode.toElement();
2101 QDomNode layerTransparencyNode = node.namedItem( QStringLiteral(
"layerTransparency" ) );
2102 if ( !layerTransparencyNode.isNull() )
2104 QDomElement e = layerTransparencyNode.toElement();
2105 setOpacity( 1.0 - e.text().toInt() / 100.0 );
2107 QDomNode layerOpacityNode = node.namedItem( QStringLiteral(
"layerOpacity" ) );
2108 if ( !layerOpacityNode.isNull() )
2110 QDomElement e = layerOpacityNode.toElement();
2114 QDomElement e = node.toElement();
2117 mSimplifyMethod.
setSimplifyHints( static_cast< QgsVectorSimplifyMethod::SimplifyHints >( e.attribute( QStringLiteral(
"simplifyDrawingHints" ), QStringLiteral(
"1" ) ).toInt() ) );
2118 mSimplifyMethod.
setSimplifyAlgorithm( static_cast< QgsVectorSimplifyMethod::SimplifyAlgorithm >( e.attribute( QStringLiteral(
"simplifyAlgorithm" ), QStringLiteral(
"0" ) ).toInt() ) );
2119 mSimplifyMethod.
setThreshold( e.attribute( QStringLiteral(
"simplifyDrawingTol" ), QStringLiteral(
"1" ) ).toFloat() );
2120 mSimplifyMethod.
setForceLocalOptimization( e.attribute( QStringLiteral(
"simplifyLocal" ), QStringLiteral(
"1" ) ).toInt() );
2121 mSimplifyMethod.
setMaximumScale( e.attribute( QStringLiteral(
"simplifyMaxScale" ), QStringLiteral(
"1" ) ).toFloat() );
2124 delete mDiagramRenderer;
2125 mDiagramRenderer =
nullptr;
2126 QDomElement singleCatDiagramElem = node.firstChildElement( QStringLiteral(
"SingleCategoryDiagramRenderer" ) );
2127 if ( !singleCatDiagramElem.isNull() )
2130 mDiagramRenderer->
readXml( singleCatDiagramElem, context );
2132 QDomElement linearDiagramElem = node.firstChildElement( QStringLiteral(
"LinearlyInterpolatedDiagramRenderer" ) );
2133 if ( !linearDiagramElem.isNull() )
2135 if ( linearDiagramElem.hasAttribute( QStringLiteral(
"classificationAttribute" ) ) )
2138 int idx = linearDiagramElem.attribute( QStringLiteral(
"classificationAttribute" ) ).toInt();
2139 if ( idx >= 0 && idx < mFields.
count() )
2140 linearDiagramElem.setAttribute( QStringLiteral(
"classificationField" ), mFields.
at( idx ).
name() );
2144 mDiagramRenderer->
readXml( linearDiagramElem, context );
2147 if ( mDiagramRenderer )
2149 QDomElement diagramSettingsElem = node.firstChildElement( QStringLiteral(
"DiagramLayerSettings" ) );
2150 if ( !diagramSettingsElem.isNull() )
2152 bool oldXPos = diagramSettingsElem.hasAttribute( QStringLiteral(
"xPosColumn" ) );
2153 bool oldYPos = diagramSettingsElem.hasAttribute( QStringLiteral(
"yPosColumn" ) );
2154 bool oldShow = diagramSettingsElem.hasAttribute( QStringLiteral(
"showColumn" ) );
2155 if ( oldXPos || oldYPos || oldShow )
2161 int xPosColumn = diagramSettingsElem.attribute( QStringLiteral(
"xPosColumn" ) ).toInt();
2162 if ( xPosColumn >= 0 && xPosColumn < mFields.
count() )
2167 int yPosColumn = diagramSettingsElem.attribute( QStringLiteral(
"yPosColumn" ) ).toInt();
2168 if ( yPosColumn >= 0 && yPosColumn < mFields.
count() )
2173 int showColumn = diagramSettingsElem.attribute( QStringLiteral(
"showColumn" ) ).toInt();
2174 if ( showColumn >= 0 && showColumn < mFields.
count() )
2177 QDomElement propertiesElem = diagramSettingsElem.ownerDocument().createElement( QStringLiteral(
"properties" ) );
2184 ddp.
writeXml( propertiesElem, defs );
2185 diagramSettingsElem.appendChild( propertiesElem );
2188 delete mDiagramLayerSettings;
2190 mDiagramLayerSettings->
readXml( diagramSettingsElem );
2200 QDomElement layerElement = node.toElement();
2203 ( void )
writeStyle( node, doc, errorMessage, context );
2205 QDomElement fieldConfigurationElement = doc.createElement( QStringLiteral(
"fieldConfiguration" ) );
2206 node.appendChild( fieldConfigurationElement );
2209 Q_FOREACH (
const QgsField &field, mFields )
2212 QDomElement fieldElement = doc.createElement( QStringLiteral(
"field" ) );
2213 fieldElement.setAttribute( QStringLiteral(
"name" ), field.
name() );
2215 fieldConfigurationElement.appendChild( fieldElement );
2220 QDomElement editWidgetElement = doc.createElement( QStringLiteral(
"editWidget" ) );
2221 fieldElement.appendChild( editWidgetElement );
2223 QDomElement editWidgetConfigElement = doc.createElement( QStringLiteral(
"config" ) );
2226 editWidgetElement.appendChild( editWidgetConfigElement );
2233 QDomElement aliasElem = doc.createElement( QStringLiteral(
"aliases" ) );
2234 Q_FOREACH (
const QgsField &field, mFields )
2236 QDomElement aliasEntryElem = doc.createElement( QStringLiteral(
"alias" ) );
2237 aliasEntryElem.setAttribute( QStringLiteral(
"field" ), field.
name() );
2238 aliasEntryElem.setAttribute( QStringLiteral(
"index" ), mFields.
indexFromName( field.
name() ) );
2239 aliasEntryElem.setAttribute( QStringLiteral(
"name" ), field.
alias() );
2240 aliasElem.appendChild( aliasEntryElem );
2242 node.appendChild( aliasElem );
2245 QDomElement excludeWMSElem = doc.createElement( QStringLiteral(
"excludeAttributesWMS" ) );
2246 QSet<QString>::const_iterator attWMSIt = mExcludeAttributesWMS.constBegin();
2247 for ( ; attWMSIt != mExcludeAttributesWMS.constEnd(); ++attWMSIt )
2249 QDomElement attrElem = doc.createElement( QStringLiteral(
"attribute" ) );
2250 QDomText attrText = doc.createTextNode( *attWMSIt );
2251 attrElem.appendChild( attrText );
2252 excludeWMSElem.appendChild( attrElem );
2254 node.appendChild( excludeWMSElem );
2257 QDomElement excludeWFSElem = doc.createElement( QStringLiteral(
"excludeAttributesWFS" ) );
2258 QSet<QString>::const_iterator attWFSIt = mExcludeAttributesWFS.constBegin();
2259 for ( ; attWFSIt != mExcludeAttributesWFS.constEnd(); ++attWFSIt )
2261 QDomElement attrElem = doc.createElement( QStringLiteral(
"attribute" ) );
2262 QDomText attrText = doc.createTextNode( *attWFSIt );
2263 attrElem.appendChild( attrText );
2264 excludeWFSElem.appendChild( attrElem );
2266 node.appendChild( excludeWFSElem );
2269 QDomElement defaultsElem = doc.createElement( QStringLiteral(
"defaults" ) );
2270 Q_FOREACH (
const QgsField &field, mFields )
2272 QDomElement defaultElem = doc.createElement( QStringLiteral(
"default" ) );
2273 defaultElem.setAttribute( QStringLiteral(
"field" ), field.
name() );
2276 defaultsElem.appendChild( defaultElem );
2278 node.appendChild( defaultsElem );
2281 QDomElement constraintsElem = doc.createElement( QStringLiteral(
"constraints" ) );
2282 Q_FOREACH (
const QgsField &field, mFields )
2284 QDomElement constraintElem = doc.createElement( QStringLiteral(
"constraint" ) );
2285 constraintElem.setAttribute( QStringLiteral(
"field" ), field.
name() );
2290 constraintsElem.appendChild( constraintElem );
2292 node.appendChild( constraintsElem );
2295 QDomElement constraintExpressionsElem = doc.createElement( QStringLiteral(
"constraintExpressions" ) );
2296 Q_FOREACH (
const QgsField &field, mFields )
2298 QDomElement constraintExpressionElem = doc.createElement( QStringLiteral(
"constraint" ) );
2299 constraintExpressionElem.setAttribute( QStringLiteral(
"field" ), field.
name() );
2302 constraintExpressionsElem.appendChild( constraintExpressionElem );
2304 node.appendChild( constraintExpressionsElem );
2308 mAttributeTableConfig.
writeXml( node );
2309 mEditFormConfig.
writeXml( node, context );
2310 mConditionalStyles->
writeXml( node, doc, context );
2313 if ( !mExpressionFieldBuffer )
2320 mExpressionFieldBuffer->
writeXml( node, doc );
2323 node.toElement().setAttribute( QStringLiteral(
"readOnly" ), mReadOnly );
2326 QDomElement prevExpElem = doc.createElement( QStringLiteral(
"previewExpression" ) );
2327 QDomText prevExpText = doc.createTextNode( mDisplayExpression );
2328 prevExpElem.appendChild( prevExpText );
2329 node.appendChild( prevExpElem );
2332 QDomElement mapTipElem = doc.createElement( QStringLiteral(
"mapTip" ) );
2333 QDomText mapTipText = doc.createTextNode( mMapTipTemplate );
2334 mapTipElem.appendChild( mapTipText );
2335 node.toElement().appendChild( mapTipElem );
2342 QDomElement mapLayerNode = node.toElement();
2350 QDomElement rendererElement = mRenderer->
save( doc, context );
2351 node.appendChild( rendererElement );
2356 QDomElement labelingElement = mLabeling->
save( doc, context );
2357 node.appendChild( labelingElement );
2359 mapLayerNode.setAttribute( QStringLiteral(
"labelsEnabled" ), mLabelsEnabled ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
2362 mapLayerNode.setAttribute( QStringLiteral(
"simplifyDrawingHints" ), QString::number( mSimplifyMethod.
simplifyHints() ) );
2363 mapLayerNode.setAttribute( QStringLiteral(
"simplifyAlgorithm" ), QString::number( mSimplifyMethod.
simplifyAlgorithm() ) );
2364 mapLayerNode.setAttribute( QStringLiteral(
"simplifyDrawingTol" ), QString::number( mSimplifyMethod.
threshold() ) );
2365 mapLayerNode.setAttribute( QStringLiteral(
"simplifyLocal" ), mSimplifyMethod.
forceLocalOptimization() ? 1 : 0 );
2366 mapLayerNode.setAttribute( QStringLiteral(
"simplifyMaxScale" ), QString::number( mSimplifyMethod.
maximumScale() ) );
2372 QDomElement blendModeElem = doc.createElement( QStringLiteral(
"blendMode" ) );
2374 blendModeElem.appendChild( blendModeText );
2375 node.appendChild( blendModeElem );
2378 QDomElement featureBlendModeElem = doc.createElement( QStringLiteral(
"featureBlendMode" ) );
2380 featureBlendModeElem.appendChild( featureBlendModeText );
2381 node.appendChild( featureBlendModeElem );
2384 QDomElement layerOpacityElem = doc.createElement( QStringLiteral(
"layerOpacity" ) );
2385 QDomText layerOpacityText = doc.createTextNode( QString::number(
opacity() ) );
2386 layerOpacityElem.appendChild( layerOpacityText );
2387 node.appendChild( layerOpacityElem );
2389 if ( mDiagramRenderer )
2391 mDiagramRenderer->
writeXml( mapLayerNode, doc, context );
2392 if ( mDiagramLayerSettings )
2393 mDiagramLayerSettings->
writeXml( mapLayerNode, doc );
2402 QDomElement nameElem = node.firstChildElement( QStringLiteral(
"Name" ) );
2403 if ( nameElem.isNull() )
2405 errorMessage = QStringLiteral(
"Warning: Name element not found within NamedLayer while it's required." );
2417 readSldLabeling( node );
2424 Q_UNUSED( errorMessage );
2435 QDomElement nameNode = doc.createElement( QStringLiteral(
"se:Name" ) );
2436 nameNode.appendChild( doc.createTextNode(
name() ) );
2437 node.appendChild( nameNode );
2439 QDomElement userStyleElem = doc.createElement( QStringLiteral(
"UserStyle" ) );
2440 node.appendChild( userStyleElem );
2442 QDomElement nameElem = doc.createElement( QStringLiteral(
"se:Name" ) );
2443 nameElem.appendChild( doc.createTextNode(
name() ) );
2445 userStyleElem.appendChild( nameElem );
2447 QDomElement featureTypeStyleElem = doc.createElement( QStringLiteral(
"se:FeatureTypeStyle" ) );
2448 userStyleElem.appendChild( featureTypeStyleElem );
2450 mRenderer->
toSld( doc, featureTypeStyleElem, localProps );
2453 mLabeling->
toSld( featureTypeStyleElem, localProps );
2462 if ( !mEditBuffer || !mDataProvider )
2474 if ( !skipDefaultValue && !mDefaultValueOnUpdateFields.isEmpty() )
2475 updateDefaultValues( fid );
2483 bool result =
false;
2485 switch (
fields().fieldOrigin( field ) )
2495 if ( mEditBuffer && mDataProvider )
2504 if ( result && !skipDefaultValues && !mDefaultValueOnUpdateFields.isEmpty() )
2505 updateDefaultValues( fid );
2520 for (
auto it = newValues.constBegin(); it != newValues.constEnd(); ++it )
2522 const int field = it.key();
2523 const QVariant newValue = it.value();
2526 if ( oldValues.contains( field ) )
2527 oldValue = oldValues[field];
2532 newValuesJoin[field] = newValue;
2533 oldValuesJoin[field] = oldValue;
2540 newValuesNotJoin[field] = newValue;
2541 oldValuesNotJoin[field] = oldValue;
2550 if ( ! newValuesJoin.isEmpty() && mJoinBuffer )
2555 if ( ! newValuesNotJoin.isEmpty() && mEditBuffer && mDataProvider )
2560 if ( result && !skipDefaultValues && !mDefaultValueOnUpdateFields.isEmpty() )
2562 updateDefaultValues( fid );
2570 if ( !mEditBuffer || !mDataProvider )
2578 if ( attIndex < 0 || attIndex >=
fields().count() )
2582 mFields[ attIndex ].setAlias( QString() );
2583 if ( mAttributeAliasMap.contains( name ) )
2585 mAttributeAliasMap.remove( name );
2587 mEditFormConfig.setFields( mFields );
2594 if ( index < 0 || index >=
fields().count() )
2601 if ( mExpressionFieldBuffer )
2617 if ( !mEditBuffer || !mDataProvider )
2633 if ( attIndex < 0 || attIndex >=
fields().count() )
2638 mAttributeAliasMap.insert( name, aliasString );
2639 mFields[ attIndex ].setAlias( aliasString );
2640 mEditFormConfig.setFields( mFields );
2646 if ( index < 0 || index >=
fields().count() )
2654 if ( index >= 0 && index < mFields.
count() )
2665 if ( !field.
alias().isEmpty() )
2666 map.insert( field.
name(), field.
alias() );
2673 if ( index < 0 || index >=
fields().count() )
2682 if ( !mEditBuffer || !mDataProvider )
2690 bool deleted =
false;
2693 QList<int> attrList = attrs.toSet().toList();
2695 std::sort( attrList.begin(), attrList.end(), std::greater<int>() );
2697 for (
int attr : qgis::as_const( attrList ) )
2719 mSelectedFeatureIds.remove( fid );
2730 QgsDebugMsgLevel( QStringLiteral(
"Cannot delete features (mEditBuffer==NULL)" ), 1 );
2741 mSelectedFeatureIds.subtract( fids );
2753 for (
int i = 0; i < mFields.
count(); ++i )
2757 pkAttributesList << i;
2760 return pkAttributesList;
2771 mCommitErrors.clear();
2773 if ( !mDataProvider )
2775 mCommitErrors << tr(
"ERROR: no provider" );
2781 mCommitErrors << tr(
"ERROR: layer not editable" );
2792 mEditBuffer =
nullptr;
2813 return mCommitErrors;
2843 mEditBuffer =
nullptr;
2848 if ( rollbackExtent )
2859 return mSelectedFeatureIds.size();
2864 return mSelectedFeatureIds;
2872 if ( mSelectedFeatureIds.count() <= 8 )
2888 features.push_back( f );
2897 if ( mSelectedFeatureIds.isEmpty() )
2903 if ( mSelectedFeatureIds.count() == 1 )
2904 request.
setFilterFid( *mSelectedFeatureIds.constBegin() );
2913 if ( !mEditBuffer || !mDataProvider )
2954 if ( mDisplayExpression == displayExpression )
2963 if ( !mDisplayExpression.isEmpty() || mFields.
isEmpty() )
2965 return mDisplayExpression;
2971 Q_FOREACH (
const QgsField &field, mFields )
2973 QString fldName = field.
name();
2979 if ( fldName.indexOf( QLatin1String(
"name" ), 0, Qt::CaseInsensitive ) > -1 )
2984 if ( fldName.indexOf( QLatin1String(
"descrip" ), 0, Qt::CaseInsensitive ) > -1 )
2989 if ( fldName.indexOf( QLatin1String(
"id" ), 0, Qt::CaseInsensitive ) > -1 )
2996 if ( !idxName.isNull() )
3009 return ( mEditBuffer && mDataProvider );
3018 bool QgsVectorLayer::isReadOnly()
const 3026 if ( readonly && mEditBuffer )
3029 mReadOnly = readonly;
3037 return mEditBuffer && mEditBuffer->
isModified();
3043 bool auxiliaryField =
false;
3047 return auxiliaryField;
3054 auxiliaryField =
true;
3057 return auxiliaryField;
3065 if ( r != mRenderer )
3069 mSymbolFeatureCounted =
false;
3070 mSymbolFeatureCountMap.clear();
3079 if ( !mDataProvider )
3085 QString ignoredError;
3089 mEditCommandActive =
true;
3095 if ( !mDataProvider )
3100 mEditCommandActive =
false;
3101 if ( !mDeletedFids.isEmpty() )
3104 mDeletedFids.clear();
3111 if ( !mDataProvider )
3118 #if QT_VERSION >= 0x050900 // setObsolete is new in Qt 5.9 3123 std::unique_ptr< QUndoCommand > command = qgis::make_unique< QUndoCommand >();
3124 command->setObsolete(
true );
3128 mEditCommandActive =
false;
3129 mDeletedFids.clear();
3135 return mJoinBuffer->
addJoin( joinInfo );
3141 return mJoinBuffer->
removeJoin( joinLayerId );
3171 if ( oi < 0 || oi >= mExpressionFieldBuffer->
expressions().size() )
3174 return mExpressionFieldBuffer->
expressions().at( oi ).cachedExpression.expression();
3185 if ( !mDataProvider )
3190 mFields = mDataProvider->
fields();
3200 if ( mExpressionFieldBuffer )
3204 QMap< QString, QString >::const_iterator aliasIt = mAttributeAliasMap.constBegin();
3205 for ( ; aliasIt != mAttributeAliasMap.constEnd(); ++aliasIt )
3211 mFields[ index ].setAlias( aliasIt.value() );
3215 mDefaultValueOnUpdateFields.clear();
3216 QMap< QString, QgsDefaultValue >::const_iterator defaultIt = mDefaultExpressionMap.constBegin();
3217 for ( ; defaultIt != mDefaultExpressionMap.constEnd(); ++defaultIt )
3219 int index = mFields.
lookupField( defaultIt.key() );
3223 mFields[ index ].setDefaultValueDefinition( defaultIt.value() );
3224 if ( defaultIt.value().applyOnUpdate() )
3225 mDefaultValueOnUpdateFields.insert( index );
3228 QMap< QString, QgsFieldConstraints::Constraints >::const_iterator constraintIt = mFieldConstraints.constBegin();
3229 for ( ; constraintIt != mFieldConstraints.constEnd(); ++constraintIt )
3231 int index = mFields.
lookupField( constraintIt.key() );
3244 mFields[ index ].setConstraints( constraints );
3247 QMap< QString, QPair< QString, QString > >::const_iterator constraintExpIt = mFieldConstraintExpressions.constBegin();
3248 for ( ; constraintExpIt != mFieldConstraintExpressions.constEnd(); ++constraintExpIt )
3250 int index = mFields.
lookupField( constraintExpIt.key() );
3261 mFields[ index ].setConstraints( constraints );
3265 for ( ; constraintStrengthIt != mFieldConstraintStrength.constEnd(); ++constraintStrengthIt )
3267 int index = mFields.
lookupField( constraintStrengthIt.key().first );
3277 constraints.
setConstraintStrength( constraintStrengthIt.key().second, constraintStrengthIt.value() );
3278 mFields[ index ].setConstraints( constraints );
3281 auto fieldWidgetIterator = mFieldWidgetSetups.constBegin();
3282 for ( ; fieldWidgetIterator != mFieldWidgetSetups.constEnd(); ++ fieldWidgetIterator )
3284 int index = mFields.
indexOf( fieldWidgetIterator.key() );
3288 mFields[index].setEditorWidgetSetup( fieldWidgetIterator.value() );
3291 if ( oldFields != mFields )
3294 mEditFormConfig.setFields( mFields );
3301 if ( index < 0 || index >= mFields.
count() )
3305 if ( expression.isEmpty() )
3309 std::unique_ptr< QgsExpressionContext > tempContext;
3314 evalContext = tempContext.get();
3347 if ( index < 0 || index >= mFields.
count() )
3352 mDefaultExpressionMap.insert( mFields.
at( index ).
name(), definition );
3356 mDefaultExpressionMap.remove( mFields.
at( index ).
name() );
3363 if ( index < 0 || index >= mFields.
count() )
3372 if ( !mDataProvider )
3385 uniqueValues = mDataProvider->
uniqueValues( index, limit );
3390 Q_FOREACH (
const QVariant &v, uniqueValues )
3392 vals << v.toString();
3396 QMapIterator< QgsFeatureId, QgsFeature > addedIt( added );
3397 while ( addedIt.hasNext() && ( limit < 0 || uniqueValues.count() < limit ) )
3400 QVariant v = addedIt.value().attribute( index );
3403 QString vs = v.toString();
3404 if ( !vals.contains( vs ) )
3413 while ( it.hasNext() && ( limit < 0 || uniqueValues.count() < limit ) )
3416 QVariant v = it.value().value( index );
3419 QString vs = v.toString();
3420 if ( !vals.contains( vs ) )
3439 uniqueValues = mDataProvider->
uniqueValues( index, limit );
3452 .setSubsetOfAttributes( attList ) );
3455 QVariant currentValue;
3456 QHash<QString, QVariant> val;
3460 val.insert( currentValue.toString(), currentValue );
3461 if ( limit >= 0 && val.size() >= limit )
3467 return val.values().toSet();
3471 Q_ASSERT_X(
false,
"QgsVectorLayer::uniqueValues()",
"Unknown source of the field!" );
3477 QStringList results;
3478 if ( !mDataProvider )
3496 QMapIterator< QgsFeatureId, QgsFeature > addedIt( added );
3497 while ( addedIt.hasNext() && ( limit < 0 || results.count() < limit ) && ( !feedback || !feedback->
isCanceled() ) )
3500 QVariant v = addedIt.value().attribute( index );
3503 QString vs = v.toString();
3504 if ( vs.contains( substring, Qt::CaseInsensitive ) && !results.contains( vs ) )
3512 while ( it.hasNext() && ( limit < 0 || results.count() < limit ) && ( !feedback || !feedback->
isCanceled() ) )
3515 QVariant v = it.value().value( index );
3518 QString vs = v.toString();
3519 if ( vs.contains( substring, Qt::CaseInsensitive ) && !results.contains( vs ) )
3550 QString fieldName = mFields.
at( index ).
name();
3551 request.
setFilterExpression( QStringLiteral(
"\"%1\" ILIKE '%%2%'" ).arg( fieldName, substring ) );
3555 QString currentValue;
3558 currentValue = f.
attribute( index ).toString();
3559 if ( !results.contains( currentValue ) )
3560 results << currentValue;
3562 if ( ( limit >= 0 && results.size() >= limit ) || ( feedback && feedback->
isCanceled() ) )
3572 Q_ASSERT_X(
false,
"QgsVectorLayer::uniqueStringsMatching()",
"Unknown source of the field!" );
3578 if ( !mDataProvider )
3596 QMapIterator< QgsFeatureId, QgsFeature > addedIt( added );
3597 while ( addedIt.hasNext() )
3600 QVariant v = addedIt.value().attribute( index );
3608 while ( it.hasNext() )
3611 QVariant v = it.value().value( index );
3643 .setSubsetOfAttributes( attList ) );
3646 double minimumValue = std::numeric_limits<double>::max();
3647 double currentValue = 0;
3650 currentValue = f.
attribute( index ).toDouble();
3651 if ( currentValue < minimumValue )
3653 minimumValue = currentValue;
3656 return QVariant( minimumValue );
3660 Q_ASSERT_X(
false,
"QgsVectorLayer::minimumValue()",
"Unknown source of the field!" );
3666 if ( !mDataProvider )
3683 QMapIterator< QgsFeatureId, QgsFeature > addedIt( added );
3684 while ( addedIt.hasNext() )
3687 QVariant v = addedIt.value().attribute( index );
3695 while ( it.hasNext() )
3698 QVariant v = it.value().value( index );
3728 .setSubsetOfAttributes( attList ) );
3731 double maximumValue = -std::numeric_limits<double>::max();
3732 double currentValue = 0;
3735 currentValue = f.
attribute( index ).toDouble();
3736 if ( currentValue > maximumValue )
3738 maximumValue = currentValue;
3741 return QVariant( maximumValue );
3745 Q_ASSERT_X(
false,
"QgsVectorLayer::maximumValue()",
"Unknown source of the field!" );
3755 if ( !mDataProvider )
3761 int attrIndex = mFields.
lookupField( fieldOrExpression );
3762 if ( attrIndex >= 0 )
3769 bool providerOk =
false;
3770 QVariant val = mDataProvider->
aggregate( aggregate, attrIndex, parameters, context, providerOk );
3784 return c.
calculate( aggregate, fieldOrExpression, context, ok );
3796 return mFeatureBlendMode;
3808 return mLayerOpacity;
3813 void QgsVectorLayer::readSldLabeling(
const QDomNode &node )
3818 QDomElement element = node.toElement();
3819 if ( element.isNull() )
3822 QDomElement userStyleElem = element.firstChildElement( QStringLiteral(
"UserStyle" ) );
3823 if ( userStyleElem.isNull() )
3825 QgsDebugMsgLevel( QStringLiteral(
"Info: UserStyle element not found." ), 4 );
3829 QDomElement featureTypeStyleElem = userStyleElem.firstChildElement( QStringLiteral(
"FeatureTypeStyle" ) );
3830 if ( featureTypeStyleElem.isNull() )
3832 QgsDebugMsgLevel( QStringLiteral(
"Info: FeatureTypeStyle element not found." ), 4 );
3837 QDomElement ruleElem = featureTypeStyleElem.lastChildElement( QStringLiteral(
"Rule" ) );
3838 if ( ruleElem.isNull() )
3845 QDomElement textSymbolizerElem = ruleElem.lastChildElement( QStringLiteral(
"TextSymbolizer" ) );
3846 if ( textSymbolizerElem.isNull() )
3848 QgsDebugMsgLevel( QStringLiteral(
"Info: TextSymbolizer element not found." ), 4 );
3855 QDomElement labelElem = textSymbolizerElem.firstChildElement( QStringLiteral(
"Label" ) );
3856 if ( !labelElem.isNull() )
3858 QDomElement propertyNameElem = labelElem.firstChildElement( QStringLiteral(
"PropertyName" ) );
3859 if ( !propertyNameElem.isNull() )
3864 QString labelAttribute = propertyNameElem.text();
3868 int fieldIndex = mFields.
lookupField( labelAttribute );
3869 if ( fieldIndex == -1 )
3885 QgsDebugMsgLevel( QStringLiteral(
"Info: PropertyName element not found." ), 4 );
3895 QString fontFamily = QStringLiteral(
"Sans-Serif" );
3896 int fontPointSize = 10;
3897 int fontWeight = -1;
3898 bool fontItalic =
false;
3899 bool fontUnderline =
false;
3902 QDomElement fontElem = textSymbolizerElem.firstChildElement( QStringLiteral(
"Font" ) );
3903 if ( !fontElem.isNull() )
3907 QDomElement cssElem = fontElem.firstChildElement( QStringLiteral(
"CssParameter" ) );
3908 while ( !cssElem.isNull() )
3910 cssName = cssElem.attribute( QStringLiteral(
"name" ), QStringLiteral(
"not_found" ) );
3911 if ( cssName != QLatin1String(
"not_found" ) )
3913 elemText = cssElem.text();
3914 if ( cssName == QLatin1String(
"font-family" ) )
3916 fontFamily = elemText;
3918 else if ( cssName == QLatin1String(
"font-style" ) )
3920 fontItalic = ( elemText == QLatin1String(
"italic" ) ) || ( elemText == QLatin1String(
"Italic" ) );
3922 else if ( cssName == QLatin1String(
"font-size" ) )
3925 int fontSize = elemText.toInt( &ok );
3928 fontPointSize = fontSize;
3931 else if ( cssName == QLatin1String(
"font-weight" ) )
3933 if ( ( elemText == QLatin1String(
"bold" ) ) || ( elemText == QLatin1String(
"Bold" ) ) )
3934 fontWeight = QFont::Bold;
3936 else if ( cssName == QLatin1String(
"font-underline" ) )
3938 fontUnderline = ( elemText == QLatin1String(
"underline" ) ) || ( elemText == QLatin1String(
"Underline" ) );
3942 cssElem = cssElem.nextSiblingElement( QStringLiteral(
"CssParameter" ) );
3947 QFont font( fontFamily, fontPointSize, fontWeight, fontItalic );
3948 font.setUnderline( fontUnderline );
3950 format.
setSize( fontPointSize );
3954 if ( textColor.isValid() )
3962 QDomElement haloElem = textSymbolizerElem.firstChildElement( QStringLiteral(
"Halo" ) );
3963 if ( !haloElem.isNull() )
3968 QDomElement radiusElem = haloElem.firstChildElement( QStringLiteral(
"Radius" ) );
3969 if ( !radiusElem.isNull() )
3972 double bufferSize = radiusElem.text().toDouble( &ok );
3975 bufferSettings.
setSize( bufferSize );
3980 if ( bufferColor.isValid() )
3982 bufferSettings.
setColor( bufferColor );
3987 QDomElement labelPlacementElem = textSymbolizerElem.firstChildElement( QStringLiteral(
"LabelPlacement" ) );
3988 if ( !labelPlacementElem.isNull() )
3991 QDomElement pointPlacementElem = labelPlacementElem.firstChildElement( QStringLiteral(
"PointPlacement" ) );
3992 if ( !pointPlacementElem.isNull() )
3996 QDomElement displacementElem = pointPlacementElem.firstChildElement( QStringLiteral(
"Displacement" ) );
3997 if ( !displacementElem.isNull() )
3999 QDomElement displacementXElem = displacementElem.firstChildElement( QStringLiteral(
"DisplacementX" ) );
4000 if ( !displacementXElem.isNull() )
4003 double xOffset = displacementXElem.text().toDouble( &ok );
4009 QDomElement displacementYElem = displacementElem.firstChildElement( QStringLiteral(
"DisplacementY" ) );
4010 if ( !displacementYElem.isNull() )
4013 double yOffset = displacementYElem.text().toDouble( &ok );
4021 QDomElement rotationElem = pointPlacementElem.firstChildElement( QStringLiteral(
"Rotation" ) );
4022 if ( !rotationElem.isNull() )
4025 double rotation = rotationElem.text().toDouble( &ok );
4042 return mEditFormConfig;
4047 if ( mEditFormConfig == editFormConfig )
4051 mEditFormConfig.onRelationsLoaded();
4057 return mMapTipTemplate;
4062 if ( mMapTipTemplate == mapTip )
4065 mMapTipTemplate = mapTip;
4081 if ( mAttributeTableConfig != attributeTableConfig )
4100 if ( !mDiagramLayerSettings )
4102 *mDiagramLayerSettings = s;
4108 QString myMetadata = QStringLiteral(
"<html>\n<body>\n" );
4111 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Information from provider" ) + QStringLiteral(
"</h1>\n<hr>\n" );
4112 myMetadata += QLatin1String(
"<table class=\"list-view\">\n" );
4115 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Original" ) + QStringLiteral(
"</td><td>" ) +
name() + QStringLiteral(
"</td></tr>\n" );
4118 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Name" ) + QStringLiteral(
"</td><td>" ) +
name() + QStringLiteral(
"</td></tr>\n" );
4121 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Source" ) + QStringLiteral(
"</td><td>" ) +
publicSource() + QStringLiteral(
"</td></tr>\n" );
4124 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Storage" ) + QStringLiteral(
"</td><td>" ) +
storageType() + QStringLiteral(
"</td></tr>\n" );
4127 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Comment" ) + QStringLiteral(
"</td><td>" ) +
dataComment() + QStringLiteral(
"</td></tr>\n" );
4130 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Encoding" ) + QStringLiteral(
"</td><td>" ) +
dataProvider()->
encoding() + QStringLiteral(
"</td></tr>\n" );
4142 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Geometry" ) + QStringLiteral(
"</td><td>" ) + typeString + QStringLiteral(
"</td></tr>\n" );
4146 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"CRS" ) + QStringLiteral(
"</td><td>" );
4149 myMetadata +=
crs().
authid() + QStringLiteral(
" - " );
4151 if (
crs().isGeographic() )
4152 myMetadata += tr(
"Geographic" );
4154 myMetadata += tr(
"Projected" );
4156 myMetadata += QLatin1String(
"</td></tr>\n" );
4159 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Extent" ) + QStringLiteral(
"</td><td>" ) +
extent().
toString() + QStringLiteral(
"</td></tr>\n" );
4162 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Unit" ) + QStringLiteral(
"</td><td>" ) +
QgsUnitTypes::toString(
crs().mapUnits() ) + QStringLiteral(
"</td></tr>\n" );
4165 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Feature count" ) + QStringLiteral(
"</td><td>" ) + QString::number(
featureCount() ) + QStringLiteral(
"</td></tr>\n" );
4168 myMetadata += QLatin1String(
"</table>\n<br><br>" );
4171 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Identification" ) + QStringLiteral(
"</h1>\n<hr>\n" );
4173 myMetadata += QLatin1String(
"<br><br>\n" );
4176 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Extent" ) + QStringLiteral(
"</h1>\n<hr>\n" );
4178 myMetadata += QLatin1String(
"<br><br>\n" );
4181 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Access" ) + QStringLiteral(
"</h1>\n<hr>\n" );
4183 myMetadata += QLatin1String(
"<br><br>\n" );
4186 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Fields" ) + QStringLiteral(
"</h1>\n<hr>\n<table class=\"list-view\">\n" );
4190 if ( !pkAttrList.isEmpty() )
4192 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Primary key attributes" ) + QStringLiteral(
"</td><td>" );
4193 Q_FOREACH (
int idx, pkAttrList )
4197 myMetadata += QLatin1String(
"</td></tr>\n" );
4203 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Count" ) + QStringLiteral(
"</td><td>" ) + QString::number( myFields.
size() ) + QStringLiteral(
"</td></tr>\n" );
4205 myMetadata += QLatin1String(
"</table>\n<br><table width=\"100%\" class=\"tabular-view\">\n" );
4206 myMetadata +=
"<tr><th>" + tr(
"Field" ) +
"</th><th>" + tr(
"Type" ) +
"</th><th>" + tr(
"Length" ) +
"</th><th>" + tr(
"Precision" ) +
"</th><th>" + tr(
"Comment" ) +
"</th></tr>\n";
4208 for (
int i = 0; i < myFields.
size(); ++i )
4213 rowClass = QStringLiteral(
"class=\"odd-row\"" );
4214 myMetadata +=
"<tr " + rowClass +
"><td>" + myField.
name() +
"</td><td>" + myField.
typeName() +
"</td><td>" + QString::number( myField.
length() ) +
"</td><td>" + QString::number( myField.
precision() ) +
"</td><td>" + myField.
comment() +
"</td></tr>\n";
4218 myMetadata += QLatin1String(
"</table>\n<br><br>" );
4221 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Contacts" ) + QStringLiteral(
"</h1>\n<hr>\n" );
4223 myMetadata += QLatin1String(
"<br><br>\n" );
4226 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Links" ) + QStringLiteral(
"</h1>\n<hr>\n" );
4228 myMetadata += QLatin1String(
"<br><br>\n" );
4231 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"History" ) + QStringLiteral(
"</h1>\n<hr>\n" );
4233 myMetadata += QLatin1String(
"<br><br>\n" );
4235 myMetadata += QStringLiteral(
"\n</body>\n</html>\n" );
4239 void QgsVectorLayer::invalidateSymbolCountedFlag()
4241 mSymbolFeatureCounted =
false;
4244 void QgsVectorLayer::onFeatureCounterCompleted()
4247 mFeatureCounter =
nullptr;
4250 void QgsVectorLayer::onFeatureCounterTerminated()
4252 mFeatureCounter =
nullptr;
4255 void QgsVectorLayer::onJoinedFieldsChanged()
4261 void QgsVectorLayer::onFeatureDeleted(
QgsFeatureId fid )
4263 if ( mEditCommandActive )
4264 mDeletedFids << fid;
4271 void QgsVectorLayer::onRelationsLoaded()
4273 mEditFormConfig.onRelationsLoaded();
4276 void QgsVectorLayer::onSymbolsCounted()
4278 if ( mFeatureCounter )
4281 mSymbolFeatureCounted =
true;
4296 msgError = QObject::tr(
"Unable to load %1 provider" ).arg( mProviderKey );
4301 if ( !listStylesExternalMethod )
4303 msgError = QObject::tr(
"Provider %1 has no %2 method" ).arg( mProviderKey, QStringLiteral(
"listStyles" ) );
4307 return listStylesExternalMethod(
mDataSource, ids, names, descriptions, msgError );
4315 msgError = QObject::tr(
"Unable to load %1 provider" ).arg( mProviderKey );
4320 if ( !getStyleByIdMethod )
4322 msgError = QObject::tr(
"Provider %1 has no %2 method" ).arg( mProviderKey, QStringLiteral(
"getStyleById" ) );
4326 return getStyleByIdMethod(
mDataSource, styleId, msgError );
4334 msgError = QObject::tr(
"Unable to load %1 provider" ).arg( mProviderKey );
4338 if ( !deleteStyleByIdMethod )
4340 msgError = QObject::tr(
"Provider %1 has no %2 method" ).arg( mProviderKey, QStringLiteral(
"deleteStyleById" ) );
4343 return deleteStyleByIdMethod(
mDataSource, styleId, msgError );
4348 bool useAsDefault,
const QString &uiFileContent, QString &msgError )
4351 QString sldStyle, qmlStyle;
4355 msgError = QObject::tr(
"Unable to load %1 provider" ).arg( mProviderKey );
4360 if ( !saveStyleExternalMethod )
4362 msgError = QObject::tr(
"Provider %1 has no %2 method" ).arg( mProviderKey, QStringLiteral(
"saveStyle" ) );
4366 QDomDocument qmlDocument, sldDocument;
4368 if ( !msgError.isNull() )
4372 qmlStyle = qmlDocument.toString();
4375 if ( !msgError.isNull() )
4379 sldStyle = sldDocument.toString();
4381 saveStyleExternalMethod(
mDataSource, qmlStyle, sldStyle, name,
4382 description, uiFileContent, useAsDefault, msgError );
4396 QString joinKey = mAuxiliaryLayerKey;
4397 if ( !key.isEmpty() )
4400 if ( storage.
isValid() && !joinKey.isEmpty() )
4423 mAuxiliaryLayerKey.clear();
4425 if ( mAuxiliaryLayer )
4438 mAuxiliaryLayer.reset( alayer );
4439 if ( mAuxiliaryLayer )
4440 mAuxiliaryLayer->setParent(
this );
4446 return mAuxiliaryLayer.get();
4451 return mAuxiliaryLayer.get();
4463 if ( loadStyleExternalMethod )
4465 QString qml, errorMsg;
4466 qml = loadStyleExternalMethod(
mDataSource, errorMsg );
4467 if ( !qml.isEmpty() )
4469 QDomDocument myDocument( QStringLiteral(
"qgis" ) );
4470 myDocument.setContent( qml );
4472 return QObject::tr(
"Loaded from Provider" );
4483 if ( mDataProvider )
4490 QSet<QgsMapLayerDependency> deps;
4499 QSet<QgsMapLayerDependency> toAdd = deps -
dependencies();
4515 if ( mDataProvider )
4535 if ( ! toAdd.isEmpty() )
4543 if ( fieldIndex < 0 || fieldIndex >= mFields.
count() )
4559 QMap< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrength > m;
4561 if ( fieldIndex < 0 || fieldIndex >= mFields.
count() )
4564 QString
name = mFields.
at( fieldIndex ).
name();
4567 for ( ; conIt != mFieldConstraintStrength.constEnd(); ++conIt )
4569 if ( conIt.key().first ==
name )
4571 m[ conIt.key().second ] = mFieldConstraintStrength.value( conIt.key() );
4580 if ( index < 0 || index >= mFields.
count() )
4586 QgsFieldConstraints::Constraints constraints = mFieldConstraints.value( name,
nullptr );
4587 constraints |= constraint;
4588 mFieldConstraints.insert( name, constraints );
4590 mFieldConstraintStrength.insert( qMakePair( name, constraint ), strength );
4597 if ( index < 0 || index >= mFields.
count() )
4603 QgsFieldConstraints::Constraints constraints = mFieldConstraints.value( name,
nullptr );
4604 constraints &= ~constraint;
4605 mFieldConstraints.insert( name, constraints );
4607 mFieldConstraintStrength.remove( qMakePair( name, constraint ) );
4614 if ( index < 0 || index >= mFields.
count() )
4622 if ( index < 0 || index >= mFields.
count() )
4630 if ( index < 0 || index >= mFields.
count() )
4633 if ( expression.isEmpty() )
4635 mFieldConstraintExpressions.remove( mFields.
at( index ).
name() );
4639 mFieldConstraintExpressions.insert( mFields.
at( index ).
name(), qMakePair( expression, description ) );
4646 if ( index < 0 || index >= mFields.
count() )
4650 mFieldWidgetSetups.remove( mFields.
at( index ).
name() );
4652 mFieldWidgetSetups.insert( mFields.
at( index ).
name(), setup );
4659 if ( index < 0 || index >= mFields.
count() )
4668 if (
customProperty( QStringLiteral(
"labeling" ) ).toString() == QLatin1String(
"pal" ) )
4670 if (
customProperty( QStringLiteral(
"labeling/enabled" ), QVariant(
false ) ).toBool() ==
true )
4674 settings.readFromLayerCustomProperties(
this );
4682 if ( key.startsWith( QLatin1String(
"labeling/" ) ) )
4697 return mReadExtentFromXml;
4700 void QgsVectorLayer::onDirtyTransaction(
const QString &sql,
const QString &
name )
4703 if ( tr && mEditBuffer )
void setProperty(int key, const QgsProperty &property)
Adds a property to the collection and takes ownership of it.
int lookupField(const QString &fieldName) const
Look up field's index from the field name.
bool addFeatures(QgsFeatureList &features, QgsFeatureSink::Flags flags=nullptr) override
Adds a list of features in joined layers.
QList< QgsExpressionFieldBuffer::ExpressionField > expressions() const
void setExtent(const QgsRectangle &rect) override
Sets the extent.
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn.
Origin origin() const
Returns the dependency origin.
bool isValid() const
Returns the validity of this feature.
void writeXml(QDomNode &layer_node, QDomDocument &document) const
Saves mVectorJoins to xml under the layer node.
Class for parsing and evaluation of expressions (formerly called "search strings").
void updateFields()
Will regenerate the fields property of this layer by obtaining all fields from the dataProvider...
void opacityChanged(double opacity)
Emitted when the layer's opacity is changed, where opacity is a value between 0 (transparent) and 1 (...
QgsGeometry::OperationResult addPart(const QList< QgsPointXY > &ring)
Adds a new part polygon to a multipart feature.
void writeCommonStyle(QDomElement &layerElement, QDomDocument &document, const QgsReadWriteContext &context) const
Write style data common to all layer types.
QgsActionManager * actions()
Returns all layer actions defined on this layer.
bool writeSymbology(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context) const override
Write the symbology for the layer into the docment provided.
double xOffset
Horizontal offset of label.
QString encoding() const
Gets encoding which is used for accessing data.
QgsStringMap attributeAliases() const
Returns a map of field name to attribute alias.
The class is used as a container of context for various read/write operations on other objects...
Wrapper for iterator of features from vector data provider or vector layer.
void featuresDeleted(const QgsFeatureIds &fids)
Emitted when features have been deleted.
void selectAll()
Select all the features.
void setConstraintStrength(Constraint constraint, ConstraintStrength strength)
Sets the strength of a constraint.
Constraint was set by layer.
bool addJoin(const QgsVectorLayerJoinInfo &joinInfo)
Joins another vector layer to this layer.
void taskTerminated()
Will be emitted by task if it has terminated for any reason other then completion (e...
virtual bool setSubsetString(const QString &subset, bool updateFeatureCount=true)
Set the subset string used to create a subset of features in the layer.
A rectangle specified with double values.
QString targetFieldName() const
Returns name of the field of our layer that will be used for join.
Base class for all map layer types.
QgsGeometry::OperationResult splitParts(const QVector< QgsPointXY > &splitLine, bool topologicalEditing=false)
Splits parts cut by the given line.
double rendererScale() const
Returns the renderer map scale.
void geometryChanged(QgsFeatureId fid, const QgsGeometry &geom)
Emitted when a feature's geometry is changed.
void renameExpression(int index, const QString &name)
Renames an expression field at a given index.
virtual void writeXml(QDomElement &layerElem, QDomDocument &doc, const QgsReadWriteContext &context) const =0
Writes diagram state to a DOM element.
void setDiagramLayerSettings(const QgsDiagramLayerSettings &s)
bool loadDefaultStyle
Sets to true if the default layer style should be loaded.
QVariant maximumValue(int index) const override
Returns the maximum value of an attribute.
QgsVectorLayerFeatureCounter * countSymbolFeatures()
Count features for symbols.
bool containsJoins() const
Quick way to test if there is any join at all.
void update(const QgsFields &fields)
Update the configuration with the given fields.
virtual QDomElement writeXml(QDomDocument &doc, const QgsReadWriteContext &context) const
Writes configuration to a DOM element, to be used later with readXml()
void setRenderer(QgsFeatureRenderer *r)
Set renderer which will be invoked to represent this layer.
Field comes from a joined layer (originIndex / 1000 = index of the join, originIndex % 1000 = index w...
void setExcludeAttributesWms(const QSet< QString > &att)
A set of attributes that are not advertised in WMS requests with QGIS server.
virtual bool renameAttribute(int attr, const QString &newName)
Renames an attribute field (but does not commit it)
virtual bool addAttribute(const QgsField &field)
Add an attribute field (but does not commit it) returns true if the field was added.
int size() const
Returns number of items.
virtual void exportSldStyle(QDomDocument &doc, QString &errorMsg) const
Export the properties of this layer as SLD style in a QDomDocument.
FieldOrigin fieldOrigin(int fieldIdx) const
Gets field's origin (value from an enumeration)
void setMinimal()
Set a rectangle so that min corner is at max and max corner is at min.
virtual QString subsetString() const
Returns the subset definition string (typically sql) currently in use by the layer and used by the pr...
void taskCompleted()
Will be emitted by task to indicate its successful completion.
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
virtual QgsVectorDataProvider::Capabilities capabilities() const
Returns flags containing the supported capabilities.
void dependenciesChanged()
Emitted when dependencies are changed.
QgsWkbTypes::Type wkbType() const override=0
Returns the geometry type which is returned by this layer.
static QString quotedColumnRef(QString name)
Returns a quoted column reference (in double quotes)
void committedAttributesDeleted(const QString &layerId, const QgsAttributeList &deletedAttributes)
Signals emitted after committing changes.
bool isValid() const
Returns the status of the auxiliary storage currently defined.
virtual QString subsetString() const
Returns the string (typically sql) used to define a subset of the layer.
static Q_INVOKABLE QString toString(QgsUnitTypes::DistanceUnit unit)
Returns a translated string representing a distance unit.
void editFormConfigChanged()
Will be emitted whenever the edit form configuration of this layer changes.
void modifySelection(const QgsFeatureIds &selectIds, const QgsFeatureIds &deselectIds)
Modifies the current selection on this layer.
bool writeXml(QDomNode &layer_node) const
Writes the actions out in XML format.
ConstraintStrength constraintStrength(Constraint constraint) const
Returns the strength of a field constraint, or ConstraintStrengthNotSet if the constraint is not pres...
virtual void updateExtents()
Update the extents of the layer.
void addExpression(const QString &exp, const QgsField &fld)
Add an expression to the buffer.
QVariant minimumValue(int index) const override
Returns the minimum value of an attribute.
void removeFieldConstraint(int index, QgsFieldConstraints::Constraint constraint)
Removes a constraint for a specified field index.
bool writeXml(QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context) const override
Write vector layer specific state to project file Dom node.
bool isValid() const
Returns if this default value should be applied.
virtual QVariant aggregate(QgsAggregateCalculator::Aggregate aggregate, int index, const QgsAggregateCalculator::AggregateParameters ¶meters, QgsExpressionContext *context, bool &ok) const
Calculates an aggregated value from the layer's features.
bool writeXml(QDomNode &node, QDomDocument &doc, const QgsReadWriteContext &context) const
Write field ui properties specific state from Dom node.
void beforeRollBack()
Is emitted, before changes are rolled back.
virtual bool addFeatures(QgsFeatureList &features)
Insert a copy of the given features into the layer (but does not commit it)
bool hasParam(const QString &key) const
Test if param exists (generic mode)
void beginEditCommand(const QString &text)
Create edit command for undo/redo operations.
Use exact geometry intersection (slower) instead of bounding boxes.
QSet< QString > excludeAttributesWms() const
A set of attributes that are not advertised in WMS requests with QGIS server.
This class is a composition of two QSettings instances:
QgsGeometry::OperationResult splitParts(const QVector< QgsPointXY > &splitLine, bool topologicalEditing=false)
Splits parts cut by the given line.
QStringList customPropertyKeys() const
Returns list of all keys within custom properties.
MAYBE_UNUSED NODISCARD QgsReadWriteContextCategoryPopper enterCategory(const QString &category, const QString &details=QString())
Push a category to the stack.
void resolveReferences(QgsProject *project) override
Resolve references to other layers (kept as layer IDs after reading XML) into layer objects...
double angleOffset
Label rotation, in degrees clockwise.
QString mapTipTemplate() const
The mapTip is a pretty, html representation for feature information.
QString readPath(const QString &filename) const
Turn filename read from the project file to an absolute path.
int translateFeature(QgsFeatureId featureId, double dx, double dy)
Translates feature by dx, dy.
QgsMapLayerLegend * legend() const
Can be null.
QString storageType() const
Returns the permanent storage type for this layer as a friendly name.
Renders the diagrams for all features with the same settings.
The QgsDefaultValue class provides a container for managing client side default values for fields...
QgsGeometry::OperationResult addRing(const QVector< QgsPointXY > &ring, QgsFeatureId *featureId=nullptr)
Adds a ring to polygon/multipolygon features.
virtual void toSld(QDomDocument &doc, QDomElement &element, const QgsStringMap &props=QgsStringMap()) const
used from subclasses to create SLD Rule elements following SLD v1.1 specs
Constraint
Constraints which may be present on a field.
QSet< QString > excludeAttributesWfs() const
A set of attributes that are not advertised in WFS requests with QGIS server.
virtual bool addFeature(QgsFeature &f)
Adds a feature.
Field has been temporarily added in editing mode (originIndex = index in the list of added attributes...
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
Setting options for loading vector layers.
SimplifyAlgorithm simplifyAlgorithm() const
Gets the local simplification algorithm of the vector layer managed.
bool deleteFeature(QgsFeatureId fid)
Deletes a feature from the layer (but does not commit it).
void committedAttributesAdded(const QString &layerId, const QList< QgsField > &addedAttributes)
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the context.
QSet< QgsFeatureId > QgsFeatureIds
QList< QgsRelation > referencingRelations(const QgsVectorLayer *layer=nullptr, int fieldIdx=-2) const
Gets all relations where the specified layer (and field) is the referencing part (i.e.
void mapTipTemplateChanged()
Emitted when the map tip changes.
Class allowing to manage the auxiliary storage for a vector layer.
QgsFieldConstraints::Constraints fieldConstraints(int fieldIndex) const
Returns any constraints which are present at the provider for a specified field index.
void attributeDeleted(int idx)
QList< QgsFeature > QgsFeatureList
virtual void readXml(const QDomElement &elem, const QgsReadWriteContext &context)=0
Reads diagram state from a DOM element.
void readCommonStyle(const QDomElement &layerElement, const QgsReadWriteContext &context)
Read style data common to all layer types.
bool deleteStyleById_t(const QString &uri, QString styleID, QString &errCause)
static void warning(const QString &msg)
Goes to qWarning.
QVariant minimumValue(int index) const override
Returns the minimum value for an attribute column or an invalid variant in case of error...
Counts the features in a QgsVectorLayer in task.
void willBeDeleted()
Emitted in the destructor when the layer is about to be deleted, but it is still in a perfectly valid...
void setSize(double size)
Sets the size of the buffer.
A class to represent a 2D point.
friend class QgsVectorLayerFeatureSource
void setForceLocalOptimization(bool localOptimization)
Sets where the simplification executes, after fetch the geometries from provider, or when supported...
void readOnlyChanged()
Emitted when the read only state of this layer is changed.
bool renameAttribute(int index, const QString &newName)
Renames an attribute field (but does not commit it).
void invertSelectionInRectangle(QgsRectangle &rect)
Invert selection of features found within the search rectangle (in layer's coordinates) ...
void subsetStringChanged()
Emitted when the layer's subset string has changed.
QgsFeature getFeature(QgsFeatureId fid) const
Query the layer for the feature with the given id.
bool commitChanges()
Attempts to commit to the underlying data provider any buffered changes made since the last to call t...
virtual QSet< QgsMapLayerDependency > dependencies() const
Gets the list of layer ids on which this layer depends.
virtual QString loadNamedStyle(const QString &uri, bool &resultFlag)
Retrieve a named style for this layer if one exists (either as a .qml file on disk or as a record in ...
int selectedFeatureCount() const
Returns the number of features that are selected in this layer.
virtual QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context)
store renderer info to XML element
EditResult deleteVertex(QgsFeatureId featureId, int vertex)
Deletes a vertex from a feature.
virtual void setEncoding(const QString &e)
Set encoding used for accessing data from layer.
bool startEditing()
Makes the layer editable.
void setSimplifyHints(SimplifyHints simplifyHints)
Sets the simplification hints of the vector layer managed.
void setFont(const QFont &font)
Sets the font used for rendering text.
QgsVectorLayer(const QString &path=QString(), const QString &baseName=QString(), const QString &providerLib="ogr", const QgsVectorLayer::LayerOptions &options=QgsVectorLayer::LayerOptions())
Constructor - creates a vector layer.
bool deleteAttributes(const QList< int > &attrs)
Deletes a list of attribute fields (but does not commit it)
VertexMarkerType
Editing vertex markers.
void removeExpressionField(int index)
Remove an expression field.
void setFeatureBlendMode(QPainter::CompositionMode blendMode)
Sets the blending mode used for rendering each feature.
QVariant evaluate()
Evaluate the feature and return the result.
void readCustomProperties(const QDomNode &layerNode, const QString &keyStartsWith=QString())
Read custom properties from project file.
static QgsPainting::BlendMode getBlendModeEnum(QPainter::CompositionMode blendMode)
Returns a BlendMode corresponding to a QPainter::CompositionMode.
static QgsProperty fromField(const QString &fieldName, bool isActive=true)
Returns a new FieldBasedProperty created from the specified field name.
virtual QgsAttributeList pkAttributeIndexes() const
Returns list of indexes of fields that make up the primary key.
Remove from current selection.
void writeXml(QDomElement &layerElem, QDomDocument &doc) const
Writes the diagram settings to a DOM element.
static void mergeScaleDependencies(int mScaleMinDenom, int mScaleMaxDenom, QgsStringMap &props)
Merges the local scale limits, if any, with the ones already in the map, if any.
virtual void resolveReferences(QgsProject *project)
Resolve references to other layers (kept as layer IDs after reading XML) into layer objects...
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
QString encodedSource(const QString &source, const QgsReadWriteContext &context) const override
Called by writeLayerXML(), used by derived classes to encode provider's specific data source to proje...
~QgsVectorLayer() override
Class providing some utility methods to manage auxiliary storage.
SimplifyHint
Simplification flags for fast rendering of features.
Utility class for calculating aggregates for a field (or expression) over the features from a vector ...
double yOffset
Vertical offset of label.
void setLabeling(QgsAbstractVectorLayerLabeling *labeling)
Set labeling configuration.
Provider can create feature renderers using backend-specific formatting information. Since QGIS 3.2. See QgsVectorDataProvider::createRenderer().
void readCustomSymbology(const QDomElement &element, QString &errorMessage)
Signal emitted whenever the symbology (QML-file) for this layer is being read.
QString evalErrorString() const
Returns evaluation error.
QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
bool deleteFeatures(const QgsFeatureIds &fids)
Deletes a set of features from the layer (but does not commit it)
virtual const QgsLayerMetadata & metadata() const
Returns a reference to the layer's metadata store.
void readXml(const QDomNode &layer_node)
Reads joins from project file.
void raiseError(const QString &msg) const
Signals an error in this provider.
void configChanged()
Emitted whenever the configuration is changed.
void setDiagramRenderer(QgsDiagramRenderer *r)
Sets diagram rendering object (takes ownership)
Container of fields for a vector layer.
virtual void rollBack()
Stop editing and discard the edits.
bool readStyle(const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context) override
Read the style for the current layer from the Dom node supplied.
A geometry is the spatial representation of a feature.
Type type() const
Returns the dependency type.
void selectByIds(const QgsFeatureIds &ids, SelectBehavior behavior=SetSelection)
Select matching features using a list of feature IDs.
bool setAttribute(int field, const QVariant &attr)
Set an attribute's value by field index.
virtual QgsFeatureRenderer * createRenderer(const QVariantMap &configuration=QVariantMap()) const
Creates a new vector layer feature renderer, using provider backend specific information.
#define RENDERER_TAG_NAME
void beforeRemovingExpressionField(int idx)
Will be emitted, when an expression field is going to be deleted from this vector layer...
static QPainter::CompositionMode getCompositionMode(QgsPainting::BlendMode blendMode)
Returns a QPainter::CompositionMode corresponding to a BlendMode.
QgsChangedAttributesMap mChangedAttributeValues
Changed attributes values which are not committed.
bool needsGeometry() const
Returns true if the expression uses feature geometry for some computation.
Allows entering a context category and takes care of leaving this category on deletion of the class...
QgsEditorWidgetSetup editorWidgetSetup() const
Gets the editor widget setup for the field.
QSet< QVariant > uniqueValues(int fieldIndex, int limit=-1) const override
Calculates a list of unique values contained within an attribute in the layer.
QMap< QString, QgsMapLayer * > mapLayers() const
Returns a map of all registered layers by layer ID.
QMap< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrength > fieldConstraintsAndStrength(int fieldIndex) const
Returns a map of constraint with their strength for a specific field of the layer.
void setFields(const QgsFields &fields)
Convenience function for setting a fields for the scope.
void setDisplayExpression(const QString &displayExpression)
Set the preview expression, used to create a human readable preview string.
Stores information about constraints which may be present on a field.
Field comes from the underlying data provider of the vector layer (originIndex = index in provider's ...
int addTopologicalPoints(const QgsGeometry &geom)
Adds topological points for every vertex of the geometry.
bool isAuxiliaryField(int index, int &srcIndex) const
Returns true if the field comes from the auxiliary layer, false otherwise.
QSet< QString > referencedColumns() const
Gets list of columns referenced by the expression.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
static const int EditingCapabilities
Bitmask of all provider's editing capabilities.
bool isValid() const
Returns the status of the layer.
QgsChangedAttributesMap changedAttributeValues() const
Returns a map of features with changed attributes values which are not committed. ...
void beforeCommitChanges()
Is emitted, before changes are committed to the data provider.
bool qgsVariantGreaterThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is greater than the second.
QgsFeatureList selectedFeatures() const
Returns a copy of the user-selected features.
bool hasGeometry() const
Returns true if the feature has an associated geometry.
void committedFeaturesRemoved(const QString &layerId, const QgsFeatureIds &deletedFeatureIds)
This signal is emitted, when features are deleted from the provider.
QUuid addAction(QgsAction::ActionType type, const QString &name, const QString &command, bool capture=false)
Add an action with the given name and action details.
void committedAttributesDeleted(const QString &layerId, const QgsAttributeList &deletedAttributes)
This signal is emitted, when attributes are deleted from the provider.
void setBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering a layer.
void setConnection(const QString &aHost, const QString &aPort, const QString &aDatabase, const QString &aUsername, const QString &aPassword, SslMode sslmode=SslPrefer, const QString &authConfigId=QString())
Sets all connection related members at once.
bool isEditable() const override
Returns true if the provider is in editing 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)...
QgsMapLayer::LayerType type() const
Returns the type of the layer.
int count() const
Returns number of items.
void featureDeleted(QgsFeatureId fid)
Emitted when a feature has been deleted.
QMap< QString, QString > QgsStringMap
void editCommandEnded()
Signal emitted, when an edit command successfully ended.
OperationResult
Success or failure of a geometry operation.
QString username() const
Returns the username.
QgsFieldConstraints::Constraints fieldConstraints(int fieldIndex) const
Returns any constraints which are present for a specified field index.
void invertSelection()
Select not selected features and deselect selected ones.
void setParameters(const AggregateParameters ¶meters)
Sets all aggregate parameters from a parameter bundle.
bool qgsVariantLessThan(const QVariant &lhs, const QVariant &rhs)
Compares two QVariant values and returns whether the first is less than the second.
It has not been specified where the field comes from.
void deselect(QgsFeatureId featureId)
Deselect feature by its ID.
Constraint was set at data provider.
void styleChanged()
Signal emitted whenever a change affects the layer's style.
Field has an expression constraint set. See constraintExpression().
QgsExpressionContextScope * createExpressionContextScope() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
void setFormat(const QgsTextFormat &format)
Sets the label text formatting settings, e.g., font settings, buffer settings, etc.
virtual QgsRectangle extent() const
Returns the extent of the layer.
void setMapTipTemplate(const QString &mapTipTemplate)
The mapTip is a pretty, html representation for feature information.
void writeCustomProperties(QDomNode &layerNode, QDomDocument &doc) const
Write custom properties to project file.
void removeSelection()
Clear selection.
QString attributeAlias(int index) const
Returns the alias of an attribute name or a null string if there is no alias.
Manages joined fields for a vector layer.
QString decodedSource(const QString &source, const QString &provider, const QgsReadWriteContext &context) const override
Called by readLayerXML(), used by derived classes to decode provider's specific data source from proj...
bool readXml(const QDomNode &layer_node, QgsReadWriteContext &context) override
Reads vector layer specific state from project file Dom node.
QgsConditionalLayerStyles * conditionalStyles() const
Returns the conditional styles that are set for this layer.
virtual QgsLayerMetadata layerMetadata() const
Returns layer metadata collected from the provider's source.
QgsField at(int i) const
Gets field at particular index (must be in range 0..N-1)
void setAuxiliaryLayer(QgsAuxiliaryLayer *layer=nullptr)
Sets the current auxiliary layer.
QgsDataProvider * createProvider(const QString &providerKey, const QString &dataSource, const QgsDataProvider::ProviderOptions &options=QgsDataProvider::ProviderOptions())
Creates a new instance of a provider.
int fieldOriginIndex(int fieldIdx) const
Gets field's origin index (its meaning is specific to each type of origin)
static QgsTaskManager * taskManager()
Returns the application's task manager, used for managing application wide background task handling...
void dataChanged()
This is emitted whenever an asynchronous operation has finished and the data should be redrawn...
Base class for feedback objects to be used for cancelation of something running in a worker thread...
As part of the API refactoring and improvements which landed in the Processing API was substantially reworked from the x version This was done in order to allow much of the underlying Processing framework to be ported into c
void setFieldConstraint(int index, QgsFieldConstraints::Constraint constraint, QgsFieldConstraints::ConstraintStrength strength=QgsFieldConstraints::ConstraintStrengthHard)
Sets a constraint for a specified field index.
void featureAdded(QgsFeatureId fid)
virtual int listStylesInDatabase(QStringList &ids, QStringList &names, QStringList &descriptions, QString &msgError)
Lists all the style in db split into related to the layer and not related to.
QgsFeatureRequest & setExpressionContext(const QgsExpressionContext &context)
Sets the expression context used to evaluate filter expressions.
QgsRectangle mExtent
Extent of the layer.
void setExcludeAttributesWfs(const QSet< QString > &att)
A set of attributes that are not advertised in WFS requests with QGIS server.
QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext) override
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context...
QString loadDefaultStyle(bool &resultFlag) override
Retrieve the default style for this layer if one exists (either as a .qml file on disk or as a record...
QgsFeatureRequest & setFilterFid(QgsFeatureId fid)
Sets feature ID that should be fetched.
bool changeAttributeValue(QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue=QVariant())
Changes attribute value in joined layers.
Q_DECL_DEPRECATED void setDataSource(const QString &dataSource, const QString &baseName, const QString &provider, bool loadDefaultStyleFlag=false)
Update the data source of the layer.
QgsRectangle sourceExtent() const override
Returns the extent of all geometries from the source.
void committedGeometriesChanges(const QString &layerId, const QgsGeometryMap &changedGeometries)
QString host() const
Returns the host.
void setEditorWidgetSetup(int index, const QgsEditorWidgetSetup &setup)
The editor widget setup defines which QgsFieldFormatter and editor widget will be used for the field ...
QgsRectangle boundingBoxOfSelected() const
Returns the bounding box of the selected features. If there is no selection, QgsRectangle(0,0,0,0) is returned.
QgsFeatureRequest & setFilterExpression(const QString &expression)
Set the filter expression.
float maximumScale() const
Gets the maximum scale at which the layer should be simplified.
virtual void updateExtents(bool force=false)
Update the extents for the layer.
Type
The WKB type describes the number of dimensions a geometry has.
static QgsProviderRegistry * instance(const QString &pluginPath=QString())
Means of accessing canonical single instance.
QStringList uniqueStringsMatching(int index, const QString &substring, int limit=-1, QgsFeedback *feedback=nullptr) const
Returns unique string values of an attribute which contain a specified subset string.
bool readXml(const QDomNode &layer_node)
Reads the actions in in XML format.
int indexFromName(const QString &fieldName) const
Gets the field index from the field name.
static QVariant readVariant(const QDomElement &element)
Read a QVariant from a QDomElement.
QString htmlMetadata() const override
Obtain a formatted HTML string containing assorted metadata for this layer.
void setSize(double size)
Sets the size for rendered text.
const QList< QgsVectorLayerJoinInfo > vectorJoins() const
QString id() const
Returns the layer's unique ID, which is used to access this layer from QgsProject.
const QgsFeatureIds & selectedFeatureIds() const
Returns a list of the selected features IDs in this layer.
void readStyleManager(const QDomNode &layerNode)
Read style manager's configuration (if any). To be called by subclasses.
void triggerRepaint(bool deferredUpdate=false)
Will advise the map canvas (and any other interested party) that this layer requires to be repainted...
bool rollBack(bool deleteBuffer=true)
Stops a current editing operation and discards any uncommitted edits.
void attributeAdded(int idx)
bool equals(const QgsGeometry &geometry) const
Test if this geometry is exactly equal to another geometry.
QgsFields fields() const override
Returns the list of fields of this layer.
int removeParam(const QString &key)
Remove generic param (generic mode)
bool deleteFeature(QgsFeatureId fid) const
Deletes a feature from joined layers.
void select(QgsFeatureId featureId)
Select feature by its ID.
#define QgsDebugMsgLevel(str, level)
QgsRectangle extent() const override
Returns the extent of the layer.
QString typeName() const
Gets the field type.
void featureBlendModeChanged(QPainter::CompositionMode blendMode)
Signal emitted when setFeatureBlendMode() is called.
QString displayName() const
Returns the name to use when displaying this field.
virtual void setMetadata(const QgsLayerMetadata &metadata)
Sets the layer's metadata store.
static QgsFeatureRenderer * load(QDomElement &symbologyElem, const QgsReadWriteContext &context)
create a renderer from XML element
bool changeAttributeValues(QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues=QgsAttributeMap())
Changes attributes' values in joined layers.
Evaluates and returns the diagram settings relating to a diagram for a specific feature.
void setCrs(const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
Sets layer's spatial reference system.
QSet< QgsMapLayerDependency > mDependencies
List of layers that may modify this layer on modification.
void beforeModifiedCheck() const
Is emitted, when layer is checked for modifications. Use for last-minute additions.
QgsFeatureIterator getSelectedFeatures(QgsFeatureRequest request=QgsFeatureRequest()) const
Returns an iterator of the selected features.
virtual bool isValid() const =0
Returns true if this is a valid layer.
virtual QgsCoordinateReferenceSystem crs() const =0
Returns the coordinate system for the data source.
QString dataComment() const
Returns a description for this layer as defined in the data provider.
QList< QgsRelation > referencingRelations(int idx) const
Returns the layer's relations, where the foreign key is on this layer.
QgsFields fields() const override=0
Returns the fields associated with this data provider.
QString constraintDescription() const
Returns the descriptive name for the constraint expression.
long featureCount() const override
Returns feature count including changes which have not yet been committed If you need only the count ...
static QString geometryDisplayString(GeometryType type)
Returns a display string for a geometry type.
double width() const
Returns the width of the rectangle.
bool deleteFeatures(const QgsFeatureIds &fids) const
Deletes a list of features from joined layers.
virtual void setExtent(const QgsRectangle &rect)
Sets the extent.
Utility class that encapsulates an action based on vector attributes.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
double opacity() const
Returns the opacity for the vector layer, where opacity is a value between 0 (totally transparent) an...
void committedFeaturesAdded(const QString &layerId, const QgsFeatureList &addedFeatures)
This signal is emitted, when features are added to the provider.
void readXml(const QDomElement &elem)
Reads the diagram settings from a DOM element.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
bool writeSld(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsStringMap &props=QgsStringMap()) const
Writes the symbology of the layer into the document provided in SLD 1.1 format.
virtual QString dataSourceUri(bool expandAuthConfig=false) const
Gets the data source specification.
QgsWkbTypes::Type wkbType() const override
Returns the WKBType or WKBUnknown in case of error.
QgsGeometry::OperationResult splitFeatures(const QVector< QgsPointXY > &splitLine, bool topologicalEditing=false)
Splits features cut by the given line.
Defines left outer join from our vector layer to some other vector layer.
QgsGeometry::OperationResult splitFeatures(const QVector< QgsPointXY > &splitLine, bool topologicalEditing=false)
Splits features cut by the given line.
QMap< int, QVariant > QgsAttributeMap
virtual bool deleteAttribute(int attr)
Deletes an attribute field (but does not commit it).
void editingStopped()
Is emitted, when edited changes successfully have been written to the data provider.
void beforeEditingStarted()
Is emitted, before editing on this layer is started.
static GeometryType geometryType(Type type)
Returns the geometry type for a WKB type, e.g., both MultiPolygon and CurvePolygon would have a Polyg...
QgsGeometryMap mChangedGeometries
Changed geometries which are not committed.
int translateFeature(QgsFeatureId featureId, double dx, double dy)
Translates feature by dx, dy.
void setEnabled(bool enabled)
Sets whether the text buffer will be drawn.
long addTask(QgsTask *task, int priority=0)
Adds a task to the manager.
QString toString(int precision=16) const
Returns a string representation of form xmin,ymin : xmax,ymax Coordinates will be truncated to the sp...
bool moveVertex(double x, double y, QgsFeatureId atFeatureId, int atVertex)
Moves the vertex at the given position number, ring and item (first number is index 0)...
void setColor(const QColor &color)
Sets the color that text will be rendered in.
virtual bool isModified() const
Returns true if the provider has been modified since the last commit.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QgsAttributeList primaryKeyAttributes() const
Returns the list of attributes which make up the layer's primary keys.
void setLabelsEnabled(bool enabled)
Sets whether labels should be enabled for the layer.
void writeXml(QDomNode &layer_node, QDomDocument &document) const
Saves expressions to xml under the layer node.
QgsVectorLayerJoinInfo joinInfo() const
Returns information to use for joining with primary key and so on.
virtual bool changeGeometry(QgsFeatureId fid, const QgsGeometry &geom)
Change feature's geometry.
The QgsMapLayerLegend class is abstract interface for implementations of legends for one map layer...
virtual QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) const =0
Returns labeling configuration as XML element.
bool isSpatial() const override
Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeome...
void setFieldAlias(int index, const QString &aliasString)
Sets an alias (a display name) for attributes to display in dialogs.
QString description() const
Returns the descriptive name of the CRS, e.g., "WGS 84" or "GDA 94 / Vicgrid94".
float threshold() const
Gets the simplification threshold of the vector layer managed.
bool removeJoin(const QString &joinLayerId)
Removes a vector layer join.
void destroyEditCommand()
Destroy active command and reverts all changes in it.
An expression node which takes it value from a feature's field.
QgsCoordinateReferenceSystem crs() const
Returns the layer's spatial reference system.
Reads and writes project states.
Storage and management of actions associated with a layer.
QString publicSource() const
Gets a version of the internal layer definition that has sensitive bits removed (for example...
const QString GEO_EPSG_CRS_AUTHID
Geographic coord sys from EPSG authority.
virtual bool deleteFeatures(const QgsFeatureIds &fid)
Deletes a set of features from the layer (but does not commit it)
Provider can read layer metadata from data store. Since QGIS 3.0. See QgsDataProvider::layerMetadata(...
void geometryChanged(QgsFeatureId fid, const QgsGeometry &geometry)
Is emitted whenever a geometry change is done in the edit buffer.
bool setReadOnly(bool readonly=true)
Make layer read-only (editing disabled) or not.
void selectionChanged(const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect)
This signal is emitted when selection was changed.
virtual QString loadNamedStyle(const QString &theURI, bool &resultFlag, bool loadFromLocalDb)
Load a named style from file/local db/datasource db.
void setParam(const QString &key, const QString &value)
Set generic param (generic mode)
virtual bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=nullptr)
Adds a single feature to the sink.
virtual QgsTransaction * transaction() const
Returns the transaction this data provider is included in, if any.
T flagValue(const QString &key, const T &defaultValue, const Section section=NoSection)
Returns the setting value for a setting based on a flag.
QgsFeatureRenderer * renderer()
Returns renderer.
x-coordinate data defined diagram position
static QList< QgsExpressionContextScope * > globalProjectLayerScopes(const QgsMapLayer *layer)
Creates a list of three scopes: global, layer's project and layer.
QgsFeatureIds mDeletedFeatureIds
Deleted feature IDs which are not committed.
const QgsVectorJoinList & vectorJoins() const
Abstract base class for curved geometry type.
void removeCustomProperty(const QString &key)
Remove a custom property from layer.
void attributeValueChanged(QgsFeatureId fid, int idx, const QVariant &value)
Is emitted whenever an attribute value change is done in the edit buffer.
Encapsulate a field in an attribute table or data source.
virtual bool importNamedStyle(QDomDocument &doc, QString &errorMsg)
Import the properties of this layer from a QDomDocument.
void featureAdded(QgsFeatureId fid)
Emitted when a new feature has been added to the layer.
QgsEditFormConfig editFormConfig() const
Returns the configuration of the form used to represent this vector layer.
void setSimplifyAlgorithm(SimplifyAlgorithm simplifyAlgorithm)
Sets the local simplification algorithm of the vector layer managed.
const QgsAbstractVectorLayerLabeling * labeling() const
Access to const labeling configuration.
void rendererChanged()
Signal emitted when renderer is changed.
void updateFields(QgsFields &flds)
Adds fields with the expressions buffered in this object to a QgsFields object.
virtual bool isSaveAndLoadStyleToDatabaseSupported() const
It returns false by default.
Single scope for storing variables and functions for use within a QgsExpressionContext.
double minimumScale() const
Returns the minimum map scale (i.e.
virtual bool changeAttributeValues(QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues)
Changes values of attributes (but does not commit it).
Fast access to features using their ID.
QgsGeometry geometry() const
Returns the geometry associated with this feature.
QgsRelationManager relationManager
Whether diagram features act as obstacles for other diagrams/labels.
void setFeature(const QgsFeature &feature)
Convenience function for setting a feature for the scope.
double maximumScale() const
Returns the maximum map scale (i.e.
bool mValid
Indicates if the layer is valid and can be drawn.
QString port() const
Returns the port.
void raiseError(const QString &msg)
Signals an error related to this vector layer.
Add selection to current selection.
void editingStarted()
Is emitted, when editing on this layer has started.
void setName(const QString &name)
Set the display name of the layer.
QString capabilitiesString() const
Capabilities for this layer, comma separated and translated.
static void drawVertexMarker(double x, double y, QPainter &p, QgsVectorLayer::VertexMarkerType type, int vertexSize)
Draws a vertex symbol at (screen) coordinates x, y. (Useful to assist vertex editing.)
QVariant calculate(Aggregate aggregate, const QString &fieldOrExpression, QgsExpressionContext *context=nullptr, bool *ok=nullptr) const
Calculates the value of an aggregate.
QgsAuxiliaryLayer * auxiliaryLayer()
Returns the current auxiliary layer.
Point geometry type, with support for z-dimension and m-values.
Double value (including negative values)
QgsWkbTypes::GeometryType type() const
Returns type of the geometry as a QgsWkbTypes::GeometryType.
virtual QSet< QVariant > uniqueValues(int fieldIndex, int limit=-1) const
Returns the set of unique values contained within the specified fieldIndex from this source...
QString constraintDescription(int index) const
Returns the descriptive name for the constraint expression for a specified field index.
void symbolFeatureCountMapChanged()
Emitted when the feature count for symbols on this layer has been recalculated.
void endEditCommand()
Finish edit command and add it to undo/redo stack.
virtual bool commitChanges(QStringList &commitErrors)
Attempts to commit any changes to disk.
QPainter::CompositionMode featureBlendMode() const
Returns the current blending mode for features.
void setConstraint(Constraint constraint, ConstraintOrigin origin=ConstraintOriginLayer)
Sets a constraint on the field.
void committedAttributeValuesChanges(const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues)
This signal is emitted, when attribute value changes are saved to the provider.
void dirtied(const QString &sql, const QString &name)
Emitted if a sql query is executed and the underlying data is modified.
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings for fast rendering of features.
QString displayField() const
This is a shorthand for accessing the displayExpression if it is a simple field.
virtual bool deleteAttribute(int attr)
Delete an attribute field (but does not commit it)
bool readXml(const QDomNode &node, const QgsReadWriteContext &context)
Reads field ui properties specific state from Dom node.
bool hasDependencyCycle(const QSet< QgsMapLayerDependency > &layers) const
Checks whether a new set of dependencies will introduce a cycle.
Definition for a property.
void fullExtentCalculated()
This is emitted whenever the worker thread has fully calculated the PostGIS extents for this layer...
QgsGeometry::OperationResult addPart(const QList< QgsPointXY > &ring, QgsFeatureId featureId)
Adds a new part polygon to a multipart feature.
bool readSymbology(const QDomNode &layerNode, QString &errorMessage, QgsReadWriteContext &context) override
Read the symbology for the current layer from the Dom node supplied.
const QgsDiagramRenderer * diagramRenderer() const
bool loadAuxiliaryLayer(const QgsAuxiliaryStorage &storage, const QString &key=QString())
Loads the auxiliary layer for this vector layer.
QMap< int, QgsPropertyDefinition > QgsPropertiesDefinition
Definition of available properties.
void writeXml(QDomNode &node) const
Serialize to XML on layer save.
bool readExtentFromXml() const
Returns true if the extent is read from the XML document when data source has no metadata, false if it's the data provider which determines it.
void editCommandDestroyed()
Signal emitted, whan an edit command is destroyed.
void recalculateExtents() const
This is used to send a request that any mapcanvas using this layer update its extents.
Set selection, removing any existing selection.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const override
Query the layer for features specified in request.
int addExpressionField(const QString &exp, const QgsField &fld)
Add a new field which is calculated by the expression specified.
void setMaximumScale(float maximumScale)
Sets the maximum scale at which the layer should be simplified.
virtual bool isClosed() const
Returns true if the curve is closed.
void repaintRequested(bool deferredUpdate=false)
By emitting this signal the layer tells that either appearance or content have been changed and any v...
double yMinimum() const
Returns the y minimum value (bottom side of rectangle).
void reload() override
Synchronises with changes in the datasource.
QString uri(bool expandAuthConfig=true) const
Returns complete uri.
void selectByRect(QgsRectangle &rect, SelectBehavior behavior=SetSelection)
Select features found within the search rectangle (in layer's coordinates)
static QgsMapLayerLegend * defaultVectorLegend(QgsVectorLayer *vl)
Create new legend implementation for vector layer.
void setProviderEncoding(const QString &encoding)
Sets the textencoding of the data provider.
QgsExpressionContext createExpressionContext() const override
This method needs to be reimplemented in all classes which implement this interface and return an exp...
void relationsLoaded()
This signal is emitted when the relations were loaded after reading a project.
int addTopologicalPoints(const QgsGeometry &geom)
Adds topological points for every vertex of the geometry.
virtual void cancel()
Notifies the task that it should terminate.
Implementation of threaded rendering for vector layers.
void writeStyleManager(QDomNode &layerNode, QDomDocument &doc) const
Write style manager's configuration (if exists). To be called by subclasses.
QStringList commitErrors() const
Returns a list containing any error messages generated when attempting to commit changes to the layer...
Stores the settings for rendering of all diagrams for a layer.
double xMaximum() const
Returns the x maximum value (right side of rectangle).
QVector< QgsPoint > QgsPointSequence
void combineExtentWith(const QgsRectangle &rect)
Expands the rectangle so that it covers both the original rectangle and the given rectangle...
QString sourceName() const override
Returns a friendly display name for the source.
QString capabilitiesString() const
Returns the above in friendly format.
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
bool useRenderingOptimization() const
Returns true if the rendering optimization (geometry simplification) can be executed.
Modify current selection to include only select features which match.
QgsDefaultValue defaultValueDefinition(int index) const
Returns the definition of the expression used when calculating the default value for a field...
QMap< QgsFeatureId, QgsFeature > QgsFeatureMap
bool removeJoin(const QString &joinLayerId)
Removes a vector layer join.
QVariant maximumValue(int index) const override
Returns the maximum value for an attribute column or an invalid variant in case of error...
SelectBehavior
Selection behavior.
bool insertVertex(double x, double y, QgsFeatureId atFeatureId, int beforeVertex)
Insert a new vertex before the given vertex number, in the given ring, item (first number is index 0)...
QgsFeatureMap addedFeatures() const
Returns a map of new features which are not committed.
QVariant aggregate(QgsAggregateCalculator::Aggregate aggregate, const QString &fieldOrExpression, const QgsAggregateCalculator::AggregateParameters ¶meters=QgsAggregateCalculator::AggregateParameters(), QgsExpressionContext *context=nullptr, bool *ok=nullptr) const
Calculates an aggregated value from the layer's features.
QgsAttributeTableConfig attributeTableConfig() const
Returns the attribute table configuration object.
void selectByExpression(const QString &expression, SelectBehavior behavior=SetSelection)
Select matching features using an expression.
const QgsPathResolver & pathResolver() const
Returns path resolver for conversion between relative and absolute paths.
void attributeAdded(int idx)
Will be emitted, when a new attribute has been added to this vector layer.
virtual QString loadDefaultStyle(bool &resultFlag)
Retrieve the default style for this layer if one exists (either as a .qml file on disk or as a record...
void beforeAddingExpressionField(const QString &fieldName)
Will be emitted, when an expression field is going to be added to this vector layer.
Contains information about the context of a rendering operation.
Setting options for creating vector data providers.
QgsFieldConstraints constraints
bool updateFeature(const QgsFeature &feature, bool skipDefaultValues=false)
Updates an existing feature in the layer, replacing the attributes and geometry for the feature with ...
QString name() const
Returns the display name of the layer.
Buffers information about expression fields for a vector layer.
QString getStyleById_t(const QString &uri, QString styleID, QString &errCause)
bool isEmpty() const
Returns true if the configuration is empty, ie it contains no columns.
void editCommandStarted(const QString &text)
Signal emitted when a new edit command has been started.
QString loadStyle_t(const QString &uri, QString &errCause)
bool simplifyDrawingCanbeApplied(const QgsRenderContext &renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint) const
Returns whether the VectorLayer can apply the specified simplification hint.
QgsFeatureRequest & setFilterFids(const QgsFeatureIds &fids)
Sets feature IDs that should be fetched.
bool isCanceled() const
Tells whether the operation has been canceled already.
QSet< QgsMapLayerDependency > dependencies() const override
Gets the list of dependencies.
QgsEditorWidgetSetup editorWidgetSetup(int index) const
The editor widget setup defines which QgsFieldFormatter and editor widget will be used for the field ...
void displayExpressionChanged()
Emitted when the display expression changes.
QgsGeometry::OperationResult addRing(const QVector< QgsPointXY > &ring, const QgsFeatureIds &targetFeatureIds=QgsFeatureIds(), QgsFeatureId *modifiedFeatureId=nullptr)
Adds a ring to polygon/multipolygon features.
bool addJoin(const QgsVectorLayerJoinInfo &joinInfo)
Joins another vector layer to this layer.
int indexOf(const QString &fieldName) const
Gets the field index from the field name.
QString mDataSource
Data source description string, varies by layer type.
void attributeValueChanged(QgsFeatureId fid, int idx, const QVariant &)
QString source() const
Returns the source for the layer.
long featureCount() const override=0
Number of features in the layer.
const QgsDiagramLayerSettings * diagramLayerSettings() const
const QgsExpressionNode * rootNode() const
Returns root node of the expression. Root node is null is parsing has failed.
bool hasScaleBasedVisibility() const
Returns whether scale based visibility is enabled for the layer.
void setConstraintExpression(const QString &expression, const QString &description=QString())
Set the constraint expression for the field.
QgsCurve * clone() const override=0
Clones the geometry by performing a deep copy.
This class allows including a set of layers in a database-side transaction, provided the layer data p...
ConstraintStrength
Strength of constraints.
void updateExpression(int index, const QString &exp)
Changes the expression at a given index.
virtual void toSld(QDomNode &parent, const QgsStringMap &props) const
Writes the SE 1.1 TextSymbolizer element based on the current layer labeling settings.
bool prepare(const QgsExpressionContext *context)
Gets the expression ready for evaluation - find out column indexes.
void committedAttributeValuesChanges(const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues)
static QgsFeatureRenderer * loadSld(const QDomNode &node, QgsWkbTypes::GeometryType geomType, QString &errorMessage)
Create a new renderer according to the information contained in the UserStyle element of a SLD style ...
Container for settings relating to a text buffer.
virtual void reloadData()
Reloads the data from the source.
bool deleteSelectedFeatures(int *deletedCount=nullptr)
Deletes the selected features.
Edit operation was successful.
QString expressionField(int index) const
Returns the expression used for a given expression field.
virtual QList< QgsDiagramSettings > diagramSettings() const =0
Returns list with all diagram settings in the renderer.
bool forceLocalOptimization() const
Gets where the simplification executes, after fetch the geometries from provider, or when supported...
QString constraintExpression(int index) const
Returns the constraint expression for for a specified field index, if set.
The QgsConditionalLayerStyles class holds conditional style information for a layer.
bool moveVertex(double x, double y, QgsFeatureId atFeatureId, int atVertex)
Moves the vertex at the given position number, ring and item (first number is index 0)...
void updateFields(QgsFields &fields)
Updates field map with joined attributes.
void appendScope(QgsExpressionContextScope *scope)
Appends a scope to the end of the context.
void committedAttributesAdded(const QString &layerId, const QList< QgsField > &addedAttributes)
This signal is emitted, when attributes are added to the provider.
void readXml(const QDomNode &layer_node)
Reads expressions from project file.
static QgsProject * instance()
Returns the QgsProject singleton instance.
QgsRectangle boundingBox() const
Returns the bounding box of the geometry.
void removeExpression(int index)
Remove an expression from the buffer.
virtual QString dataComment() const
Returns a short comment for the data that this provider is providing access to (e.g.
This class represents a coordinate reference system (CRS).
QString layerId() const
Returns the ID of the layer this dependency depends on.
bool isField() const
Checks whether an expression consists only of a single field reference.
virtual QStringList uniqueStringsMatching(int index, const QString &substring, int limit=-1, QgsFeedback *feedback=nullptr) const
Returns unique string values of an attribute which contain a specified subset string.
friend class QgsVectorLayerEditBuffer
virtual bool isModified() const
Returns true if the provider has been modified since the last commit.
QHash< QString, long > symbolFeatureCountMap() const
Gets the count for each symbol.
bool isNull() const
Test if the rectangle is null (all coordinates zero or after call to setMinimal()).
Abstract base class - its implementations define different approaches to the labeling of a vector lay...
const QgsVectorLayerJoinInfo * joinForFieldIndex(int index, const QgsFields &fields, int &sourceFieldIndex) const
Finds the vector join for a layer field index.
SimplifyHints simplifyHints() const
Gets the simplification hints of the vector layer managed.
void removeFieldAlias(int index)
Removes an alias (a display name) for attributes to display in dialogs.
QgsVectorDataProvider * dataProvider() override
Returns the layer's data provider.
bool addFeatures(QgsFeatureList &features, QgsFeatureSink::Flags flags=nullptr) override
Adds a list of features to the sink.
bool isEmpty() const
Check whether the container is empty.
void writeCustomSymbology(QDomElement &element, QDomDocument &doc, QString &errorMessage) const
Signal emitted whenever the symbology (QML-file) for this layer is being written. ...
static QString displayString(Type type)
Returns a display string type for a WKB type, e.g., the geometry name used in WKT geometry representa...
virtual bool setSubsetString(const QString &subset)
Set the string (typically sql) used to define a subset of the layer.
QString writePath(const QString &filename) const
Prepare a filename to save it to the project file.
QgsVectorLayer::EditResult deleteVertex(QgsFeatureId featureId, int vertex)
Deletes a vertex from a feature.
double xMinimum() const
Returns the x minimum value (left side of rectangle).
void setDefaultValueDefinition(int index, const QgsDefaultValue &definition)
Sets the definition of the expression to use when calculating the default value for a field...
virtual QString getStyleFromDatabase(const QString &styleId, QString &msgError)
Will return the named style corresponding to style id provided.
virtual bool deleteFeature(QgsFeatureId fid)
Delete a feature from the layer (but does not commit it)
virtual bool enterUpdateMode()
Enter update mode.
void setSimplifyMethod(const QgsVectorSimplifyMethod &simplifyMethod)
Set the simplification settings for fast rendering of features.
friend class QgsVectorLayerEditPassthrough
bool readSld(const QDomNode &node, QString &errorMessage) override
Basic implementation of the labeling interface.
T enumValue(const QString &key, const T &defaultValue, const Section section=NoSection)
Returns the setting value for a setting based on an enum.
void dataChanged()
Data of layer changed.
void joinedFieldsChanged()
Emitted whenever the list of joined fields changes (e.g.
static QColor colorFromOgcFill(const QDomElement &fillElement)
Parse XML with OGC fill into QColor.
virtual bool changeAttributeValue(QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue=QVariant())
Changed an attribute value (but does not commit it)
QgsMapLayer * mapLayer(const QString &layerId) const
Retrieve a pointer to a registered layer by layer ID.
A grouped map of multiple QgsProperty objects, each referenced by a integer key value.
Base class for utility classes that encapsulate information necessary for rendering of map layers...
void setConstraintExpression(int index, const QString &expression, const QString &description=QString())
Set the constraint expression for the specified field index.
void setBuffer(const QgsTextBufferSettings &bufferSettings)
Sets the text's buffer settings.
Allows deletion of features.
double yMaximum() const
Returns the y maximum value (top side of rectangle).
bool isExpression
True if this label is made from a expression string, e.g., FieldName || 'mm'.
ConstraintOrigin constraintOrigin(Constraint constraint) const
Returns the origin of a field constraint, or ConstraintOriginNotSet if the constraint is not present ...
QString password() const
Returns the password.
virtual QgsRectangle extent() const =0
Returns the extent of the layer.
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).
Edit failed due to invalid layer.
QVariant customProperty(const QString &value, const QVariant &defaultValue=QVariant()) const
Read a custom property from layer.
QUndoStack * undoStack()
Returns pointer to layer's undo stack.
virtual QString storageType() const
Returns the permanent storage type for this layer as a friendly name.
void committedFeaturesRemoved(const QString &layerId, const QgsFeatureIds &deletedFeatureIds)
QList< int > QgsAttributeList
bool setDependencies(const QSet< QgsMapLayerDependency > &layers) override
Sets the list of dependencies.
QgsExpressionContextScope * popScope()
Removes the last scope from the expression context and return it.
static QgsExpressionContextScope * layerScope(const QgsMapLayer *layer)
Creates a new scope which contains variables and functions relating to a QgsMapLayer.
QString providerType() const
Returns the provider type for this layer.
void committedFeaturesAdded(const QString &layerId, const QgsFeatureList &addedFeatures)
void normalize()
Normalize the rectangle so it has non-negative width/height.
virtual bool deleteStyleFromDatabase(const QString &styleId, QString &msgError)
Delete a style from the database.
bool nextFeature(QgsFeature &f)
This is a container for configuration of the attribute table.
void setCoordinateSystem()
Setup the coordinate system transformation for the layer.
This is the base class for vector data providers.
void attributeDeleted(int idx)
Will be emitted, when an attribute has been deleted from this vector layer.
Container for all settings relating to text rendering.
QString constraintExpression() const
Returns the constraint expression for the field, if set.
static QgsFeatureRenderer * defaultRenderer(QgsWkbTypes::GeometryType geomType)
Returns a new renderer - used by default in vector layers.
bool changeAttributeValues(QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues=QgsAttributeMap(), bool skipDefaultValues=false)
Changes attributes' values for a feature (but does not immediately commit the changes).
Geometry is not required. It may still be returned if e.g. required for a filter condition.
void setEditFormConfig(const QgsEditFormConfig &editFormConfig)
Set the editFormConfig (configuration) of the form used to represent this vector layer.
void setLegend(QgsMapLayerLegend *legend)
Assign a legend controller to the map layer.
Class for storing the component parts of a PostgreSQL/RDBMS datasource URI.
bool changeGeometry(QgsFeatureId fid, const QgsGeometry &geometry, bool skipDefaultValue=false)
Changes a feature's geometry within the layer's edit buffer (but does not immediately commit the chan...
QgsFeatureMap mAddedFeatures
New features which are not committed.
void committedGeometriesChanges(const QString &layerId, const QgsGeometryMap &changedGeometries)
This signal is emitted, when geometry changes are saved to the provider.
This class models dependencies with or between map layers.
bool hasEvalError() const
Returns true if an error occurred when evaluating last input.
QString createSavepoint(QString &error)
creates a save point returns empty string on error returns the last created savepoint if it's not dir...
QString displayExpression() const
Returns the preview expression, used to create a human readable preview string.
void updateFields(QgsFields &fields)
void layerModified()
This signal is emitted when modifications has been done on layer.
Represents a vector layer which manages a vector based data sets.
bool addAttribute(const QgsField &field)
Add an attribute field (but does not commit it) returns true if the field was added.
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
virtual QgsFeatureIds allFeatureIds() const
Returns a list of all feature IDs for features present in the source.
virtual bool writeXml(QDomElement &collectionElem, const QgsPropertiesDefinition &definitions) const
Writes the current state of the property collection into an XML element.
bool writeStyle(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context) const override
Write just the style information for the layer into the document.
virtual void readXml(const QDomElement &elem, const QgsReadWriteContext &context)
Reads configuration from a DOM element previously written by writeXml()
Field is calculated from an expression.
void updatedFields()
Is emitted, whenever the fields available from this layer have been changed.
void updateExpressionField(int index, const QString &exp)
Changes the expression used to define an expression based (virtual) field.
QgsCoordinateReferenceSystem sourceCrs() const override
Returns the coordinate reference system for features in the source.
EditResult
Result of an edit operation.
void setAttributeTableConfig(const QgsAttributeTableConfig &attributeTableConfig)
Set the attribute table configuration object.
void layerModified()
This signal is emitted when modifications has been done on layer.
QgsAttributeList mDeletedAttributeIds
Deleted attributes fields which are not committed. The list is kept sorted.
static QgsRectangle readRectangle(const QDomElement &element)
QString attributeDisplayName(int index) const
Convenience function that returns the attribute alias if defined or the field name else...
void setColor(const QColor &color)
Sets the color for the buffer.
QString database() const
Returns the database.
void featureDeleted(QgsFeatureId fid)
static QDomElement writeVariant(const QVariant &value, QDomDocument &doc)
Write a QVariant to a QDomElement.
bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=nullptr) override
Adds a single feature to the sink.
QgsAuxiliaryLayer * createAuxiliaryLayer(const QgsField &field, QgsVectorLayer *layer) const
Creates an auxiliary layer for a vector layer.
QgsDefaultValue defaultValueDefinition
void set(const QgsPointXY &p1, const QgsPointXY &p2)
Sets the rectangle from two QgsPoints.
QString authid() const
Returns the authority identifier for the CRS.
void setDatabase(const QString &database)
Sets database.
void resolveReferences(QgsProject *project)
Resolves layer IDs of joined layers using given project's available layers.
static QgsAbstractVectorLayerLabeling * create(const QDomElement &element, const QgsReadWriteContext &context)
Try to create instance of an implementation based on the XML data.
QgsVectorLayer * clone() const override
Returns a new instance equivalent to this one.
virtual bool hasMetadata() const
Returns true if the data source has metadata, false otherwise.
void readXml(const QDomNode &node)
Deserialize to XML on layer load.
Aggregate
Available aggregates to calculate.
virtual bool leaveUpdateMode()
Leave update mode.
bool diagramsEnabled() const
Returns whether the layer contains diagrams which are enabled and should be drawn.
QPainter::CompositionMode blendMode() const
Returns the current blending mode for a layer.
double height() const
Returns the height of the rectangle.
QgsFeatureRequest & setFlags(QgsFeatureRequest::Flags flags)
Sets flags that affect how features will be fetched.
void setReadExtentFromXml(bool readExtentFromXml)
Flag allowing to indicate if the extent has to be read from the XML document when data source has no ...
QString joinLayerId() const
ID of the joined layer - may be used to resolve reference to the joined layer.
A bundle of parameters controlling aggregate calculation.
QVariant defaultValue(int index, const QgsFeature &feature=QgsFeature(), QgsExpressionContext *context=nullptr) const
Returns the calculated default value for the specified field index.
virtual void saveStyleToDatabase(const QString &name, const QString &description, bool useAsDefault, const QString &uiFileContent, QString &msgError)
Save named and sld style of the layer to the style table in the db.
void setThreshold(float threshold)
Sets the simplification threshold of the vector layer managed.
bool saveStyle_t(const QString &uri, const QString &qmlStyle, const QString &sldStyle, const QString &styleName, const QString &styleDescription, const QString &uiFileContent, bool useAsDefault, QString &errCause)
QString fieldName
Name of field (or an expression) to use for label text.
Field must have a unique value.
virtual QVariant defaultValue(int fieldIndex) const
Returns any literal default values which are present at the provider for a specified field index...
int listStyles_t(const QString &uri, QStringList &ids, QStringList &names, QStringList &descriptions, QString &errCause)
void setOpacity(double opacity)
Sets the opacity for the vector layer, where opacity is a value between 0 (totally transparent) and 1...
virtual void exportNamedStyle(QDomDocument &doc, QString &errorMsg) const
Export the properties of this layer as named style in a QDomDocument.