19 #ifndef QGSVECTORLAYER_H 20 #define QGSVECTORLAYER_H 22 #include "qgis_core.h" 26 #include <QStringList> 58 class QgsGeometryVertexIndex;
357 Q_PROPERTY( QString subsetString READ subsetString WRITE setSubsetString NOTIFY subsetStringChanged )
358 Q_PROPERTY( QString displayExpression READ displayExpression WRITE setDisplayExpression NOTIFY displayExpressionChanged )
359 Q_PROPERTY( QString mapTipTemplate READ mapTipTemplate WRITE setMapTipTemplate NOTIFY mapTipTemplateChanged )
360 Q_PROPERTY(
QgsEditFormConfig editFormConfig READ editFormConfig WRITE setEditFormConfig NOTIFY editFormConfigChanged )
361 Q_PROPERTY(
bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged )
362 Q_PROPERTY(
double opacity READ opacity WRITE setOpacity NOTIFY opacityChanged )
372 FetchFeatureFailed = 3,
395 explicit LayerOptions(
bool loadDefaultStyle =
true,
bool readExtentFromXml =
false )
396 : loadDefaultStyle( loadDefaultStyle )
397 , readExtentFromXml( readExtentFromXml )
401 bool loadDefaultStyle =
true;
407 bool readExtentFromXml =
false;
424 explicit QgsVectorLayer(
const QString &path = QString(),
const QString &baseName = QString(),
449 QString storageType() const;
454 QString capabilitiesString() const;
459 QString dataComment() const;
468 QString displayField() const;
477 void setDisplayExpression( const QString &displayExpression );
485 QString displayExpression() const;
491 void setProviderEncoding( const QString &encoding );
494 void setCoordinateSystem();
505 bool removeJoin( const QString &joinLayerId );
512 const QList<QgsVectorLayerJoinInfo> vectorJoins()
const;
522 bool setDependencies(
const QSet<QgsMapLayerDependency> &layers )
override;
531 QSet<QgsMapLayerDependency> dependencies()
const override;
543 int addExpressionField(
const QString &exp,
const QgsField &fld );
552 void removeExpressionField(
int index );
563 QString expressionField(
int index )
const;
574 void updateExpressionField(
int index,
const QString &exp );
596 int selectedFeatureCount()
const;
618 void selectByExpression(
const QString &expression,
SelectBehavior behavior = SetSelection );
646 void invertSelection();
709 bool labelsEnabled()
const;
720 void setLabelsEnabled(
bool enabled );
727 bool diagramsEnabled()
const;
758 QString providerType()
const;
761 QString sourceName()
const override;
773 bool writeXml( QDomNode &layer_node, QDomDocument &doc,
const QgsReadWriteContext &context )
const override;
775 QString encodedSource(
const QString &source,
const QgsReadWriteContext &context )
const override;
776 QString decodedSource(
const QString &source,
const QString &provider,
const QgsReadWriteContext &context )
const override;
782 void resolveReferences(
QgsProject *project )
override;
792 virtual void saveStyleToDatabase(
const QString &name,
const QString &description,
793 bool useAsDefault,
const QString &uiFileContent,
805 virtual int listStylesInDatabase( QStringList &ids SIP_OUT, QStringList &names SIP_OUT,
806 QStringList &descriptions SIP_OUT, QString &msgError SIP_OUT );
811 virtual QString getStyleFromDatabase(
const QString &styleId, QString &msgError SIP_OUT );
820 virtual bool deleteStyleFromDatabase(
const QString &styleId, QString &msgError SIP_OUT );
828 virtual QString loadNamedStyle(
const QString &theURI,
bool &resultFlag SIP_OUT,
bool loadFromLocalDb );
834 QString loadNamedStyle(
const QString &theURI,
bool &resultFlag SIP_OUT )
override;
849 bool loadAuxiliaryLayer(
const QgsAuxiliaryStorage &storage,
const QString &key = QString() );
883 bool readSymbology(
const QDomNode &layerNode, QString &errorMessage,
QgsReadWriteContext &context )
override;
892 bool readStyle(
const QDomNode &node, QString &errorMessage,
QgsReadWriteContext &context )
override;
902 bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
const QgsReadWriteContext &context )
const override;
912 bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
const QgsReadWriteContext &context )
const override;
922 bool writeSld( QDomNode &node, QDomDocument &doc, QString &errorMessage,
const QgsStringMap &props =
QgsStringMap() )
const;
924 bool readSld(
const QDomNode &node, QString &errorMessage )
override;
931 long featureCount(
const QString &legendKey )
const;
944 Q_DECL_DEPRECATED
void setDataSource(
const QString &dataSource,
const QString &baseName,
const QString &provider,
bool loadDefaultStyleFlag =
false )
SIP_DEPRECATED;
957 void setDataSource(
const QString &dataSource,
const QString &baseName,
const QString &provider,
const QgsDataProvider::ProviderOptions &options,
bool loadDefaultStyleFlag =
false );
959 QString loadDefaultStyle(
bool &resultFlag SIP_OUT )
override;
982 virtual bool setSubsetString(
const QString &subset );
988 virtual QString subsetString()
const;
1032 bool addFeature(
QgsFeature &feature, QgsFeatureSink::Flags flags =
nullptr )
override;
1059 bool updateFeature(
const QgsFeature &feature,
bool skipDefaultValues =
false );
1071 bool insertVertex(
double x,
double y,
QgsFeatureId atFeatureId,
int beforeVertex );
1095 bool moveVertex(
double x,
double y,
QgsFeatureId atFeatureId,
int atVertex );
1125 bool deleteSelectedFeatures(
int *deletedCount =
nullptr );
1225 int translateFeature(
QgsFeatureId featureId,
double dx,
double dy );
1275 int addTopologicalPoints(
const QgsGeometry &geom );
1289 int addTopologicalPoints(
const QgsPointXY &p );
1314 bool isEditable()
const override;
1317 bool isSpatial()
const override;
1320 virtual bool isModified()
const;
1328 bool isAuxiliaryField(
int index,
int &srcIndex )
const;
1331 void reload()
override;
1364 long featureCount()
const override;
1370 bool setReadOnly(
bool readonly =
true );
1424 bool changeAttributeValue(
QgsFeatureId fid,
int field,
const QVariant &newValue,
const QVariant &oldValue = QVariant(),
bool skipDefaultValues =
false );
1472 bool addAttribute(
const QgsField &field );
1479 void setFieldAlias(
int index,
const QString &aliasString );
1486 void removeFieldAlias(
int index );
1498 bool renameAttribute(
int index,
const QString &newName );
1506 QString attributeAlias(
int index )
const;
1509 QString attributeDisplayName(
int index )
const;
1542 virtual bool deleteAttribute(
int attr );
1551 bool deleteAttributes(
const QList<int> &attrs );
1553 bool addFeatures(
QgsFeatureList &features, QgsFeatureSink::Flags flags =
nullptr )
override;
1599 bool commitChanges();
1606 QStringList commitErrors()
const;
1617 bool rollBack(
bool deleteBuffer =
true );
1625 QList<QgsRelation> referencingRelations(
int idx )
const;
1640 void beginEditCommand(
const QString &text );
1643 void endEditCommand();
1646 void destroyEditCommand();
1667 void updateFields();
1697 void setDefaultValueDefinition(
int index,
const QgsDefaultValue &definition );
1718 QgsFieldConstraints::Constraints fieldConstraints(
int fieldIndex )
const;
1725 QMap< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrength> fieldConstraintsAndStrength(
int fieldIndex )
const;
1753 QString constraintExpression(
int index )
const;
1762 QString constraintDescription(
int index )
const;
1772 void setConstraintExpression(
int index,
const QString &expression,
const QString &description = QString() );
1798 QSet<QVariant> uniqueValues(
int fieldIndex,
int limit = -1 )
const override;
1813 QStringList uniqueStringsMatching(
int index,
const QString &substring,
int limit = -1,
1824 QVariant minimumValue(
int index )
const override;
1834 QVariant maximumValue(
int index )
const override;
1847 const QString &fieldOrExpression,
1850 bool *ok =
nullptr )
const;
1853 void setFeatureBlendMode( QPainter::CompositionMode blendMode );
1855 QPainter::CompositionMode featureBlendMode()
const;
1864 void setOpacity(
double opacity );
1873 double opacity()
const;
1875 QString htmlMetadata()
const override;
1924 QString mapTipTemplate()
const;
1933 void setMapTipTemplate(
const QString &mapTipTemplate );
1964 void setReadExtentFromXml(
bool readExtentFromXml );
1973 bool readExtentFromXml()
const;
2025 void removeSelection();
2033 virtual void updateExtents(
bool force =
false );
2049 bool startEditing();
2063 void layerModified();
2066 void beforeModifiedCheck()
const;
2069 void beforeEditingStarted();
2072 void editingStarted();
2075 void editingStopped();
2078 void beforeCommitChanges();
2081 void beforeRollBack();
2091 void attributeAdded(
int idx );
2099 void beforeAddingExpressionField(
const QString &fieldName );
2109 void attributeDeleted(
int idx );
2117 void beforeRemovingExpressionField(
int idx );
2151 void updatedFields();
2157 void subsetStringChanged();
2167 void attributeValueChanged(
QgsFeatureId fid,
int idx,
const QVariant &value );
2179 void committedAttributesDeleted(
const QString &layerId,
const QgsAttributeList &deletedAttributes );
2181 void committedAttributesAdded(
const QString &layerId,
const QList<QgsField> &addedAttributes );
2183 void committedFeaturesAdded(
const QString &layerId,
const QgsFeatureList &addedFeatures );
2185 void committedFeaturesRemoved(
const QString &layerId,
const QgsFeatureIds &deletedFeatureIds );
2187 void committedAttributeValuesChanges(
const QString &layerId,
const QgsChangedAttributesMap &changedAttributesValues );
2189 void committedGeometriesChanges(
const QString &layerId,
const QgsGeometryMap &changedGeometries );
2192 void labelingFontNotFound(
QgsVectorLayer *layer,
const QString &fontfamily );
2195 void featureBlendModeChanged( QPainter::CompositionMode blendMode );
2204 void opacityChanged(
double opacity );
2211 void editCommandStarted(
const QString &text );
2218 void editCommandEnded();
2225 void editCommandDestroyed();
2236 void readCustomSymbology(
const QDomElement &element, QString &errorMessage );
2247 void writeCustomSymbology( QDomElement &element, QDomDocument &doc, QString &errorMessage )
const;
2254 void mapTipTemplateChanged();
2261 void displayExpressionChanged();
2266 void raiseError(
const QString &msg );
2273 void editFormConfigChanged();
2281 void readOnlyChanged();
2288 void symbolFeatureCountMapChanged();
2291 void invalidateSymbolCountedFlag();
2292 void onFeatureCounterCompleted();
2293 void onFeatureCounterTerminated();
2294 void onJoinedFieldsChanged();
2296 void onRelationsLoaded();
2297 void onSymbolsCounted();
2298 void onDirtyTransaction(
const QString &sql,
const QString &name );
2311 bool isReadOnly()
const override;
2321 void readSldLabeling(
const QDomNode &node );
2337 QString mDisplayExpression;
2339 QString mMapTipTemplate;
2342 QString mProviderKey;
2348 bool mReadOnly =
false;
2364 QMap<QString, QgsDefaultValue> mDefaultExpressionMap;
2367 QSet<int> mDefaultValueOnUpdateFields;
2370 QMap< QString, QgsFieldConstraints::Constraints > mFieldConstraints;
2376 QMap< QString, QPair< QString, QString > > mFieldConstraintExpressions;
2378 QMap< QString, QgsEditorWidgetSetup > mFieldWidgetSetups;
2384 QSet<QString> mExcludeAttributesWMS;
2387 QSet<QString> mExcludeAttributesWFS;
2402 bool mLabelsEnabled =
false;
2405 bool mLabelFontNotFoundNotified =
false;
2408 QPainter::CompositionMode mFeatureBlendMode = QPainter::CompositionMode_SourceOver;
2411 double mLayerOpacity = 1.0;
2414 bool mVertexMarkerOnlyForSelection =
false;
2416 QStringList mCommitErrors;
2435 mutable bool mValidExtent =
false;
2436 mutable bool mLazyExtent =
true;
2439 std::unique_ptr<QgsAuxiliaryLayer> mAuxiliaryLayer;
2442 QString mAuxiliaryLayerKey;
2445 bool mSymbolFeatureCounted =
false;
2448 QHash<QString, long> mSymbolFeatureCountMap;
2451 bool mEditCommandActive =
false;
2453 bool mReadExtentFromXml;
2460 mutable QMutex mFeatureSourceConstructorMutex;
QgsActionManager * actions()
Returns all layer actions defined on this layer.
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.
QMap< QgsFeatureId, QgsGeometry > QgsGeometryMap
A rectangle specified with double values.
Base class for all map layer types.
void setExcludeAttributesWms(const QSet< QString > &att)
A set of attributes that are not advertised in WMS requests with QGIS server.
QSet< QString > excludeAttributesWms() const
A set of attributes that are not advertised in WMS requests with QGIS server.
The QgsDefaultValue class provides a container for managing client side default values for fields...
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.
Setting options for loading vector layers.
QSet< QgsFeatureId > QgsFeatureIds
Class allowing to manage the auxiliary storage for a vector layer.
QList< QgsFeature > QgsFeatureList
Counts the features in a QgsVectorLayer in task.
LayerOptions(bool loadDefaultStyle=true, bool readExtentFromXml=false)
Constructor for LayerOptions.
A class to represent a 2D point.
QgsFeature getFeature(QgsFeatureId fid) const
Query the layer for the feature with the given id.
VertexMarkerType
Editing vertex markers.
An interface for objects which accept features via addFeature(s) methods.
QgsAbstractVectorLayerLabeling * labeling()
Access to labeling configuration.
Remove from current selection.
SimplifyHint
Simplification flags for fast rendering of features.
Class providing some utility methods to manage auxiliary storage.
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
bool isEditCommandActive() const
Test if an edit command is active.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QMap< QString, QString > QgsStringMap
OperationResult
Success or failure of a geometry operation.
Manages joined fields for a vector layer.
Base class for feedback objects to be used for cancelation of something running in a worker thread...
Perform transforms between map coordinates and device coordinates.
void setExcludeAttributesWfs(const QSet< QString > &att)
A set of attributes that are not advertised in WFS requests with QGIS server.
QgsVectorLayerEditBuffer * editBuffer()
Buffer with uncommitted editing operations. Only valid after editing has been turned on...
Type
The WKB type describes the number of dimensions a geometry has.
QgsFields fields() const override
Returns the list of fields of this layer.
Evaluates and returns the diagram settings relating to a diagram for a specific feature.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QgsFeatureIterator getFeatures(const QString &expression)
Query the layer for features matching a given expression.
Defines left outer join from our vector layer to some other vector layer.
QMap< int, QVariant > QgsAttributeMap
This class wraps a request for features to a vector layer (or directly its vector data provider)...
Reads and writes project states.
Storage and management of actions associated with a layer.
QgsAttributeList attributeList() const
Returns list of attribute indexes.
QgsFeatureRenderer * renderer()
Returns renderer.
Abstract base class for curved geometry type.
Encapsulate a field in an attribute table or data source.
const QgsAbstractVectorLayerLabeling * labeling() const
Access to const labeling configuration.
Single scope for storing variables and functions for use within a QgsExpressionContext.
Add selection to current selection.
Point geometry type, with support for z-dimension and m-values.
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings for fast rendering of features.
const QgsDiagramRenderer * diagramRenderer() const
Abstract interface for generating an expression context.
Partial snapshot of vector layer's state (only the members necessary for access to features) ...
Set selection, removing any existing selection.
QgsFeatureIterator getFeatures(const QgsRectangle &rectangle)
Query the layer for the features which intersect the specified rectangle.
Stores the settings for rendering of all diagrams for a layer.
QVector< QgsPoint > QgsPointSequence
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Modify current selection to include only select features which match.
SelectBehavior
Selection behavior.
This class contains information how to simplify geometries fetched from a vector layer.
Contains information about the context of a rendering operation.
Setting options for creating vector data providers.
Buffers information about expression fields for a vector layer.
QMap< QgsFeatureId, QgsAttributeMap > QgsChangedAttributesMap
Abstract interface for generating an expression context scope.
An interface for objects which provide features via a getFeatures method.
const QgsDiagramLayerSettings * diagramLayerSettings() const
ConstraintStrength
Strength of constraints.
This class manages a set of relations between layers.
The QgsConditionalLayerStyles class holds conditional style information for a layer.
This class represents a coordinate reference system (CRS).
Abstract base class - its implementations define different approaches to the labeling of a vector lay...
void setSimplifyMethod(const QgsVectorSimplifyMethod &simplifyMethod)
Set the simplification settings for fast rendering of features.
Base class for utility classes that encapsulate information necessary for rendering of map layers...
const QgsFeatureRenderer * renderer() const
Returns const renderer.
QSet< int > QgsAttributeIds
QList< int > QgsAttributeList
bool nextFeature(QgsFeature &f)
This is a container for configuration of the attribute table.
This is the base class for vector data providers.
QList< int > QgsAttributeList
const QgsActionManager * actions() const
Returns all layer actions defined on this layer.
Represents a vector layer which manages a vector based data sets.
const QgsVectorLayerEditBuffer * editBuffer() const
Buffer with uncommitted editing operations.
EditResult
Result of an edit operation.
QgsFeatureIterator getFeatures(const QgsFeatureIds &fids)
Query the layer for the features with the given ids.
Constraint must be honored before feature can be accepted.
Abstract base class for simplify geometries using a specific algorithm.
Aggregate
Available aggregates to calculate.
A bundle of parameters controlling aggregate calculation.