18 #ifndef QGSVECTORLAYER_H 19 #define QGSVECTORLAYER_H 22 #include "qgis_core.h" 26 #include <QStringList> 39 #include "qgseditformconfig.h" 60 class QgsGeometryVertexIndex;
391 Q_PROPERTY( QString subsetString READ subsetString WRITE setSubsetString NOTIFY subsetStringChanged )
392 Q_PROPERTY( QString displayExpression READ displayExpression WRITE setDisplayExpression NOTIFY displayExpressionChanged )
393 Q_PROPERTY( QString mapTipTemplate READ mapTipTemplate WRITE setMapTipTemplate NOTIFY mapTipTemplateChanged )
394 Q_PROPERTY( QgsEditFormConfig editFormConfig READ editFormConfig WRITE setEditFormConfig NOTIFY editFormConfigChanged )
395 Q_PROPERTY(
bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged )
396 Q_PROPERTY(
bool supportsEditing READ supportsEditing NOTIFY supportsEditingChanged )
406 FetchFeatureFailed = 3,
432 bool readExtentFromXml =
false )
433 : loadDefaultStyle( loadDefaultStyle )
434 , readExtentFromXml( readExtentFromXml )
442 bool loadDefaultStyle =
true,
443 bool readExtentFromXml =
false 445 : loadDefaultStyle( loadDefaultStyle )
446 , readExtentFromXml( readExtentFromXml )
447 , transformContext( transformContext )
451 bool loadDefaultStyle =
true;
457 bool readExtentFromXml =
false;
504 bool skipCrsValidation =
false;
526 QList<QgsVectorLayer *> handledLayers(
bool includeAuxiliaryLayers =
true )
const;
533 QMap<QgsVectorLayer *, QgsFeatureIds> mHandledFeatures
SIP_SKIP;
551 explicit QgsVectorLayer(
const QString &path = QString(),
const QString &baseName = QString(),
562 SIP_PYOBJECT __repr__();
564 QString str = QStringLiteral(
"<QgsVectorLayer: '%1' (%2)>" ).arg( sipCpp->name(), sipCpp->dataProvider() ? sipCpp->dataProvider()->name() : QStringLiteral(
"Invalid" ) );
565 sipRes = PyUnicode_FromString( str.toUtf8().constData() );
583 QString storageType() const;
588 QString capabilitiesString() const;
593 QString dataComment() const;
602 QString displayField() const;
611 void setDisplayExpression( const QString &displayExpression );
619 QString displayExpression() const;
639 void setProviderEncoding( const QString &encoding );
642 void setCoordinateSystem();
655 bool removeJoin( const QString &joinLayerId );
669 const QList<QgsVectorLayerJoinInfo> vectorJoins()
const;
679 bool setDependencies(
const QSet<QgsMapLayerDependency> &layers )
FINAL;
688 QSet<QgsMapLayerDependency> dependencies()
const FINAL;
700 int addExpressionField(
const QString &exp,
const QgsField &fld );
709 void removeExpressionField(
int index );
720 QString expressionField(
int index )
const;
731 void updateExpressionField(
int index,
const QString &exp );
759 int selectedFeatureCount()
const;
809 Q_INVOKABLE
void invertSelection();
812 Q_INVOKABLE
void selectAll();
821 Q_INVOKABLE
void invertSelectionInRectangle(
QgsRectangle &rect );
873 bool labelsEnabled()
const;
884 void setLabelsEnabled(
bool enabled );
891 bool diagramsEnabled()
const;
945 void removeFeatureRendererGenerator(
const QString &
id );
954 QList< const QgsFeatureRendererGenerator * > featureRendererGenerators()
const;
963 QString sourceName()
const FINAL;
978 QString decodedSource(
const QString &source,
const QString &provider,
const QgsReadWriteContext &context )
const FINAL;
994 virtual void saveStyleToDatabase(
const QString &name,
const QString &description,
995 bool useAsDefault,
const QString &uiFileContent,
1007 virtual int listStylesInDatabase( QStringList &ids SIP_OUT, QStringList &names SIP_OUT,
1008 QStringList &descriptions SIP_OUT, QString &msgError SIP_OUT );
1013 virtual QString getStyleFromDatabase(
const QString &styleId, QString &msgError SIP_OUT );
1022 virtual bool deleteStyleFromDatabase(
const QString &styleId, QString &msgError SIP_OUT );
1031 virtual QString loadNamedStyle(
const QString &theURI,
bool &resultFlag SIP_OUT,
bool loadFromLocalDb,
1038 QString loadNamedStyle(
const QString &theURI,
bool &resultFlag SIP_OUT,
1054 bool loadAuxiliaryLayer(
const QgsAuxiliaryStorage &storage,
const QString &key = QString() );
1081 bool readSymbology(
const QDomNode &layerNode, QString &errorMessage,
1083 bool readStyle(
const QDomNode &node, QString &errorMessage,
1085 bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
1087 bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
1098 bool writeSld( QDomNode &node, QDomDocument &doc, QString &errorMessage,
const QVariantMap &props = QVariantMap() )
const;
1100 bool readSld(
const QDomNode &node, QString &errorMessage )
FINAL;
1107 long featureCount(
const QString &legendKey )
const;
1115 QgsFeatureIds symbolFeatureIds(
const QString &legendKey )
const;
1140 Q_DECL_DEPRECATED
void setDataSource(
const QString &dataSource,
const QString &baseName,
const QString &provider,
bool loadDefaultStyleFlag =
false )
SIP_DEPRECATED;
1154 void setDataSource(
const QString &dataSource,
const QString &baseName,
const QString &provider,
const QgsDataProvider::ProviderOptions &options,
bool loadDefaultStyleFlag =
false )
override;
1156 QString loadDefaultStyle(
bool &resultFlag SIP_OUT )
FINAL;
1180 virtual bool setSubsetString(
const QString &subset );
1186 virtual QString subsetString()
const;
1236 bool addFeature(
QgsFeature &feature, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() )
FINAL;
1263 bool updateFeature(
QgsFeature &feature,
bool skipDefaultValues =
false );
1276 bool insertVertex(
double x,
double y,
QgsFeatureId atFeatureId,
int beforeVertex );
1301 bool moveVertex(
double x,
double y,
QgsFeatureId atFeatureId,
int atVertex );
1334 Q_INVOKABLE
bool deleteSelectedFeatures(
int *deletedCount =
nullptr,
DeleteContext *context =
nullptr );
1486 Q_INVOKABLE
int translateFeature(
QgsFeatureId featureId,
double dx,
double dy );
1608 int addTopologicalPoints(
const QgsGeometry &geom );
1638 int addTopologicalPoints(
const QgsPoint &p );
1678 bool isEditable()
const FINAL;
1681 bool isSpatial()
const FINAL;
1684 virtual bool isModified()
const;
1692 bool isAuxiliaryField(
int index,
int &srcIndex )
const;
1695 void reload()
FINAL;
1729 long featureCount()
const FINAL;
1735 bool setReadOnly(
bool readonly =
true );
1742 bool supportsEditing();
1796 bool changeAttributeValue(
QgsFeatureId fid,
int field,
const QVariant &newValue,
const QVariant &oldValue = QVariant(),
bool skipDefaultValues =
false );
1844 bool addAttribute(
const QgsField &field );
1851 void setFieldAlias(
int index,
const QString &aliasString );
1858 void removeFieldAlias(
int index );
1870 bool renameAttribute(
int index,
const QString &newName );
1878 QString attributeAlias(
int index )
const;
1881 QString attributeDisplayName(
int index )
const;
1890 Q_DECL_DEPRECATED QSet<QString> excludeAttributesWms()
const SIP_DEPRECATED;
1896 Q_DECL_DEPRECATED
void setExcludeAttributesWms(
const QSet<QString> &att )
SIP_DEPRECATED;
1902 Q_DECL_DEPRECATED QSet<QString> excludeAttributesWfs()
const SIP_DEPRECATED;
1908 Q_DECL_DEPRECATED
void setExcludeAttributesWfs(
const QSet<QString> &att )
SIP_DEPRECATED;
1918 virtual bool deleteAttribute(
int attr );
1927 bool deleteAttributes(
const QList<int> &attrs );
1929 bool addFeatures(
QgsFeatureList &features, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() )
FINAL;
1981 Q_INVOKABLE
bool commitChanges(
bool stopEditing =
true );
1988 QStringList commitErrors()
const;
1999 Q_INVOKABLE
bool rollBack(
bool deleteBuffer =
true );
2007 QList<QgsRelation> referencingRelations(
int idx )
const;
2015 QList<QgsWeakRelation> weakRelations( )
const SIP_SKIP;
2031 void beginEditCommand(
const QString &text );
2034 void endEditCommand();
2037 void destroyEditCommand();
2061 void updateFields();
2091 void setDefaultValueDefinition(
int index,
const QgsDefaultValue &definition );
2112 QgsFieldConstraints::Constraints fieldConstraints(
int fieldIndex )
const;
2119 QMap< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrength> fieldConstraintsAndStrength(
int fieldIndex )
const;
2147 QString constraintExpression(
int index )
const;
2156 QString constraintDescription(
int index )
const;
2166 void setConstraintExpression(
int index,
const QString &expression,
const QString &description = QString() );
2173 void setFieldConfigurationFlags(
int index, QgsField::ConfigurationFlags flags )
SIP_SKIP;
2186 QgsField::ConfigurationFlags fieldConfigurationFlags(
int index )
const SIP_SKIP;
2212 QSet<QVariant> uniqueValues(
int fieldIndex,
int limit = -1 ) const FINAL;
2227 QStringList uniqueStringsMatching(
int index, const QString &substring,
int limit = -1,
2238 QVariant minimumValue(
int index ) const FINAL;
2248 QVariant maximumValue(
int index ) const FINAL;
2263 const QString &fieldOrExpression,
2270 void setFeatureBlendMode( QPainter::CompositionMode blendMode );
2272 QPainter::CompositionMode featureBlendMode() const;
2274 QString htmlMetadata() const FINAL;
2323 QString mapTipTemplate()
const;
2332 void setMapTipTemplate(
const QString &mapTipTemplate );
2345 QgsEditFormConfig editFormConfig()
const;
2353 void setEditFormConfig(
const QgsEditFormConfig &editFormConfig );
2362 void setReadExtentFromXml(
bool readExtentFromXml );
2371 bool readExtentFromXml()
const;
2423 void setAllowCommit(
bool allowCommit )
SIP_SKIP;
2468 Q_INVOKABLE
void deselect(
const QgsFeatureIds &featureIds );
2476 Q_INVOKABLE
void removeSelection();
2496 virtual void updateExtents(
bool force =
false );
2512 Q_INVOKABLE
bool startEditing();
2537 void layerModified();
2544 void allowCommitChanged();
2547 void beforeModifiedCheck()
const;
2550 void beforeEditingStarted();
2553 void editingStarted();
2556 void editingStopped();
2563 void beforeCommitChanges(
bool stopEditing );
2566 void beforeRollBack();
2572 void afterCommitChanges();
2578 void afterRollBack();
2588 void attributeAdded(
int idx );
2596 void beforeAddingExpressionField(
const QString &fieldName );
2606 void attributeDeleted(
int idx );
2614 void beforeRemovingExpressionField(
int idx );
2648 void updatedFields();
2654 void subsetStringChanged();
2664 void attributeValueChanged(
QgsFeatureId fid,
int idx,
const QVariant &value );
2676 void committedAttributesDeleted(
const QString &layerId,
const QgsAttributeList &deletedAttributes );
2678 void committedAttributesAdded(
const QString &layerId,
const QList<QgsField> &addedAttributes );
2680 void committedFeaturesAdded(
const QString &layerId,
const QgsFeatureList &addedFeatures );
2682 void committedFeaturesRemoved(
const QString &layerId,
const QgsFeatureIds &deletedFeatureIds );
2684 void committedAttributeValuesChanges(
const QString &layerId,
const QgsChangedAttributesMap &changedAttributesValues );
2686 void committedGeometriesChanges(
const QString &layerId,
const QgsGeometryMap &changedGeometries );
2689 void labelingFontNotFound(
QgsVectorLayer *layer,
const QString &fontfamily );
2692 void featureBlendModeChanged( QPainter::CompositionMode blendMode );
2699 void editCommandStarted(
const QString &text );
2706 void editCommandEnded();
2713 void editCommandDestroyed();
2724 void readCustomSymbology(
const QDomElement &element, QString &errorMessage );
2735 void writeCustomSymbology( QDomElement &element, QDomDocument &doc, QString &errorMessage )
const;
2742 void mapTipTemplateChanged();
2749 void displayExpressionChanged();
2754 void raiseError(
const QString &msg );
2761 void editFormConfigChanged();
2769 void readOnlyChanged();
2776 void supportsEditingChanged();
2783 void symbolFeatureCountMapChanged();
2790 void invalidateSymbolCountedFlag();
2791 void onFeatureCounterCompleted();
2792 void onFeatureCounterTerminated();
2793 void onJoinedFieldsChanged();
2795 void onRelationsLoaded();
2796 void onSymbolsCounted();
2797 void onDirtyTransaction(
const QString &sql,
const QString &name );
2798 void emitDataChanged();
2799 void onAfterCommitChangesDependency();
2807 bool isReadOnly()
const FINAL;
2815 bool setDataProvider( QString
const &provider,
const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags() );
2818 void readSldLabeling(
const QDomNode &node );
2831 QVariant minimumOrMaximumValue(
int index,
bool minimum )
const;
2844 QString mDisplayExpression;
2846 QString mMapTipTemplate;
2852 bool mReadOnly =
false;
2873 QMap<QString, QgsDefaultValue> mDefaultExpressionMap;
2876 QSet<int> mDefaultValueOnUpdateFields;
2879 QMap< QString, QgsFieldConstraints::Constraints > mFieldConstraints;
2885 QMap< QString, QPair< QString, QString > > mFieldConstraintExpressions;
2887 QMap< QString, QgsField::ConfigurationFlags > mFieldConfigurationFlags;
2888 QMap< QString, QgsEditorWidgetSetup > mFieldWidgetSetups;
2891 QgsEditFormConfig mEditFormConfig;
2906 bool mLabelsEnabled =
false;
2909 bool mLabelFontNotFoundNotified =
false;
2912 QPainter::CompositionMode mFeatureBlendMode = QPainter::CompositionMode_SourceOver;
2915 bool mVertexMarkerOnlyForSelection =
false;
2917 QStringList mCommitErrors;
2928 std::unique_ptr< QgsVectorLayerServerProperties > mServerProperties;
2939 mutable bool mValidExtent =
false;
2940 mutable bool mLazyExtent =
true;
2943 std::unique_ptr<QgsAuxiliaryLayer> mAuxiliaryLayer;
2946 QString mAuxiliaryLayerKey;
2949 bool mSymbolFeatureCounted =
false;
2952 QHash<QString, long> mSymbolFeatureCountMap;
2953 QHash<QString, QgsFeatureIds> mSymbolFeatureIdMap;
2956 bool mEditCommandActive =
false;
2958 bool mReadExtentFromXml;
2965 mutable QMutex mFeatureSourceConstructorMutex;
2969 std::unique_ptr<QgsGeometryOptions> mGeometryOptions;
2971 bool mAllowCommit =
true;
2979 bool mDataChangedFired =
false;
2981 QList<QgsWeakRelation> mWeakRelations;
2983 bool mSetLegendFromStyle =
false;
2985 QList< QgsFeatureRendererGenerator * > mRendererGenerators;
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
DeleteContext(bool cascade=false, QgsProject *project=nullptr)
Constructor for DeleteContext.
A rectangle specified with double values.
Base class for all map layer types.
QSet< QgsFeatureId > QgsFeatureIds
Implementation of map layer temporal properties for vector layers.
The QgsGeometryOptions class contains options to automatically adjust geometries to constraints on a ...
Abstract base class for all rendered symbols.
FeatureAvailability
Possible return value for hasFeatures() to determine if a source is empty.
The QgsDefaultValue class provides a container for managing client side default values for fields...
Constraint
Constraints which may be present on a field.
Setting options for loading vector layers.
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
Queries the layer for the feature with the given id.
QgsStoredExpressionManager * storedExpressionManager()
Returns the manager of the stored expressions for this layer.
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.
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features ...
SimplifyHint
Simplification flags for fast rendering of features.
Class providing some utility methods to manage auxiliary storage.
Utility class for calculating aggregates for a field (or expression) over the features from a vector ...
Container of fields for a vector layer.
An interface for objects which generate feature renderers for vector layers.
A geometry is the spatial representation of a feature.
The QgsWeakRelation class represent a QgsRelation with possibly unresolved layers or unmatched fields...
bool isEditCommandActive() const
Tests if an edit command is active.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
An interface for classes which can visit style entity (e.g.
QMap< QString, QString > QgsStringMap
OperationResult
Success or failure of a geometry operation.
Manages joined fields for a vector layer.
ConfigurationFlag
Configuration flags for fields These flags are meant to be user-configurable and are not describing a...
Base class for feedback objects to be used for cancellation of something running in a worker thread...
const QgsVectorLayerJoinBuffer * joinBuffer() const
Returns a const pointer on join buffer object.
Perform transforms between map coordinates and device coordinates.
Q_INVOKABLE QgsVectorLayerEditBuffer * editBuffer()
Buffer with uncommitted editing operations. Only valid after editing has been turned on...
LayerOptions(const QgsCoordinateTransformContext &transformContext, bool loadDefaultStyle=true, bool readExtentFromXml=false)
Constructor for LayerOptions.
Type
The WKB type describes the number of dimensions a geometry has.
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)
Queries 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
QgsVectorLayerServerProperties * serverProperties() const
Returns QGIS Server Properties of the vector layer.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
Encapsulates a QGIS project, including sets of map layers and their styles, layouts, annotations, canvases, etc.
Storage and management of actions associated with a layer.
QgsAttributeList attributeList() const
Returns list of attribute indexes.
Manages QGIS Server properties for a vector layer.
QgsFeatureRenderer * renderer()
Returns the feature renderer used for rendering the features in the layer in 2D map views...
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.
Contains information about the context in which a coordinate transform is executed.
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)
Queries 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.
Base class for storage of map layer temporal properties.
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.
Context for cascade delete features.
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...
Base class for utility classes that encapsulate information necessary for rendering of map layers...
SpatialIndexPresence
Enumeration of spatial index presence states.
const QgsFeatureRenderer * renderer() const
Returns the feature renderer used for rendering the features in the layer in 2D map views...
QSet< int > QgsAttributeIds
QList< int > QgsAttributeList
This is a container for configuration of the attribute table.
This is the base class for vector data providers.
QList< int > QgsAttributeList
QgsCoordinateReferenceSystem fallbackCrs
Fallback layer coordinate reference system.
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)
Queries the layer for the features with the given ids.
Constraint must be honored before feature can be accepted.
Manages stored expressions regarding creation, modification and storing in the project.
Abstract base class for simplify geometries using a specific algorithm.