28 #include <QPainterPath> 30 #include <QProgressDialog> 34 #include <QStringBuilder> 49 #include "qgsexpressionnodeimpl.h" 95 #ifdef TESTPROVIDERLIB 101 const QString &qmlStyle,
102 const QString &sldStyle,
103 const QString &styleName,
104 const QString &styleDescription,
105 const QString &uiFileContent,
119 QStringList &descriptions,
137 const QString &baseName,
138 const QString &providerKey,
140 :
QgsMapLayer( VectorLayer, baseName, vectorLayerPath )
141 , mProviderKey( providerKey )
142 , mAuxiliaryLayer( nullptr )
143 , mAuxiliaryLayerKey( QString() )
144 , mReadExtentFromXml( options.readExtentFromXml )
150 mJoinBuffer->setParent(
this );
155 if ( !vectorLayerPath.isEmpty() && !mProviderKey.isEmpty() )
167 mSimplifyMethod.
setThreshold( settings.
value( QStringLiteral(
"qgis/simplifyDrawingTol" ), mSimplifyMethod.
threshold() ).toFloat() );
180 delete mDataProvider;
183 delete mExpressionFieldBuffer;
185 delete mDiagramLayerSettings;
186 delete mDiagramRenderer;
191 delete mConditionalStyles;
193 if ( mFeatureCounter )
194 mFeatureCounter->
cancel();
202 QList<QgsVectorLayerJoinInfo> joins =
vectorJoins();
259 auto constraintIt = constraints.constBegin();
260 for ( ; constraintIt != constraints.constEnd(); ++ constraintIt )
342 p.setPen( QColor( 50, 100, 120, 200 ) );
343 p.setBrush( QColor( 200, 200, 210, 120 ) );
344 p.drawEllipse( x - m, y - m, m * 2 + 1, m * 2 + 1 );
348 p.setPen( QColor( 255, 0, 0 ) );
349 p.drawLine( x - m, y + m, x + m, y - m );
350 p.drawLine( x - m, y - m, x + m, y + m );
356 mSelectedFeatureIds.insert( fid );
363 mSelectedFeatureIds.unite( featureIds );
370 mSelectedFeatureIds.remove( fid );
377 mSelectedFeatureIds.subtract( featureIds );
390 .setFilterRect( rect )
397 newSelection << feat.
id();
426 newSelection << feat.
id();
432 QgsExpression exp( expression );
433 exp.prepare( &context );
439 if ( !exp.needsGeometry() )
448 bool matches = exp.evaluate( &context ).toBool();
452 newSelection << feat.
id();
456 newSelection << feat.
id();
475 newSelection = mSelectedFeatureIds + ids;
479 newSelection = mSelectedFeatureIds - ids;
483 newSelection = mSelectedFeatureIds.intersect( ids );
487 QgsFeatureIds deselectedFeatures = mSelectedFeatureIds - newSelection;
488 mSelectedFeatureIds = newSelection;
496 if ( !intersectingIds.isEmpty() )
498 QgsDebugMsgLevel( QStringLiteral(
"Trying to select and deselect the same item at the same time. Unsure what to do. Selecting dubious items." ), 3 );
501 mSelectedFeatureIds -= deselectIds;
502 mSelectedFeatureIds += selectIds;
510 ids.subtract( mSelectedFeatureIds );
525 .setFilterRect( rect )
535 if ( mSelectedFeatureIds.contains( fet.
id() ) )
537 deselectIds << fet.
id();
541 selectIds << fet.
id();
550 if ( mSelectedFeatureIds.isEmpty() )
558 return mDataProvider;
563 return mDataProvider;
568 if (
mValid && mDataProvider && mDataProvider->
encoding() != encoding )
577 delete mDiagramRenderer;
578 mDiagramRenderer = r;
585 if (
mValid && mDataProvider )
591 QgsDebugMsgLevel( QStringLiteral(
"invalid layer or pointer to mDataProvider is null" ), 3 );
601 QgsDebugMsg( QStringLiteral(
"WARNING: This code should never be reached. Problems may occur..." ) );
625 .setFilterFids( mSelectedFeatureIds )
643 if ( mSelectedFeatureIds.contains( fet.
id() ) )
654 if ( retval.
width() == 0.0 || retval.
height() == 0.0 )
663 retval.
set( -1.0, -1.0, 1.0, 1.0 );
672 return mLabelsEnabled &&
static_cast< bool >( mLabeling );
677 mLabelsEnabled = enabled;
682 if ( !mDiagramRenderer || !mDiagramLayerSettings )
685 QList<QgsDiagramSettings> settingList = mDiagramRenderer->
diagramSettings();
686 if ( !settingList.isEmpty() )
688 return settingList.at( 0 ).enabled;
695 if ( !mSymbolFeatureCounted )
698 return mSymbolFeatureCountMap.value( legendKey );
703 if ( mSymbolFeatureCounted || mFeatureCounter )
704 return mFeatureCounter;
706 mSymbolFeatureCountMap.clear();
711 return mFeatureCounter;
713 if ( !mDataProvider )
716 return mFeatureCounter;
721 return mFeatureCounter;
724 if ( !mFeatureCounter )
733 return mFeatureCounter;
739 if ( force || !mReadExtentFromXml || ( mReadExtentFromXml && mXmlExtent.
isNull() ) )
740 mValidExtent =
false;
751 if ( !mDefaultValueOnUpdateFields.isEmpty() )
756 int size = mFields.
size();
757 for (
int idx : qgis::as_const( mDefaultValueOnUpdateFields ) )
759 if ( idx < 0 || idx >= size )
777 if ( !mValidExtent && mLazyExtent && mDataProvider && !mDataProvider->
hasMetadata() && mReadExtentFromXml && !mXmlExtent.
isNull() )
784 if ( !mValidExtent && mLazyExtent && mDataProvider )
801 if ( !
mValid || !mDataProvider )
803 QgsDebugMsgLevel( QStringLiteral(
"invoked with invalid layer or null mDataProvider" ), 3 );
825 if ( it->hasGeometry() )
871 if ( !
mValid || !mDataProvider )
873 QgsDebugMsgLevel( QStringLiteral(
"invoked with invalid layer or null mDataProvider" ), 3 );
881 if ( !
mValid || !mDataProvider )
883 QgsDebugMsgLevel( QStringLiteral(
"invoked with invalid layer or null mDataProvider" ), 3 );
904 double maximumSimplificationScale = mSimplifyMethod.
maximumScale();
907 return !( maximumSimplificationScale > 1 && renderContext.
rendererScale() <= maximumSimplificationScale );
914 return mConditionalStyles;
919 if ( !
mValid || !mDataProvider )
927 if ( !
mValid || !mEditBuffer || !mDataProvider )
930 bool success = mEditBuffer->
addFeature( feature );
945 if ( !mEditBuffer || !mDataProvider )
951 if ( currentFeature.
isValid() )
953 bool hasChanged =
false;
954 bool hasError =
false;
964 QgsDebugMsgLevel( QStringLiteral(
"geometry of feature %1 could not be changed." ).arg( updatedFeature.
id() ), 3 );
971 for (
int attr = 0; attr < fa.count(); ++attr )
973 if ( fa.at( attr ) != ca.at( attr ) )
981 QgsDebugMsgLevel( QStringLiteral(
"attribute %1 of feature %2 could not be changed." ).arg( attr ).arg( updatedFeature.
id() ), 3 );
986 if ( hasChanged && !mDefaultValueOnUpdateFields.isEmpty() && !skipDefaultValues )
987 updateDefaultValues( updatedFeature.
id(), updatedFeature );
993 QgsDebugMsgLevel( QStringLiteral(
"feature %1 could not be retrieved" ).arg( updatedFeature.
id() ), 3 );
1001 if ( !
mValid || !mEditBuffer || !mDataProvider )
1005 bool result = utils.
insertVertex( x, y, atFeatureId, beforeVertex );
1014 if ( !
mValid || !mEditBuffer || !mDataProvider )
1018 bool result = utils.
insertVertex( point, atFeatureId, beforeVertex );
1027 if ( !
mValid || !mEditBuffer || !mDataProvider )
1031 bool result = utils.
moveVertex( x, y, atFeatureId, atVertex );
1040 if ( !
mValid || !mEditBuffer || !mDataProvider )
1044 bool result = utils.
moveVertex( p, atFeatureId, atVertex );
1053 if ( !
mValid || !mEditBuffer || !mDataProvider )
1078 int count = mSelectedFeatureIds.size();
1091 *deletedCount = deleted;
1094 return deleted == count;
1099 if ( !
mValid || !mEditBuffer || !mDataProvider )
1100 return QgsGeometry::OperationResult::LayerNotEditable;
1106 if ( !mSelectedFeatureIds.isEmpty() )
1108 result = utils.
addRing( ring, mSelectedFeatureIds, featureId );
1111 if ( result != QgsGeometry::OperationResult::Success )
1122 if ( !
mValid || !mEditBuffer || !mDataProvider )
1125 return QgsGeometry::OperationResult::LayerNotEditable;
1130 return QgsGeometry::OperationResult::InvalidInputGeometryType;
1136 return QgsGeometry::OperationResult::AddRingNotClosed;
1143 if ( !mSelectedFeatureIds.isEmpty() )
1145 result = utils.
addRing( static_cast< QgsCurve * >( ring->
clone() ), mSelectedFeatureIds, featureId );
1148 if ( result != QgsGeometry::OperationResult::Success )
1160 if ( !
mValid || !mEditBuffer || !mDataProvider )
1161 return QgsGeometry::OperationResult::LayerNotEditable;
1165 if ( mSelectedFeatureIds.empty() )
1168 return QgsGeometry::OperationResult::SelectionIsEmpty;
1170 else if ( mSelectedFeatureIds.size() > 1 )
1173 return QgsGeometry::OperationResult::SelectionIsGreaterThanOne;
1179 if ( result == QgsGeometry::OperationResult::Success )
1186 if ( !
mValid || !mEditBuffer || !mDataProvider )
1187 return QgsGeometry::OperationResult::LayerNotEditable;
1191 if ( mSelectedFeatureIds.empty() )
1194 return QgsGeometry::OperationResult::SelectionIsEmpty;
1196 else if ( mSelectedFeatureIds.size() > 1 )
1199 return QgsGeometry::OperationResult::SelectionIsGreaterThanOne;
1205 if ( result == QgsGeometry::OperationResult::Success )
1212 if ( !
mValid || !mEditBuffer || !mDataProvider )
1213 return QgsGeometry::OperationResult::LayerNotEditable;
1217 if ( mSelectedFeatureIds.empty() )
1220 return QgsGeometry::OperationResult::SelectionIsEmpty;
1222 else if ( mSelectedFeatureIds.size() > 1 )
1225 return QgsGeometry::OperationResult::SelectionIsGreaterThanOne;
1231 if ( result == QgsGeometry::OperationResult::Success )
1238 if ( !
mValid || !mEditBuffer || !mDataProvider )
1239 return QgsGeometry::OperationResult::LayerNotEditable;
1244 if ( result == QgsGeometry::OperationResult::Success )
1251 if ( !
mValid || !mEditBuffer || !mDataProvider )
1252 return QgsGeometry::OperationResult::LayerNotEditable;
1255 return utils.
splitParts( splitLine, topologicalEditing );
1260 if ( !
mValid || !mEditBuffer || !mDataProvider )
1261 return QgsGeometry::OperationResult::LayerNotEditable;
1264 return utils.
splitFeatures( splitLine, topologicalEditing );
1269 if ( !
mValid || !mEditBuffer || !mDataProvider )
1278 if ( !
mValid || !mEditBuffer || !mDataProvider )
1287 if ( mLabeling == labeling )
1296 if ( !
mValid || !mDataProvider )
1361 QDomNode pkeyNode = layer_node.namedItem( QStringLiteral(
"provider" ) );
1363 if ( pkeyNode.isNull() )
1365 mProviderKey.clear();
1369 QDomElement pkeyElt = pkeyNode.toElement();
1370 mProviderKey = pkeyElt.text();
1374 if ( !mProviderKey.isNull() )
1379 else if (
mDataSource.contains( QLatin1String(
"dbname=" ) ) )
1381 mProviderKey = QStringLiteral(
"postgres" );
1385 mProviderKey = QStringLiteral(
"ogr" );
1388 if ( !setDataProvider( mProviderKey ) )
1393 QDomElement pkeyElem = pkeyNode.toElement();
1394 if ( !pkeyElem.isNull() )
1396 QString encodingString = pkeyElem.attribute( QStringLiteral(
"encoding" ) );
1397 if ( !encodingString.isEmpty() )
1404 mJoinBuffer->
readXml( layer_node );
1416 QDomNode depsNode = layer_node.namedItem( QStringLiteral(
"dataDependencies" ) );
1417 QDomNodeList depsNodes = depsNode.childNodes();
1418 QSet<QgsMapLayerDependency> sources;
1419 for (
int i = 0; i < depsNodes.count(); i++ )
1421 QString
source = depsNodes.at( i ).toElement().attribute( QStringLiteral(
"id" ) );
1429 if ( mReadExtentFromXml )
1431 QDomNode extentNode = layer_node.namedItem( QStringLiteral(
"extent" ) );
1432 if ( !extentNode.isNull() )
1439 const QDomNode asNode = layer_node.namedItem( QStringLiteral(
"auxiliaryLayer" ) );
1440 const QDomElement asElem = asNode.toElement();
1441 if ( !asElem.isNull() )
1443 mAuxiliaryLayerKey = asElem.attribute( QStringLiteral(
"key" ) );
1457 setDataProvider( provider );
1470 bool defaultLoadedFlag =
false;
1471 if ( loadDefaultStyleFlag )
1477 if ( !defaultLoadedFlag &&
isSpatial() )
1490 bool QgsVectorLayer::setDataProvider( QString
const &provider )
1492 mProviderKey = provider;
1496 QString checkUnicityKey = QStringLiteral(
"checkPrimaryKeyUnicity" );
1498 if ( provider.compare( QLatin1String(
"postgres" ) ) == 0 )
1502 if ( uri.
hasParam( checkUnicityKey ) )
1505 uri.
setParam( checkUnicityKey, mReadExtentFromXml ?
"0" :
"1" );
1506 dataSource = uri.
uri(
false );
1509 delete mDataProvider;
1511 if ( !mDataProvider )
1517 mDataProvider->setParent(
this );
1520 QgsDebugMsgLevel( QStringLiteral(
"Instantiated the data provider plugin" ), 2 );
1532 QgsDebugMsgLevel( QString(
"Set Data provider QgsLayerMetadata identifier[%1]" ).arg(
metadata().identifier() ), 4 );
1539 mWkbType = mDataProvider->
wkbType();
1543 if ( mProviderKey == QLatin1String(
"postgres" ) )
1548 QRegExp reg( R
"lit("[^"]+"\."([^"] + )"( \([^)]+\))?)lit" ); 1549 if ( reg.indexIn(
name() ) >= 0 )
1551 QStringList stuff = reg.capturedTexts();
1552 QString lName = stuff[1];
1556 QMap<QString, QgsMapLayer *>::const_iterator it;
1557 for ( it = layers.constBegin(); it != layers.constEnd() && ( *it )->name() != lName; ++it )
1560 if ( it != layers.constEnd() && stuff.size() > 2 )
1562 lName +=
'.' + stuff[2].mid( 2, stuff[2].length() - 3 );
1565 if ( !lName.isEmpty() )
1574 if ( dataProviderUri.hasParam( checkUnicityKey ) )
1578 else if ( mProviderKey == QLatin1String(
"osm" ) )
1583 else if ( provider == QLatin1String(
"ogr" ) )
1587 if (
mDataSource.right( 10 ) == QLatin1String(
"|layerid=0" ) )
1590 else if ( provider == QStringLiteral(
"memory" ) )
1607 QDomDocument &document,
1612 QDomElement mapLayerNode = layer_node.toElement();
1614 if ( mapLayerNode.isNull() || (
"maplayer" != mapLayerNode.nodeName() ) )
1620 mapLayerNode.setAttribute( QStringLiteral(
"type" ), QStringLiteral(
"vector" ) );
1626 if ( mDataProvider )
1628 QDomElement provider = document.createElement( QStringLiteral(
"provider" ) );
1629 provider.setAttribute( QStringLiteral(
"encoding" ), mDataProvider->
encoding() );
1630 QDomText providerText = document.createTextNode(
providerType() );
1631 provider.appendChild( providerText );
1632 layer_node.appendChild( provider );
1636 mJoinBuffer->
writeXml( layer_node, document );
1639 QDomElement dependenciesElement = document.createElement( QStringLiteral(
"layerDependencies" ) );
1644 QDomElement depElem = document.createElement( QStringLiteral(
"layer" ) );
1645 depElem.setAttribute( QStringLiteral(
"id" ), dep.
layerId() );
1646 dependenciesElement.appendChild( depElem );
1648 layer_node.appendChild( dependenciesElement );
1651 QDomElement dataDependenciesElement = document.createElement( QStringLiteral(
"dataDependencies" ) );
1656 QDomElement depElem = document.createElement( QStringLiteral(
"layer" ) );
1657 depElem.setAttribute( QStringLiteral(
"id" ), dep.
layerId() );
1658 dataDependenciesElement.appendChild( depElem );
1660 layer_node.appendChild( dataDependenciesElement );
1663 mExpressionFieldBuffer->
writeXml( layer_node, document );
1668 QDomElement asElem = document.createElement( QStringLiteral(
"auxiliaryLayer" ) );
1669 if ( mAuxiliaryLayer )
1671 const QString pkField = mAuxiliaryLayer->joinInfo().targetFieldName();
1672 asElem.setAttribute( QStringLiteral(
"key" ), pkField );
1674 layer_node.appendChild( asElem );
1678 return writeSymbology( layer_node, document, errorMsg, context );
1691 if ( !mExpressionFieldBuffer )
1693 mExpressionFieldBuffer->
readXml( layerNode );
1697 QDomElement layerElement = layerNode.toElement();
1700 readStyle( layerNode, errorMessage, context );
1702 mDisplayExpression = layerNode.namedItem( QStringLiteral(
"previewExpression" ) ).toElement().text();
1703 mMapTipTemplate = layerNode.namedItem( QStringLiteral(
"mapTip" ) ).toElement().text();
1705 QString
displayField = layerNode.namedItem( QStringLiteral(
"displayfield" ) ).toElement().text();
1711 if ( mMapTipTemplate.isEmpty() )
1712 mMapTipTemplate = displayField;
1716 if ( mDisplayExpression.isEmpty() )
1717 mDisplayExpression = QgsExpression::quotedColumnRef( displayField );
1721 mActions->
readXml( layerNode );
1723 mAttributeAliasMap.clear();
1724 QDomNode aliasesNode = layerNode.namedItem( QStringLiteral(
"aliases" ) );
1725 if ( !aliasesNode.isNull() )
1727 QDomElement aliasElem;
1729 QDomNodeList aliasNodeList = aliasesNode.toElement().elementsByTagName( QStringLiteral(
"alias" ) );
1730 for (
int i = 0; i < aliasNodeList.size(); ++i )
1732 aliasElem = aliasNodeList.at( i ).toElement();
1735 if ( aliasElem.hasAttribute( QStringLiteral(
"field" ) ) )
1737 field = aliasElem.attribute( QStringLiteral(
"field" ) );
1741 int index = aliasElem.attribute( QStringLiteral(
"index" ) ).toInt();
1743 if ( index >= 0 && index <
fields().count() )
1747 mAttributeAliasMap.insert( field, aliasElem.attribute( QStringLiteral(
"name" ) ) );
1752 mDefaultExpressionMap.clear();
1753 QDomNode defaultsNode = layerNode.namedItem( QStringLiteral(
"defaults" ) );
1754 if ( !defaultsNode.isNull() )
1756 QDomNodeList defaultNodeList = defaultsNode.toElement().elementsByTagName( QStringLiteral(
"default" ) );
1757 for (
int i = 0; i < defaultNodeList.size(); ++i )
1759 QDomElement defaultElem = defaultNodeList.at( i ).toElement();
1761 QString field = defaultElem.attribute( QStringLiteral(
"field" ), QString() );
1762 QString expression = defaultElem.attribute( QStringLiteral(
"expression" ), QString() );
1763 bool applyOnUpdate = defaultElem.attribute( QStringLiteral(
"applyOnUpdate" ), QStringLiteral(
"0" ) ) == QLatin1String(
"1" );
1764 if ( field.isEmpty() || expression.isEmpty() )
1767 mDefaultExpressionMap.insert( field,
QgsDefaultValue( expression, applyOnUpdate ) );
1772 mFieldConstraints.clear();
1773 mFieldConstraintStrength.clear();
1774 QDomNode constraintsNode = layerNode.namedItem( QStringLiteral(
"constraints" ) );
1775 if ( !constraintsNode.isNull() )
1777 QDomNodeList constraintNodeList = constraintsNode.toElement().elementsByTagName( QStringLiteral(
"constraint" ) );
1778 for (
int i = 0; i < constraintNodeList.size(); ++i )
1780 QDomElement constraintElem = constraintNodeList.at( i ).toElement();
1782 QString field = constraintElem.attribute( QStringLiteral(
"field" ), QString() );
1783 int constraints = constraintElem.attribute( QStringLiteral(
"constraints" ), QStringLiteral(
"0" ) ).toInt();
1784 if ( field.isEmpty() || constraints == 0 )
1787 mFieldConstraints.insert( field, static_cast< QgsFieldConstraints::Constraints >( constraints ) );
1789 int uniqueStrength = constraintElem.attribute( QStringLiteral(
"unique_strength" ), QStringLiteral(
"1" ) ).toInt();
1790 int notNullStrength = constraintElem.attribute( QStringLiteral(
"notnull_strength" ), QStringLiteral(
"1" ) ).toInt();
1791 int expStrength = constraintElem.attribute( QStringLiteral(
"exp_strength" ), QStringLiteral(
"1" ) ).toInt();
1798 mFieldConstraintExpressions.clear();
1799 QDomNode constraintExpressionsNode = layerNode.namedItem( QStringLiteral(
"constraintExpressions" ) );
1800 if ( !constraintExpressionsNode.isNull() )
1802 QDomNodeList constraintNodeList = constraintExpressionsNode.toElement().elementsByTagName( QStringLiteral(
"constraint" ) );
1803 for (
int i = 0; i < constraintNodeList.size(); ++i )
1805 QDomElement constraintElem = constraintNodeList.at( i ).toElement();
1807 QString field = constraintElem.attribute( QStringLiteral(
"field" ), QString() );
1808 QString exp = constraintElem.attribute( QStringLiteral(
"exp" ), QString() );
1809 QString desc = constraintElem.attribute( QStringLiteral(
"desc" ), QString() );
1810 if ( field.isEmpty() || exp.isEmpty() )
1813 mFieldConstraintExpressions.insert( field, qMakePair( exp, desc ) );
1820 mExcludeAttributesWMS.clear();
1821 QDomNode excludeWMSNode = layerNode.namedItem( QStringLiteral(
"excludeAttributesWMS" ) );
1822 if ( !excludeWMSNode.isNull() )
1824 QDomNodeList attributeNodeList = excludeWMSNode.toElement().elementsByTagName( QStringLiteral(
"attribute" ) );
1825 for (
int i = 0; i < attributeNodeList.size(); ++i )
1827 mExcludeAttributesWMS.insert( attributeNodeList.at( i ).toElement().text() );
1831 mExcludeAttributesWFS.clear();
1832 QDomNode excludeWFSNode = layerNode.namedItem( QStringLiteral(
"excludeAttributesWFS" ) );
1833 if ( !excludeWFSNode.isNull() )
1835 QDomNodeList attributeNodeList = excludeWFSNode.toElement().elementsByTagName( QStringLiteral(
"attribute" ) );
1836 for (
int i = 0; i < attributeNodeList.size(); ++i )
1838 mExcludeAttributesWFS.insert( attributeNodeList.at( i ).toElement().text() );
1843 QDomElement widgetsElem = layerNode.namedItem( QStringLiteral(
"fieldConfiguration" ) ).toElement();
1845 QDomNodeList fieldConfigurationElementList = widgetsElem.elementsByTagName( QStringLiteral(
"field" ) );
1847 for (
int i = 0; i < fieldConfigurationElementList.size(); ++i )
1849 const QDomElement fieldConfigElement = fieldConfigurationElementList.at( i ).toElement();
1850 const QDomElement fieldWidgetElement = fieldConfigElement.elementsByTagName( QStringLiteral(
"editWidget" ) ).at( 0 ).toElement();
1852 QString fieldName = fieldConfigElement.attribute( QStringLiteral(
"name" ) );
1854 const QString widgetType = fieldWidgetElement.attribute( QStringLiteral(
"type" ) );
1855 const QDomElement cfgElem = fieldConfigElement.elementsByTagName( QStringLiteral(
"config" ) ).at( 0 ).toElement();
1856 const QDomElement optionsElem = cfgElem.childNodes().at( 0 ).toElement();
1859 mFieldWidgetSetups[fieldName] = setup;
1862 mEditFormConfig.
readXml( layerNode, context );
1864 mAttributeTableConfig.
readXml( layerNode );
1866 mConditionalStyles->
readXml( layerNode, context );
1870 QDomElement mapLayerNode = layerNode.toElement();
1871 if ( mapLayerNode.attribute( QStringLiteral(
"readOnly" ), QStringLiteral(
"0" ) ).toInt() == 1 )
1888 if ( !rendererElement.isNull() )
1908 QDomElement labelingElement = node.firstChildElement( QStringLiteral(
"labeling" ) );
1910 if ( labelingElement.isNull() ||
1911 ( labelingElement.attribute( QStringLiteral(
"type" ) ) == QLatin1String(
"simple" ) && labelingElement.firstChildElement( QStringLiteral(
"settings" ) ).isNull() ) )
1919 labeling = readLabelingFromCustomProperties();
1927 if ( node.toElement().hasAttribute( QStringLiteral(
"labelsEnabled" ) ) )
1928 mLabelsEnabled = node.toElement().attribute( QStringLiteral(
"labelsEnabled" ) ).toInt();
1930 mLabelsEnabled =
true;
1933 QDomNode blendModeNode = node.namedItem( QStringLiteral(
"blendMode" ) );
1934 if ( !blendModeNode.isNull() )
1936 QDomElement e = blendModeNode.toElement();
1941 QDomNode featureBlendModeNode = node.namedItem( QStringLiteral(
"featureBlendMode" ) );
1942 if ( !featureBlendModeNode.isNull() )
1944 QDomElement e = featureBlendModeNode.toElement();
1949 QDomNode layerTransparencyNode = node.namedItem( QStringLiteral(
"layerTransparency" ) );
1950 if ( !layerTransparencyNode.isNull() )
1952 QDomElement e = layerTransparencyNode.toElement();
1953 setOpacity( 1.0 - e.text().toInt() / 100.0 );
1955 QDomNode layerOpacityNode = node.namedItem( QStringLiteral(
"layerOpacity" ) );
1956 if ( !layerOpacityNode.isNull() )
1958 QDomElement e = layerOpacityNode.toElement();
1962 QDomElement e = node.toElement();
1965 mSimplifyMethod.
setSimplifyHints( static_cast< QgsVectorSimplifyMethod::SimplifyHints >( e.attribute( QStringLiteral(
"simplifyDrawingHints" ), QStringLiteral(
"1" ) ).toInt() ) );
1966 mSimplifyMethod.
setSimplifyAlgorithm( static_cast< QgsVectorSimplifyMethod::SimplifyAlgorithm >( e.attribute( QStringLiteral(
"simplifyAlgorithm" ), QStringLiteral(
"0" ) ).toInt() ) );
1967 mSimplifyMethod.
setThreshold( e.attribute( QStringLiteral(
"simplifyDrawingTol" ), QStringLiteral(
"1" ) ).toFloat() );
1968 mSimplifyMethod.
setForceLocalOptimization( e.attribute( QStringLiteral(
"simplifyLocal" ), QStringLiteral(
"1" ) ).toInt() );
1969 mSimplifyMethod.
setMaximumScale( e.attribute( QStringLiteral(
"simplifyMaxScale" ), QStringLiteral(
"1" ) ).toFloat() );
1972 delete mDiagramRenderer;
1973 mDiagramRenderer =
nullptr;
1974 QDomElement singleCatDiagramElem = node.firstChildElement( QStringLiteral(
"SingleCategoryDiagramRenderer" ) );
1975 if ( !singleCatDiagramElem.isNull() )
1978 mDiagramRenderer->
readXml( singleCatDiagramElem, context );
1980 QDomElement linearDiagramElem = node.firstChildElement( QStringLiteral(
"LinearlyInterpolatedDiagramRenderer" ) );
1981 if ( !linearDiagramElem.isNull() )
1983 if ( linearDiagramElem.hasAttribute( QStringLiteral(
"classificationAttribute" ) ) )
1986 int idx = linearDiagramElem.attribute( QStringLiteral(
"classificationAttribute" ) ).toInt();
1987 if ( idx >= 0 && idx < mFields.
count() )
1988 linearDiagramElem.setAttribute( QStringLiteral(
"classificationField" ), mFields.
at( idx ).
name() );
1992 mDiagramRenderer->
readXml( linearDiagramElem, context );
1995 if ( mDiagramRenderer )
1997 QDomElement diagramSettingsElem = node.firstChildElement( QStringLiteral(
"DiagramLayerSettings" ) );
1998 if ( !diagramSettingsElem.isNull() )
2000 bool oldXPos = diagramSettingsElem.hasAttribute( QStringLiteral(
"xPosColumn" ) );
2001 bool oldYPos = diagramSettingsElem.hasAttribute( QStringLiteral(
"yPosColumn" ) );
2002 bool oldShow = diagramSettingsElem.hasAttribute( QStringLiteral(
"showColumn" ) );
2003 if ( oldXPos || oldYPos || oldShow )
2009 int xPosColumn = diagramSettingsElem.attribute( QStringLiteral(
"xPosColumn" ) ).toInt();
2010 if ( xPosColumn >= 0 && xPosColumn < mFields.
count() )
2015 int yPosColumn = diagramSettingsElem.attribute( QStringLiteral(
"yPosColumn" ) ).toInt();
2016 if ( yPosColumn >= 0 && yPosColumn < mFields.
count() )
2021 int showColumn = diagramSettingsElem.attribute( QStringLiteral(
"showColumn" ) ).toInt();
2022 if ( showColumn >= 0 && showColumn < mFields.
count() )
2025 QDomElement propertiesElem = diagramSettingsElem.ownerDocument().createElement( QStringLiteral(
"properties" ) );
2032 ddp.
writeXml( propertiesElem, defs );
2033 diagramSettingsElem.appendChild( propertiesElem );
2036 delete mDiagramLayerSettings;
2038 mDiagramLayerSettings->
readXml( diagramSettingsElem );
2048 QDomElement layerElement = node.toElement();
2051 ( void )
writeStyle( node, doc, errorMessage, context );
2053 QDomElement fieldConfigurationElement = doc.createElement( QStringLiteral(
"fieldConfiguration" ) );
2054 node.appendChild( fieldConfigurationElement );
2057 Q_FOREACH (
const QgsField &field, mFields )
2060 QDomElement fieldElement = doc.createElement( QStringLiteral(
"field" ) );
2061 fieldElement.setAttribute( QStringLiteral(
"name" ), field.
name() );
2063 fieldConfigurationElement.appendChild( fieldElement );
2068 QDomElement editWidgetElement = doc.createElement( QStringLiteral(
"editWidget" ) );
2069 fieldElement.appendChild( editWidgetElement );
2071 QDomElement editWidgetConfigElement = doc.createElement( QStringLiteral(
"config" ) );
2074 editWidgetElement.appendChild( editWidgetConfigElement );
2081 QDomElement aliasElem = doc.createElement( QStringLiteral(
"aliases" ) );
2082 Q_FOREACH (
const QgsField &field, mFields )
2084 QDomElement aliasEntryElem = doc.createElement( QStringLiteral(
"alias" ) );
2085 aliasEntryElem.setAttribute( QStringLiteral(
"field" ), field.
name() );
2086 aliasEntryElem.setAttribute( QStringLiteral(
"index" ), mFields.
indexFromName( field.
name() ) );
2087 aliasEntryElem.setAttribute( QStringLiteral(
"name" ), field.
alias() );
2088 aliasElem.appendChild( aliasEntryElem );
2090 node.appendChild( aliasElem );
2093 QDomElement excludeWMSElem = doc.createElement( QStringLiteral(
"excludeAttributesWMS" ) );
2094 QSet<QString>::const_iterator attWMSIt = mExcludeAttributesWMS.constBegin();
2095 for ( ; attWMSIt != mExcludeAttributesWMS.constEnd(); ++attWMSIt )
2097 QDomElement attrElem = doc.createElement( QStringLiteral(
"attribute" ) );
2098 QDomText attrText = doc.createTextNode( *attWMSIt );
2099 attrElem.appendChild( attrText );
2100 excludeWMSElem.appendChild( attrElem );
2102 node.appendChild( excludeWMSElem );
2105 QDomElement excludeWFSElem = doc.createElement( QStringLiteral(
"excludeAttributesWFS" ) );
2106 QSet<QString>::const_iterator attWFSIt = mExcludeAttributesWFS.constBegin();
2107 for ( ; attWFSIt != mExcludeAttributesWFS.constEnd(); ++attWFSIt )
2109 QDomElement attrElem = doc.createElement( QStringLiteral(
"attribute" ) );
2110 QDomText attrText = doc.createTextNode( *attWFSIt );
2111 attrElem.appendChild( attrText );
2112 excludeWFSElem.appendChild( attrElem );
2114 node.appendChild( excludeWFSElem );
2117 QDomElement defaultsElem = doc.createElement( QStringLiteral(
"defaults" ) );
2118 Q_FOREACH (
const QgsField &field, mFields )
2120 QDomElement defaultElem = doc.createElement( QStringLiteral(
"default" ) );
2121 defaultElem.setAttribute( QStringLiteral(
"field" ), field.
name() );
2124 defaultsElem.appendChild( defaultElem );
2126 node.appendChild( defaultsElem );
2129 QDomElement constraintsElem = doc.createElement( QStringLiteral(
"constraints" ) );
2130 Q_FOREACH (
const QgsField &field, mFields )
2132 QDomElement constraintElem = doc.createElement( QStringLiteral(
"constraint" ) );
2133 constraintElem.setAttribute( QStringLiteral(
"field" ), field.
name() );
2138 constraintsElem.appendChild( constraintElem );
2140 node.appendChild( constraintsElem );
2143 QDomElement constraintExpressionsElem = doc.createElement( QStringLiteral(
"constraintExpressions" ) );
2144 Q_FOREACH (
const QgsField &field, mFields )
2146 QDomElement constraintExpressionElem = doc.createElement( QStringLiteral(
"constraint" ) );
2147 constraintExpressionElem.setAttribute( QStringLiteral(
"field" ), field.
name() );
2150 constraintExpressionsElem.appendChild( constraintExpressionElem );
2152 node.appendChild( constraintExpressionsElem );
2156 mAttributeTableConfig.
writeXml( node );
2157 mEditFormConfig.
writeXml( node, context );
2158 mConditionalStyles->
writeXml( node, doc, context );
2161 if ( !mExpressionFieldBuffer )
2168 mExpressionFieldBuffer->
writeXml( node, doc );
2171 node.toElement().setAttribute( QStringLiteral(
"readOnly" ), mReadOnly );
2174 QDomElement prevExpElem = doc.createElement( QStringLiteral(
"previewExpression" ) );
2175 QDomText prevExpText = doc.createTextNode( mDisplayExpression );
2176 prevExpElem.appendChild( prevExpText );
2177 node.appendChild( prevExpElem );
2180 QDomElement mapTipElem = doc.createElement( QStringLiteral(
"mapTip" ) );
2181 QDomText mapTipText = doc.createTextNode( mMapTipTemplate );
2182 mapTipElem.appendChild( mapTipText );
2183 node.toElement().appendChild( mapTipElem );
2190 QDomElement mapLayerNode = node.toElement();
2198 QDomElement rendererElement = mRenderer->
save( doc, context );
2199 node.appendChild( rendererElement );
2204 QDomElement labelingElement = mLabeling->
save( doc, context );
2205 node.appendChild( labelingElement );
2207 mapLayerNode.setAttribute( QStringLiteral(
"labelsEnabled" ), mLabelsEnabled ? QStringLiteral(
"1" ) : QStringLiteral(
"0" ) );
2210 mapLayerNode.setAttribute( QStringLiteral(
"simplifyDrawingHints" ), QString::number( mSimplifyMethod.
simplifyHints() ) );
2211 mapLayerNode.setAttribute( QStringLiteral(
"simplifyAlgorithm" ), QString::number( mSimplifyMethod.
simplifyAlgorithm() ) );
2212 mapLayerNode.setAttribute( QStringLiteral(
"simplifyDrawingTol" ), QString::number( mSimplifyMethod.
threshold() ) );
2213 mapLayerNode.setAttribute( QStringLiteral(
"simplifyLocal" ), mSimplifyMethod.
forceLocalOptimization() ? 1 : 0 );
2214 mapLayerNode.setAttribute( QStringLiteral(
"simplifyMaxScale" ), QString::number( mSimplifyMethod.
maximumScale() ) );
2220 QDomElement blendModeElem = doc.createElement( QStringLiteral(
"blendMode" ) );
2222 blendModeElem.appendChild( blendModeText );
2223 node.appendChild( blendModeElem );
2226 QDomElement featureBlendModeElem = doc.createElement( QStringLiteral(
"featureBlendMode" ) );
2228 featureBlendModeElem.appendChild( featureBlendModeText );
2229 node.appendChild( featureBlendModeElem );
2232 QDomElement layerOpacityElem = doc.createElement( QStringLiteral(
"layerOpacity" ) );
2233 QDomText layerOpacityText = doc.createTextNode( QString::number(
opacity() ) );
2234 layerOpacityElem.appendChild( layerOpacityText );
2235 node.appendChild( layerOpacityElem );
2237 if ( mDiagramRenderer )
2239 mDiagramRenderer->
writeXml( mapLayerNode, doc, context );
2240 if ( mDiagramLayerSettings )
2241 mDiagramLayerSettings->
writeXml( mapLayerNode, doc );
2250 QDomElement nameElem = node.firstChildElement( QStringLiteral(
"Name" ) );
2251 if ( nameElem.isNull() )
2253 errorMessage = QStringLiteral(
"Warning: Name element not found within NamedLayer while it's required." );
2265 readSldLabeling( node );
2272 Q_UNUSED( errorMessage );
2283 QDomElement nameNode = doc.createElement( QStringLiteral(
"se:Name" ) );
2284 nameNode.appendChild( doc.createTextNode(
name() ) );
2285 node.appendChild( nameNode );
2287 QDomElement userStyleElem = doc.createElement( QStringLiteral(
"UserStyle" ) );
2288 node.appendChild( userStyleElem );
2290 QDomElement nameElem = doc.createElement( QStringLiteral(
"se:Name" ) );
2291 nameElem.appendChild( doc.createTextNode(
name() ) );
2293 userStyleElem.appendChild( nameElem );
2295 QDomElement featureTypeStyleElem = doc.createElement( QStringLiteral(
"se:FeatureTypeStyle" ) );
2296 userStyleElem.appendChild( featureTypeStyleElem );
2298 mRenderer->
toSld( doc, featureTypeStyleElem, localProps );
2301 mLabeling->
toSld( featureTypeStyleElem, localProps );
2310 if ( !mEditBuffer || !mDataProvider )
2322 if ( !skipDefaultValue && !mDefaultValueOnUpdateFields.isEmpty() )
2323 updateDefaultValues( fid );
2331 bool result =
false;
2333 switch (
fields().fieldOrigin( field ) )
2343 if ( mEditBuffer && mDataProvider )
2352 if ( result && !skipDefaultValues && !mDefaultValueOnUpdateFields.isEmpty() )
2353 updateDefaultValues( fid );
2368 for (
auto it = newValues.constBegin(); it != newValues.constEnd(); ++it )
2370 const int field = it.key();
2371 const QVariant newValue = it.value();
2374 if ( oldValues.contains( field ) )
2375 oldValue = oldValues[field];
2380 newValuesJoin[field] = newValue;
2381 oldValuesJoin[field] = oldValue;
2388 newValuesNotJoin[field] = newValue;
2389 oldValuesNotJoin[field] = oldValue;
2398 if ( ! newValuesJoin.isEmpty() && mJoinBuffer )
2403 if ( ! newValuesNotJoin.isEmpty() && mEditBuffer && mDataProvider )
2408 if ( result && !skipDefaultValues && !mDefaultValueOnUpdateFields.isEmpty() )
2410 updateDefaultValues( fid );
2418 if ( !mEditBuffer || !mDataProvider )
2426 if ( attIndex < 0 || attIndex >=
fields().count() )
2430 mFields[ attIndex ].setAlias( QString() );
2431 if ( mAttributeAliasMap.contains( name ) )
2433 mAttributeAliasMap.remove( name );
2435 mEditFormConfig.setFields( mFields );
2442 if ( index < 0 || index >=
fields().count() )
2449 if ( mExpressionFieldBuffer )
2465 if ( !mEditBuffer || !mDataProvider )
2481 if ( attIndex < 0 || attIndex >=
fields().count() )
2486 mAttributeAliasMap.insert( name, aliasString );
2487 mFields[ attIndex ].setAlias( aliasString );
2488 mEditFormConfig.setFields( mFields );
2494 if ( index < 0 || index >=
fields().count() )
2502 if ( index >= 0 && index < mFields.
count() )
2513 if ( !field.
alias().isEmpty() )
2514 map.insert( field.
name(), field.
alias() );
2521 if ( index < 0 || index >=
fields().count() )
2530 if ( !mEditBuffer || !mDataProvider )
2538 bool deleted =
false;
2541 attrs = attrs.toSet().toList();
2543 std::sort( attrs.begin(), attrs.end(), std::greater<int>() );
2545 Q_FOREACH (
int attr, attrs )
2567 mSelectedFeatureIds.remove( fid );
2578 QgsDebugMsgLevel( QStringLiteral(
"Cannot delete features (mEditBuffer==NULL)" ), 1 );
2589 mSelectedFeatureIds.subtract( fids );
2601 for (
int i = 0; i < mFields.
count(); ++i )
2605 pkAttributesList << i;
2608 return pkAttributesList;
2619 mCommitErrors.clear();
2621 if ( !mDataProvider )
2623 mCommitErrors << tr(
"ERROR: no provider" );
2629 mCommitErrors << tr(
"ERROR: layer not editable" );
2640 mEditBuffer =
nullptr;
2661 return mCommitErrors;
2691 mEditBuffer =
nullptr;
2696 if ( rollbackExtent )
2707 return mSelectedFeatureIds.size();
2712 return mSelectedFeatureIds;
2720 if ( mSelectedFeatureIds.count() <= 8 )
2736 features.push_back( f );
2745 if ( mSelectedFeatureIds.isEmpty() )
2751 if ( mSelectedFeatureIds.count() == 1 )
2752 request.
setFilterFid( *mSelectedFeatureIds.constBegin() );
2761 if ( !mEditBuffer || !mDataProvider )
2791 QgsExpression exp( mDisplayExpression );
2792 if ( exp.isField() )
2794 return static_cast<const QgsExpressionNodeColumnRef *
>( exp.rootNode() )->
name();
2802 if ( mDisplayExpression == displayExpression )
2811 if ( !mDisplayExpression.isEmpty() || mFields.
isEmpty() )
2813 return mDisplayExpression;
2819 Q_FOREACH (
const QgsField &field, mFields )
2821 QString fldName = field.
name();
2827 if ( fldName.indexOf( QLatin1String(
"name" ), 0, Qt::CaseInsensitive ) > -1 )
2832 if ( fldName.indexOf( QLatin1String(
"descrip" ), 0, Qt::CaseInsensitive ) > -1 )
2837 if ( fldName.indexOf( QLatin1String(
"id" ), 0, Qt::CaseInsensitive ) > -1 )
2844 if ( !idxName.isNull() )
2846 return QgsExpression::quotedColumnRef( idxName );
2850 return QgsExpression::quotedColumnRef( mFields.
at( 0 ).
name() );
2857 return ( mEditBuffer && mDataProvider );
2866 bool QgsVectorLayer::isReadOnly()
const 2874 if ( readonly && mEditBuffer )
2877 mReadOnly = readonly;
2885 return mEditBuffer && mEditBuffer->
isModified();
2891 bool auxiliaryField =
false;
2895 return auxiliaryField;
2902 auxiliaryField =
true;
2905 return auxiliaryField;
2913 if ( r != mRenderer )
2917 mSymbolFeatureCounted =
false;
2918 mSymbolFeatureCountMap.clear();
2927 if ( !mDataProvider )
2933 QString ignoredError;
2937 mEditCommandActive =
true;
2943 if ( !mDataProvider )
2948 mEditCommandActive =
false;
2949 if ( !mDeletedFids.isEmpty() )
2952 mDeletedFids.clear();
2959 if ( !mDataProvider )
2965 mEditCommandActive =
false;
2966 mDeletedFids.clear();
2972 return mJoinBuffer->
addJoin( joinInfo );
2978 return mJoinBuffer->
removeJoin( joinLayerId );
3008 if ( oi < 0 || oi >= mExpressionFieldBuffer->
expressions().size() )
3011 return mExpressionFieldBuffer->
expressions().at( oi ).cachedExpression.expression();
3022 if ( !mDataProvider )
3027 mFields = mDataProvider->
fields();
3037 if ( mExpressionFieldBuffer )
3041 QMap< QString, QString >::const_iterator aliasIt = mAttributeAliasMap.constBegin();
3042 for ( ; aliasIt != mAttributeAliasMap.constEnd(); ++aliasIt )
3048 mFields[ index ].setAlias( aliasIt.value() );
3052 mDefaultValueOnUpdateFields.clear();
3053 QMap< QString, QgsDefaultValue >::const_iterator defaultIt = mDefaultExpressionMap.constBegin();
3054 for ( ; defaultIt != mDefaultExpressionMap.constEnd(); ++defaultIt )
3056 int index = mFields.
lookupField( defaultIt.key() );
3060 mFields[ index ].setDefaultValueDefinition( defaultIt.value() );
3061 if ( defaultIt.value().applyOnUpdate() )
3062 mDefaultValueOnUpdateFields.insert( index );
3065 QMap< QString, QgsFieldConstraints::Constraints >::const_iterator constraintIt = mFieldConstraints.constBegin();
3066 for ( ; constraintIt != mFieldConstraints.constEnd(); ++constraintIt )
3068 int index = mFields.
lookupField( constraintIt.key() );
3081 mFields[ index ].setConstraints( constraints );
3084 QMap< QString, QPair< QString, QString > >::const_iterator constraintExpIt = mFieldConstraintExpressions.constBegin();
3085 for ( ; constraintExpIt != mFieldConstraintExpressions.constEnd(); ++constraintExpIt )
3087 int index = mFields.
lookupField( constraintExpIt.key() );
3098 mFields[ index ].setConstraints( constraints );
3102 for ( ; constraintStrengthIt != mFieldConstraintStrength.constEnd(); ++constraintStrengthIt )
3104 int index = mFields.
lookupField( constraintStrengthIt.key().first );
3114 constraints.
setConstraintStrength( constraintStrengthIt.key().second, constraintStrengthIt.value() );
3115 mFields[ index ].setConstraints( constraints );
3118 auto fieldWidgetIterator = mFieldWidgetSetups.constBegin();
3119 for ( ; fieldWidgetIterator != mFieldWidgetSetups.constEnd(); ++ fieldWidgetIterator )
3121 int index = mFields.
indexOf( fieldWidgetIterator.key() );
3125 mFields[index].setEditorWidgetSetup( fieldWidgetIterator.value() );
3128 if ( oldFields != mFields )
3131 mEditFormConfig.setFields( mFields );
3138 if ( index < 0 || index >= mFields.
count() )
3142 if ( expression.isEmpty() )
3146 std::unique_ptr< QgsExpressionContext > tempContext;
3151 evalContext = tempContext.get();
3163 QgsExpression exp( expression );
3164 exp.prepare( evalContext );
3165 if ( exp.hasEvalError() )
3171 val = exp.evaluate( evalContext );
3184 if ( index < 0 || index >= mFields.
count() )
3189 mDefaultExpressionMap.insert( mFields.
at( index ).
name(), definition );
3193 mDefaultExpressionMap.remove( mFields.
at( index ).
name() );
3200 if ( index < 0 || index >= mFields.
count() )
3209 if ( !mDataProvider )
3222 uniqueValues = mDataProvider->
uniqueValues( index, limit );
3227 Q_FOREACH (
const QVariant &v, uniqueValues )
3229 vals << v.toString();
3233 QMapIterator< QgsFeatureId, QgsFeature > addedIt( added );
3234 while ( addedIt.hasNext() && ( limit < 0 || uniqueValues.count() < limit ) )
3237 QVariant v = addedIt.value().attribute( index );
3240 QString vs = v.toString();
3241 if ( !vals.contains( vs ) )
3250 while ( it.hasNext() && ( limit < 0 || uniqueValues.count() < limit ) )
3253 QVariant v = it.value().value( index );
3256 QString vs = v.toString();
3257 if ( !vals.contains( vs ) )
3276 uniqueValues = mDataProvider->
uniqueValues( index, limit );
3289 .setSubsetOfAttributes( attList ) );
3292 QVariant currentValue;
3293 QHash<QString, QVariant> val;
3297 val.insert( currentValue.toString(), currentValue );
3298 if ( limit >= 0 && val.size() >= limit )
3304 return val.values().toSet();
3308 Q_ASSERT_X(
false,
"QgsVectorLayer::uniqueValues()",
"Unknown source of the field!" );
3314 QStringList results;
3315 if ( !mDataProvider )
3333 QMapIterator< QgsFeatureId, QgsFeature > addedIt( added );
3334 while ( addedIt.hasNext() && ( limit < 0 || results.count() < limit ) && ( !feedback || !feedback->
isCanceled() ) )
3337 QVariant v = addedIt.value().attribute( index );
3340 QString vs = v.toString();
3341 if ( vs.contains( substring, Qt::CaseInsensitive ) && !results.contains( vs ) )
3349 while ( it.hasNext() && ( limit < 0 || results.count() < limit ) && ( !feedback || !feedback->
isCanceled() ) )
3352 QVariant v = it.value().value( index );
3355 QString vs = v.toString();
3356 if ( vs.contains( substring, Qt::CaseInsensitive ) && !results.contains( vs ) )
3387 QString fieldName = mFields.
at( index ).
name();
3388 request.
setFilterExpression( QStringLiteral(
"\"%1\" ILIKE '%%2%'" ).arg( fieldName, substring ) );
3392 QString currentValue;
3395 currentValue = f.
attribute( index ).toString();
3396 if ( !results.contains( currentValue ) )
3397 results << currentValue;
3399 if ( ( limit >= 0 && results.size() >= limit ) || ( feedback && feedback->
isCanceled() ) )
3409 Q_ASSERT_X(
false,
"QgsVectorLayer::uniqueStringsMatching()",
"Unknown source of the field!" );
3415 if ( !mDataProvider )
3433 QMapIterator< QgsFeatureId, QgsFeature > addedIt( added );
3434 while ( addedIt.hasNext() )
3437 QVariant v = addedIt.value().attribute( index );
3445 while ( it.hasNext() )
3448 QVariant v = it.value().value( index );
3480 .setSubsetOfAttributes( attList ) );
3483 double minimumValue = std::numeric_limits<double>::max();
3484 double currentValue = 0;
3487 currentValue = f.
attribute( index ).toDouble();
3488 if ( currentValue < minimumValue )
3490 minimumValue = currentValue;
3493 return QVariant( minimumValue );
3497 Q_ASSERT_X(
false,
"QgsVectorLayer::minimumValue()",
"Unknown source of the field!" );
3503 if ( !mDataProvider )
3520 QMapIterator< QgsFeatureId, QgsFeature > addedIt( added );
3521 while ( addedIt.hasNext() )
3524 QVariant v = addedIt.value().attribute( index );
3532 while ( it.hasNext() )
3535 QVariant v = it.value().value( index );
3565 .setSubsetOfAttributes( attList ) );
3568 double maximumValue = -std::numeric_limits<double>::max();
3569 double currentValue = 0;
3572 currentValue = f.
attribute( index ).toDouble();
3573 if ( currentValue > maximumValue )
3575 maximumValue = currentValue;
3578 return QVariant( maximumValue );
3582 Q_ASSERT_X(
false,
"QgsVectorLayer::maximumValue()",
"Unknown source of the field!" );
3592 if ( !mDataProvider )
3598 int attrIndex = mFields.
lookupField( fieldOrExpression );
3599 if ( attrIndex >= 0 )
3606 bool providerOk =
false;
3607 QVariant val = mDataProvider->
aggregate( aggregate, attrIndex, parameters, context, providerOk );
3621 return c.
calculate( aggregate, fieldOrExpression, context, ok );
3633 return mFeatureBlendMode;
3645 return mLayerOpacity;
3650 void QgsVectorLayer::readSldLabeling(
const QDomNode &node )
3655 QDomElement element = node.toElement();
3656 if ( element.isNull() )
3659 QDomElement userStyleElem = element.firstChildElement( QStringLiteral(
"UserStyle" ) );
3660 if ( userStyleElem.isNull() )
3662 QgsDebugMsgLevel( QStringLiteral(
"Info: UserStyle element not found." ), 4 );
3666 QDomElement featureTypeStyleElem = userStyleElem.firstChildElement( QStringLiteral(
"FeatureTypeStyle" ) );
3667 if ( featureTypeStyleElem.isNull() )
3669 QgsDebugMsgLevel( QStringLiteral(
"Info: FeatureTypeStyle element not found." ), 4 );
3674 QDomElement ruleElem = featureTypeStyleElem.lastChildElement( QStringLiteral(
"Rule" ) );
3675 if ( ruleElem.isNull() )
3682 QDomElement textSymbolizerElem = ruleElem.lastChildElement( QStringLiteral(
"TextSymbolizer" ) );
3683 if ( textSymbolizerElem.isNull() )
3685 QgsDebugMsgLevel( QStringLiteral(
"Info: TextSymbolizer element not found." ), 4 );
3692 QDomElement labelElem = textSymbolizerElem.firstChildElement( QStringLiteral(
"Label" ) );
3693 if ( !labelElem.isNull() )
3695 QDomElement propertyNameElem = labelElem.firstChildElement( QStringLiteral(
"PropertyName" ) );
3696 if ( !propertyNameElem.isNull() )
3701 QString labelAttribute = propertyNameElem.text();
3705 int fieldIndex = mFields.
lookupField( labelAttribute );
3706 if ( fieldIndex == -1 )
3709 QgsExpression exp( labelAttribute );
3710 if ( !exp.hasEvalError() )
3716 QgsDebugMsgLevel( QStringLiteral(
"SLD label attribute error: %1" ).arg( exp.evalErrorString() ), 3 );
3722 QgsDebugMsgLevel( QStringLiteral(
"Info: PropertyName element not found." ), 4 );
3732 QString fontFamily = QStringLiteral(
"Sans-Serif" );
3733 int fontPointSize = 10;
3734 int fontWeight = -1;
3735 bool fontItalic =
false;
3736 bool fontUnderline =
false;
3739 QDomElement fontElem = textSymbolizerElem.firstChildElement( QStringLiteral(
"Font" ) );
3740 if ( !fontElem.isNull() )
3744 QDomElement cssElem = fontElem.firstChildElement( QStringLiteral(
"CssParameter" ) );
3745 while ( !cssElem.isNull() )
3747 cssName = cssElem.attribute( QStringLiteral(
"name" ), QStringLiteral(
"not_found" ) );
3748 if ( cssName != QLatin1String(
"not_found" ) )
3750 elemText = cssElem.text();
3751 if ( cssName == QLatin1String(
"font-family" ) )
3753 fontFamily = elemText;
3755 else if ( cssName == QLatin1String(
"font-style" ) )
3757 fontItalic = ( elemText == QLatin1String(
"italic" ) ) || ( elemText == QLatin1String(
"Italic" ) );
3759 else if ( cssName == QLatin1String(
"font-size" ) )
3762 int fontSize = elemText.toInt( &ok );
3765 fontPointSize = fontSize;
3768 else if ( cssName == QLatin1String(
"font-weight" ) )
3770 if ( ( elemText == QLatin1String(
"bold" ) ) || ( elemText == QLatin1String(
"Bold" ) ) )
3771 fontWeight = QFont::Bold;
3773 else if ( cssName == QLatin1String(
"font-underline" ) )
3775 fontUnderline = ( elemText == QLatin1String(
"underline" ) ) || ( elemText == QLatin1String(
"Underline" ) );
3779 cssElem = cssElem.nextSiblingElement( QStringLiteral(
"CssParameter" ) );
3784 QFont font( fontFamily, fontPointSize, fontWeight, fontItalic );
3785 font.setUnderline( fontUnderline );
3787 format.
setSize( fontPointSize );
3791 if ( textColor.isValid() )
3799 QDomElement haloElem = textSymbolizerElem.firstChildElement( QStringLiteral(
"Halo" ) );
3800 if ( !haloElem.isNull() )
3805 QDomElement radiusElem = haloElem.firstChildElement( QStringLiteral(
"Radius" ) );
3806 if ( !radiusElem.isNull() )
3809 double bufferSize = radiusElem.text().toDouble( &ok );
3812 bufferSettings.
setSize( bufferSize );
3817 if ( bufferColor.isValid() )
3819 bufferSettings.
setColor( bufferColor );
3824 QDomElement labelPlacementElem = textSymbolizerElem.firstChildElement( QStringLiteral(
"LabelPlacement" ) );
3825 if ( !labelPlacementElem.isNull() )
3828 QDomElement pointPlacementElem = labelPlacementElem.firstChildElement( QStringLiteral(
"PointPlacement" ) );
3829 if ( !pointPlacementElem.isNull() )
3833 QDomElement displacementElem = pointPlacementElem.firstChildElement( QStringLiteral(
"Displacement" ) );
3834 if ( !displacementElem.isNull() )
3836 QDomElement displacementXElem = displacementElem.firstChildElement( QStringLiteral(
"DisplacementX" ) );
3837 if ( !displacementXElem.isNull() )
3840 double xOffset = displacementXElem.text().toDouble( &ok );
3846 QDomElement displacementYElem = displacementElem.firstChildElement( QStringLiteral(
"DisplacementY" ) );
3847 if ( !displacementYElem.isNull() )
3850 double yOffset = displacementYElem.text().toDouble( &ok );
3858 QDomElement rotationElem = pointPlacementElem.firstChildElement( QStringLiteral(
"Rotation" ) );
3859 if ( !rotationElem.isNull() )
3862 double rotation = rotationElem.text().toDouble( &ok );
3879 return mEditFormConfig;
3884 if ( mEditFormConfig == editFormConfig )
3888 mEditFormConfig.onRelationsLoaded();
3894 return mMapTipTemplate;
3899 if ( mMapTipTemplate == mapTip )
3902 mMapTipTemplate = mapTip;
3918 if ( mAttributeTableConfig != attributeTableConfig )
3937 if ( !mDiagramLayerSettings )
3939 *mDiagramLayerSettings = s;
3945 QString myMetadata = QStringLiteral(
"<html>\n<body>\n" );
3948 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Information from provider" ) + QStringLiteral(
"</h1>\n<hr>\n" );
3949 myMetadata += QLatin1String(
"<table class=\"list-view\">\n" );
3952 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Original" ) + QStringLiteral(
"</td><td>" ) +
name() + QStringLiteral(
"</td></tr>\n" );
3955 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Name" ) + QStringLiteral(
"</td><td>" ) +
name() + QStringLiteral(
"</td></tr>\n" );
3958 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Source" ) + QStringLiteral(
"</td><td>" ) +
publicSource() + QStringLiteral(
"</td></tr>\n" );
3961 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Storage" ) + QStringLiteral(
"</td><td>" ) +
storageType() + QStringLiteral(
"</td></tr>\n" );
3964 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Comment" ) + QStringLiteral(
"</td><td>" ) +
dataComment() + QStringLiteral(
"</td></tr>\n" );
3967 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Encoding" ) + QStringLiteral(
"</td><td>" ) +
dataProvider()->
encoding() + QStringLiteral(
"</td></tr>\n" );
3979 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Geometry" ) + QStringLiteral(
"</td><td>" ) + typeString + QStringLiteral(
"</td></tr>\n" );
3983 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"CRS" ) + QStringLiteral(
"</td><td>" );
3986 myMetadata +=
crs().
authid() + QStringLiteral(
" - " );
3988 if (
crs().isGeographic() )
3989 myMetadata += tr(
"Geographic" );
3991 myMetadata += tr(
"Projected" );
3993 myMetadata += QLatin1String(
"</td></tr>\n" );
3996 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Extent" ) + QStringLiteral(
"</td><td>" ) +
extent().
toString() + QStringLiteral(
"</td></tr>\n" );
3999 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Unit" ) + QStringLiteral(
"</td><td>" ) +
QgsUnitTypes::toString(
crs().mapUnits() ) + QStringLiteral(
"</td></tr>\n" );
4002 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Feature count" ) + QStringLiteral(
"</td><td>" ) + QString::number(
featureCount() ) + QStringLiteral(
"</td></tr>\n" );
4005 myMetadata += QLatin1String(
"</table>\n<br><br>" );
4008 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Identification" ) + QStringLiteral(
"</h1>\n<hr>\n" );
4010 myMetadata += QLatin1String(
"<br><br>\n" );
4013 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Extent" ) + QStringLiteral(
"</h1>\n<hr>\n" );
4015 myMetadata += QLatin1String(
"<br><br>\n" );
4018 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Access" ) + QStringLiteral(
"</h1>\n<hr>\n" );
4020 myMetadata += QLatin1String(
"<br><br>\n" );
4023 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Fields" ) + QStringLiteral(
"</h1>\n<hr>\n<table class=\"list-view\">\n" );
4027 if ( !pkAttrList.isEmpty() )
4029 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Primary key attributes" ) + QStringLiteral(
"</td><td>" );
4030 Q_FOREACH (
int idx, pkAttrList )
4034 myMetadata += QLatin1String(
"</td></tr>\n" );
4040 myMetadata += QStringLiteral(
"<tr><td class=\"highlight\">" ) + tr(
"Count" ) + QStringLiteral(
"</td><td>" ) + QString::number( myFields.
size() ) + QStringLiteral(
"</td></tr>\n" );
4042 myMetadata += QLatin1String(
"</table>\n<br><table width=\"100%\" class=\"tabular-view\">\n" );
4043 myMetadata +=
"<tr><th>" + tr(
"Field" ) +
"</th><th>" + tr(
"Type" ) +
"</th><th>" + tr(
"Length" ) +
"</th><th>" + tr(
"Precision" ) +
"</th><th>" + tr(
"Comment" ) +
"</th></tr>\n";
4045 for (
int i = 0; i < myFields.
size(); ++i )
4050 rowClass = QStringLiteral(
"class=\"odd-row\"" );
4051 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";
4055 myMetadata += QLatin1String(
"</table>\n<br><br>" );
4058 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Contacts" ) + QStringLiteral(
"</h1>\n<hr>\n" );
4060 myMetadata += QLatin1String(
"<br><br>\n" );
4063 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"Links" ) + QStringLiteral(
"</h1>\n<hr>\n" );
4065 myMetadata += QLatin1String(
"<br><br>\n" );
4068 myMetadata += QStringLiteral(
"<h1>" ) + tr(
"History" ) + QStringLiteral(
"</h1>\n<hr>\n" );
4070 myMetadata += QLatin1String(
"<br><br>\n" );
4072 myMetadata += QStringLiteral(
"\n</body>\n</html>\n" );
4076 void QgsVectorLayer::invalidateSymbolCountedFlag()
4078 mSymbolFeatureCounted =
false;
4081 void QgsVectorLayer::onFeatureCounterCompleted()
4084 mFeatureCounter =
nullptr;
4087 void QgsVectorLayer::onFeatureCounterTerminated()
4089 mFeatureCounter =
nullptr;
4092 void QgsVectorLayer::onJoinedFieldsChanged()
4098 void QgsVectorLayer::onFeatureDeleted(
QgsFeatureId fid )
4100 if ( mEditCommandActive )
4101 mDeletedFids << fid;
4108 void QgsVectorLayer::onRelationsLoaded()
4110 mEditFormConfig.onRelationsLoaded();
4113 void QgsVectorLayer::onSymbolsCounted()
4115 if ( mFeatureCounter )
4118 mSymbolFeatureCounted =
true;
4133 msgError = QObject::tr(
"Unable to load %1 provider" ).arg( mProviderKey );
4138 if ( !listStylesExternalMethod )
4140 msgError = QObject::tr(
"Provider %1 has no %2 method" ).arg( mProviderKey, QStringLiteral(
"listStyles" ) );
4144 return listStylesExternalMethod(
mDataSource, ids, names, descriptions, msgError );
4152 msgError = QObject::tr(
"Unable to load %1 provider" ).arg( mProviderKey );
4157 if ( !getStyleByIdMethod )
4159 msgError = QObject::tr(
"Provider %1 has no %2 method" ).arg( mProviderKey, QStringLiteral(
"getStyleById" ) );
4163 return getStyleByIdMethod(
mDataSource, styleId, msgError );
4171 msgError = QObject::tr(
"Unable to load %1 provider" ).arg( mProviderKey );
4175 if ( !deleteStyleByIdMethod )
4177 msgError = QObject::tr(
"Provider %1 has no %2 method" ).arg( mProviderKey, QStringLiteral(
"deleteStyleById" ) );
4180 return deleteStyleByIdMethod(
mDataSource, styleId, msgError );
4185 bool useAsDefault,
const QString &uiFileContent, QString &msgError )
4188 QString sldStyle, qmlStyle;
4192 msgError = QObject::tr(
"Unable to load %1 provider" ).arg( mProviderKey );
4197 if ( !saveStyleExternalMethod )
4199 msgError = QObject::tr(
"Provider %1 has no %2 method" ).arg( mProviderKey, QStringLiteral(
"saveStyle" ) );
4203 QDomDocument qmlDocument, sldDocument;
4205 if ( !msgError.isNull() )
4209 qmlStyle = qmlDocument.toString();
4212 if ( !msgError.isNull() )
4216 sldStyle = sldDocument.toString();
4218 saveStyleExternalMethod(
mDataSource, qmlStyle, sldStyle, name,
4219 description, uiFileContent, useAsDefault, msgError );
4233 QString joinKey = mAuxiliaryLayerKey;
4234 if ( !key.isEmpty() )
4237 if ( storage.
isValid() && !joinKey.isEmpty() )
4260 mAuxiliaryLayerKey.clear();
4262 if ( mAuxiliaryLayer )
4275 mAuxiliaryLayer.reset( alayer );
4276 mAuxiliaryLayer->setParent(
this );
4282 return mAuxiliaryLayer.get();
4287 return mAuxiliaryLayer.get();
4299 if ( loadStyleExternalMethod )
4301 QString qml, errorMsg;
4302 qml = loadStyleExternalMethod(
mDataSource, errorMsg );
4303 if ( !qml.isEmpty() )
4305 QDomDocument myDocument( QStringLiteral(
"qgis" ) );
4306 myDocument.setContent( qml );
4308 return QObject::tr(
"Loaded from Provider" );
4319 if ( mDataProvider )
4326 QSet<QgsMapLayerDependency> deps;
4335 QSet<QgsMapLayerDependency> toAdd = deps -
dependencies();
4351 if ( mDataProvider )
4371 if ( ! toAdd.isEmpty() )
4379 if ( fieldIndex < 0 || fieldIndex >= mFields.
count() )
4395 QMap< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrength > m;
4397 if ( fieldIndex < 0 || fieldIndex >= mFields.
count() )
4400 QString
name = mFields.
at( fieldIndex ).
name();
4403 for ( ; conIt != mFieldConstraintStrength.constEnd(); ++conIt )
4405 if ( conIt.key().first ==
name )
4407 m[ conIt.key().second ] = mFieldConstraintStrength.value( conIt.key() );
4416 if ( index < 0 || index >= mFields.
count() )
4422 QgsFieldConstraints::Constraints constraints = mFieldConstraints.value( name,
nullptr );
4423 constraints |= constraint;
4424 mFieldConstraints.insert( name, constraints );
4426 mFieldConstraintStrength.insert( qMakePair( name, constraint ), strength );
4433 if ( index < 0 || index >= mFields.
count() )
4439 QgsFieldConstraints::Constraints constraints = mFieldConstraints.value( name,
nullptr );
4440 constraints &= ~constraint;
4441 mFieldConstraints.insert( name, constraints );
4443 mFieldConstraintStrength.remove( qMakePair( name, constraint ) );
4450 if ( index < 0 || index >= mFields.
count() )
4458 if ( index < 0 || index >= mFields.
count() )
4466 if ( index < 0 || index >= mFields.
count() )
4469 if ( expression.isEmpty() )
4471 mFieldConstraintExpressions.remove( mFields.
at( index ).
name() );
4475 mFieldConstraintExpressions.insert( mFields.
at( index ).
name(), qMakePair( expression, description ) );
4482 if ( index < 0 || index >= mFields.
count() )
4486 mFieldWidgetSetups.remove( mFields.
at( index ).
name() );
4488 mFieldWidgetSetups.insert( mFields.
at( index ).
name(), setup );
4495 if ( index < 0 || index >= mFields.
count() )
4504 if (
customProperty( QStringLiteral(
"labeling" ) ).toString() == QLatin1String(
"pal" ) )
4506 if (
customProperty( QStringLiteral(
"labeling/enabled" ), QVariant(
false ) ).toBool() ==
true )
4510 settings.readFromLayerCustomProperties(
this );
4518 if ( key.startsWith( QLatin1String(
"labeling/" ) ) )
4533 return mReadExtentFromXml;
4536 void QgsVectorLayer::onDirtyTransaction(
const QString &sql,
const QString &
name )
4539 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
Set the extent.
bool labelsEnabled() const
Returns whether the layer contains labels which are enabled and should be drawn.
Origin origin() const
Return the dependency origin.
bool isValid() const
Returns the validity of this feature.
T enumValue(const QString &key, const T &defaultValue, const Section section=NoSection, bool flag=false) const
Return the setting value for a setting based on an enum.
void writeXml(QDomNode &layer_node, QDomDocument &document) const
Saves mVectorJoins to xml under the layer node.
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()
Get 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
Get 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
Set 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.
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
Return 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
Get 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.
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.
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.
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.
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...
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
Get 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) ...
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
Get 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
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.
VertexMarkerType
Editing vertex markers.
void removeExpressionField(int index)
Remove an expression field.
void setFeatureBlendMode(QPainter::CompositionMode blendMode)
Set the blending mode used for rendering each feature.
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
Return 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.
~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 ...
bool deleteAttributes(QList< int > attrs)
Deletes a list of attribute fields (but does not commit it)
QgsDataProvider * createProvider(const QString &providerKey, const QString &dataSource)
Creates a new instance of a provider.
double yOffset
Vertical offset of label.
void setLabeling(QgsAbstractVectorLayerLabeling *labeling)
Set labeling configuration.
void readCustomSymbology(const QDomElement &element, QString &errorMessage)
Signal emitted whenever the symbology (QML-file) for this layer is being read.
QgsWkbTypes::GeometryType geometryType() const
Returns point, line or polygon.
bool deleteFeatures(const QgsFeatureIds &fids)
Deletes a set of features from the layer (but does not commit it)
virtual const QgsLayerMetadata & metadata() const
Returns a reference to the layer's metadata store.
void readXml(const QDomNode &layer_node)
Reads joins from project file.
void raiseError(const QString &msg) const
Signals an error in this provider.
void configChanged()
Emitted whenever the configuration is changed.
void setDiagramRenderer(QgsDiagramRenderer *r)
Sets diagram rendering object (takes ownership)
Container of fields for a vector layer.
virtual void rollBack()
Stop editing and discard the edits.
A geometry is the spatial representation of a feature.
Type type() const
Return 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.
#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.
QgsEditorWidgetSetup editorWidgetSetup() const
Get 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.
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
Return 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
Get 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.
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
Return 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.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning)
add a message to the instance (and create it if necessary)
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.
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.
QgsConditionalLayerStyles * conditionalStyles() const
Return 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
Get field at particular index (must be in range 0..N-1)
void setAuxiliaryLayer(QgsAuxiliaryLayer *layer=nullptr)
Sets the current auxiliary layer.
int fieldOriginIndex(int fieldIdx) const
Get 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...
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
Return new instance of QgsMapLayerRenderer that will be used for rendering of given context...
QgsFeatureRequest & setFilterFid(QgsFeatureId fid)
Set feature ID that should be fetched.
bool changeAttributeValue(QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue=QVariant())
Changes attribute value in joined layers.
void 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)
bool readSymbology(const QDomNode &layerNode, QString &errorMessage, const QgsReadWriteContext &context) override
Read the symbology for the current layer from the Dom node supplied.
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
Get 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.
void deselect(const QgsFeatureId featureId)
Deselect feature by its ID.
const QgsFeatureIds & selectedFeatureIds() const
Return reference to identifiers of selected features.
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
Get 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
Get 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 ...
void selectionChanged(const QgsFeatureIds &selected, const QgsFeatureIds &deselected, const bool clearAndSelect)
This signal is emitted when selection was changed.
static QString geometryDisplayString(GeometryType type)
Return 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)
Set 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.
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
Get 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.
virtual QDomElement save(QDomDocument &doc, const QgsReadWriteContext &context) const =0
Return 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.
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.
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.
QgsFeatureRenderer * renderer()
Return 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
Get 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.
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.
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
return 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)
Expand the rectangle so that 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
Get the attribute table configuration object.
void selectByExpression(const QString &expression, SelectBehavior behavior=SetSelection)
Select matching features using an expression.
bool readXml(const QDomNode &layer_node, const QgsReadWriteContext &context) override
Reads vector layer specific state from project file Dom node.
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.
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)
Set 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
Get 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
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.
void committedAttributeValuesChanges(const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues)
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), const Section section=NoSection) const
Returns the value for setting key.
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
Return 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
Return the ID of the layer this dependency depends on.
virtual QString subsetString() const
Get the string (typically sql) used to define a subset of the layer.
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
Get 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.
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.
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 ...
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()
Return 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
Return 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 readStyle(const QDomNode &node, QString &errorMessage, const QgsReadWriteContext &context) override
Read the style for the current layer from the Dom node supplied.
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)
return 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)
Get the 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.
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
Get 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.
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.
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 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)
Set 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.