19 #ifndef QGSVECTORLAYER_H 20 #define QGSVECTORLAYER_H 22 #include "qgis_core.h" 26 #include <QStringList> 58 class QgsGeometryVertexIndex;
357 Q_PROPERTY( QString displayExpression READ displayExpression WRITE setDisplayExpression NOTIFY displayExpressionChanged )
358 Q_PROPERTY( QString mapTipTemplate READ mapTipTemplate WRITE setMapTipTemplate NOTIFY mapTipTemplateChanged )
359 Q_PROPERTY(
QgsEditFormConfig editFormConfig READ editFormConfig WRITE setEditFormConfig NOTIFY editFormConfigChanged )
360 Q_PROPERTY(
bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged )
361 Q_PROPERTY(
double opacity READ opacity WRITE setOpacity NOTIFY opacityChanged )
371 FetchFeatureFailed = 3,
394 explicit LayerOptions(
bool loadDefaultStyle =
true,
bool readExtentFromXml =
false )
395 : loadDefaultStyle( loadDefaultStyle )
396 , readExtentFromXml( readExtentFromXml )
400 bool loadDefaultStyle =
true;
406 bool readExtentFromXml =
false;
423 explicit QgsVectorLayer(
const QString &path = QString(),
const QString &baseName = QString(),
448 QString storageType() const;
453 QString capabilitiesString() const;
458 QString dataComment() const;
467 QString displayField() const;
476 void setDisplayExpression( const QString &displayExpression );
484 QString displayExpression() const;
490 void setProviderEncoding( const QString &encoding );
493 void setCoordinateSystem();
504 bool removeJoin( const QString &joinLayerId );
511 const QList<QgsVectorLayerJoinInfo> vectorJoins()
const;
521 bool setDependencies(
const QSet<QgsMapLayerDependency> &layers )
override;
530 QSet<QgsMapLayerDependency> dependencies()
const override;
542 int addExpressionField(
const QString &exp,
const QgsField &fld );
551 void removeExpressionField(
int index );
562 QString expressionField(
int index )
const;
573 void updateExpressionField(
int index,
const QString &exp );
595 int selectedFeatureCount()
const;
617 void selectByExpression(
const QString &expression,
SelectBehavior behavior = SetSelection );
646 void invertSelection();
701 bool labelsEnabled()
const;
712 void setLabelsEnabled(
bool enabled );
719 bool diagramsEnabled()
const;
750 QString providerType()
const;
753 QString sourceName()
const override;
765 bool writeXml( QDomNode &layer_node, QDomDocument &doc,
const QgsReadWriteContext &context )
const override;
771 void resolveReferences(
QgsProject *project )
override;
781 virtual void saveStyleToDatabase(
const QString &name,
const QString &description,
782 bool useAsDefault,
const QString &uiFileContent,
793 virtual int listStylesInDatabase( QStringList &ids SIP_OUT, QStringList &names SIP_OUT,
794 QStringList &descriptions SIP_OUT, QString &msgError SIP_OUT );
799 virtual QString getStyleFromDatabase(
const QString &styleId, QString &msgError SIP_OUT );
808 virtual bool deleteStyleFromDatabase(
const QString &styleId, QString &msgError SIP_OUT );
816 virtual QString loadNamedStyle(
const QString &theURI,
bool &resultFlag SIP_OUT,
bool loadFromLocalDb );
822 QString loadNamedStyle(
const QString &theURI,
bool &resultFlag SIP_OUT )
override;
837 bool loadAuxiliaryLayer(
const QgsAuxiliaryStorage &storage,
const QString &key = QString() );
871 bool readSymbology(
const QDomNode &layerNode, QString &errorMessage,
const QgsReadWriteContext &context )
override;
880 bool readStyle(
const QDomNode &node, QString &errorMessage,
const QgsReadWriteContext &context )
override;
890 bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
const QgsReadWriteContext &context )
const override;
900 bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
const QgsReadWriteContext &context )
const override;
910 bool writeSld( QDomNode &node, QDomDocument &doc, QString &errorMessage,
const QgsStringMap &props =
QgsStringMap() )
const;
912 bool readSld(
const QDomNode &node, QString &errorMessage )
override;
919 long featureCount(
const QString &legendKey )
const;
931 void setDataSource(
const QString &dataSource,
const QString &baseName,
const QString &provider,
bool loadDefaultStyleFlag =
false );
954 virtual bool setSubsetString(
const QString &subset );
960 virtual QString subsetString()
const;
1004 bool addFeature(
QgsFeature &feature, QgsFeatureSink::Flags flags =
nullptr )
override;
1031 bool updateFeature(
const QgsFeature &feature,
bool skipDefaultValues =
false );
1043 bool insertVertex(
double x,
double y,
QgsFeatureId atFeatureId,
int beforeVertex );
1067 bool moveVertex(
double x,
double y,
QgsFeatureId atFeatureId,
int atVertex );
1097 bool deleteSelectedFeatures(
int *deletedCount =
nullptr );
1197 int translateFeature(
QgsFeatureId featureId,
double dx,
double dy );
1247 int addTopologicalPoints(
const QgsGeometry &geom );
1261 int addTopologicalPoints(
const QgsPointXY &p );
1286 bool isEditable()
const override;
1289 bool isSpatial()
const override;
1292 virtual bool isModified()
const;
1300 bool isAuxiliaryField(
int index,
int &srcIndex )
const;
1303 void reload()
override;
1336 long featureCount()
const override;
1342 bool setReadOnly(
bool readonly =
true );
1396 bool changeAttributeValue(
QgsFeatureId fid,
int field,
const QVariant &newValue,
const QVariant &oldValue = QVariant(),
bool skipDefaultValues =
false );
1444 bool addAttribute(
const QgsField &field );
1451 void setFieldAlias(
int index,
const QString &aliasString );
1458 void removeFieldAlias(
int index );
1470 bool renameAttribute(
int index,
const QString &newName );
1478 QString attributeAlias(
int index )
const;
1481 QString attributeDisplayName(
int index )
const;
1514 virtual bool deleteAttribute(
int attr );
1523 bool deleteAttributes( QList<int> attrs );
1525 bool addFeatures(
QgsFeatureList &features, QgsFeatureSink::Flags flags =
nullptr )
override;
1571 bool commitChanges();
1578 QStringList commitErrors()
const;
1589 bool rollBack(
bool deleteBuffer =
true );
1597 QList<QgsRelation> referencingRelations(
int idx )
const;
1612 void beginEditCommand(
const QString &text );
1615 void endEditCommand();
1618 void destroyEditCommand();
1639 void updateFields();
1669 void setDefaultValueDefinition(
int index,
const QgsDefaultValue &definition );
1690 QgsFieldConstraints::Constraints fieldConstraints(
int fieldIndex )
const;
1697 QMap< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrength> fieldConstraintsAndStrength(
int fieldIndex )
const;
1725 QString constraintExpression(
int index )
const;
1734 QString constraintDescription(
int index )
const;
1744 void setConstraintExpression(
int index,
const QString &expression,
const QString &description = QString() );
1770 QSet<QVariant> uniqueValues(
int fieldIndex,
int limit = -1 )
const override;
1785 QStringList uniqueStringsMatching(
int index,
const QString &substring,
int limit = -1,
1796 QVariant minimumValue(
int index )
const override;
1806 QVariant maximumValue(
int index )
const override;
1819 const QString &fieldOrExpression,
1822 bool *ok =
nullptr )
const;
1825 void setFeatureBlendMode( QPainter::CompositionMode blendMode );
1827 QPainter::CompositionMode featureBlendMode()
const;
1836 void setOpacity(
double opacity );
1845 double opacity()
const;
1847 QString htmlMetadata()
const override;
1896 QString mapTipTemplate()
const;
1905 void setMapTipTemplate(
const QString &mapTipTemplate );
1938 void setReadExtentFromXml(
bool readExtentFromXml );
1947 bool readExtentFromXml()
const;
1999 void removeSelection();
2007 virtual void updateExtents(
bool force =
false );
2023 bool startEditing();
2037 void layerModified();
2040 void beforeModifiedCheck()
const;
2043 void beforeEditingStarted();
2046 void editingStarted();
2049 void editingStopped();
2052 void beforeCommitChanges();
2055 void beforeRollBack();
2065 void attributeAdded(
int idx );
2073 void beforeAddingExpressionField(
const QString &fieldName );
2083 void attributeDeleted(
int idx );
2091 void beforeRemovingExpressionField(
int idx );
2125 void updatedFields();
2136 void attributeValueChanged(
QgsFeatureId fid,
int idx,
const QVariant &value );
2148 void committedAttributesDeleted(
const QString &layerId,
const QgsAttributeList &deletedAttributes );
2150 void committedAttributesAdded(
const QString &layerId,
const QList<QgsField> &addedAttributes );
2152 void committedFeaturesAdded(
const QString &layerId,
const QgsFeatureList &addedFeatures );
2154 void committedFeaturesRemoved(
const QString &layerId,
const QgsFeatureIds &deletedFeatureIds );
2156 void committedAttributeValuesChanges(
const QString &layerId,
const QgsChangedAttributesMap &changedAttributesValues );
2158 void committedGeometriesChanges(
const QString &layerId,
const QgsGeometryMap &changedGeometries );
2161 void labelingFontNotFound(
QgsVectorLayer *layer,
const QString &fontfamily );
2164 void featureBlendModeChanged( QPainter::CompositionMode blendMode );
2173 void opacityChanged(
double opacity );
2180 void editCommandStarted(
const QString &text );
2187 void editCommandEnded();
2194 void editCommandDestroyed();
2205 void readCustomSymbology(
const QDomElement &element, QString &errorMessage );
2216 void writeCustomSymbology( QDomElement &element, QDomDocument &doc, QString &errorMessage )
const;
2223 void mapTipTemplateChanged();
2230 void displayExpressionChanged();
2235 void raiseError(
const QString &msg );
2242 void editFormConfigChanged();
2250 void readOnlyChanged();
2257 void symbolFeatureCountMapChanged();
2260 void invalidateSymbolCountedFlag();
2261 void onFeatureCounterCompleted();
2262 void onFeatureCounterTerminated();
2263 void onJoinedFieldsChanged();
2265 void onRelationsLoaded();
2266 void onSymbolsCounted();
2267 void onDirtyTransaction(
const QString &sql,
const QString &name );
2280 bool isReadOnly()
const override;
2287 bool setDataProvider( QString
const &provider );
2290 void readSldLabeling(
const QDomNode &node );
2306 QString mDisplayExpression;
2308 QString mMapTipTemplate;
2311 QString mProviderKey;
2317 bool mReadOnly =
false;
2333 QMap<QString, QgsDefaultValue> mDefaultExpressionMap;
2336 QSet<int> mDefaultValueOnUpdateFields;
2339 QMap< QString, QgsFieldConstraints::Constraints > mFieldConstraints;
2345 QMap< QString, QPair< QString, QString > > mFieldConstraintExpressions;
2347 QMap< QString, QgsEditorWidgetSetup > mFieldWidgetSetups;
2353 QSet<QString> mExcludeAttributesWMS;
2356 QSet<QString> mExcludeAttributesWFS;
2371 bool mLabelsEnabled =
false;
2374 bool mLabelFontNotFoundNotified =
false;
2377 QPainter::CompositionMode mFeatureBlendMode = QPainter::CompositionMode_SourceOver;
2380 double mLayerOpacity = 1.0;
2383 bool mVertexMarkerOnlyForSelection =
false;
2385 QStringList mCommitErrors;
2404 mutable bool mValidExtent =
false;
2405 mutable bool mLazyExtent =
true;
2408 std::unique_ptr<QgsAuxiliaryLayer> mAuxiliaryLayer;
2411 QString mAuxiliaryLayerKey;
2414 bool mSymbolFeatureCounted =
false;
2417 QHash<QString, long> mSymbolFeatureCountMap;
2420 bool mEditCommandActive =
false;
2422 bool mReadExtentFromXml;
2429 mutable QMutex mFeatureSourceConstructorMutex;
QgsActionManager * actions()
Get 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()
Return 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.
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
Return 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
Get 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.