18 #ifndef QGSVECTORLAYER_H 19 #define QGSVECTORLAYER_H 22 #include "qgis_core.h" 26 #include <QStringList> 60 class QgsGeometryVertexIndex;
370 Q_PROPERTY( QString subsetString READ subsetString WRITE setSubsetString NOTIFY subsetStringChanged )
371 Q_PROPERTY( QString displayExpression READ displayExpression WRITE setDisplayExpression NOTIFY displayExpressionChanged )
372 Q_PROPERTY( QString mapTipTemplate READ mapTipTemplate WRITE setMapTipTemplate NOTIFY mapTipTemplateChanged )
373 Q_PROPERTY(
QgsEditFormConfig editFormConfig READ editFormConfig WRITE setEditFormConfig NOTIFY editFormConfigChanged )
374 Q_PROPERTY(
bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged )
375 Q_PROPERTY(
double opacity READ opacity WRITE setOpacity NOTIFY opacityChanged )
385 FetchFeatureFailed = 3,
409 bool readExtentFromXml =
false )
410 : loadDefaultStyle( loadDefaultStyle )
411 , readExtentFromXml( readExtentFromXml )
419 bool loadDefaultStyle =
true,
420 bool readExtentFromXml =
false 422 : loadDefaultStyle( loadDefaultStyle )
423 , readExtentFromXml( readExtentFromXml )
424 , transformContext( transformContext )
428 bool loadDefaultStyle =
true;
434 bool readExtentFromXml =
false;
481 bool skipCrsValidation =
false;
498 explicit QgsVectorLayer(
const QString &path = QString(),
const QString &baseName = QString(),
522 QString storageType() const;
527 QString capabilitiesString() const;
532 QString dataComment() const;
541 QString displayField() const;
550 void setDisplayExpression( const QString &displayExpression );
558 QString displayExpression() const;
564 void setProviderEncoding( const QString &encoding );
567 void setCoordinateSystem();
580 bool removeJoin( const QString &joinLayerId );
594 const QList<QgsVectorLayerJoinInfo> vectorJoins()
const;
604 bool setDependencies(
const QSet<QgsMapLayerDependency> &layers )
FINAL;
613 QSet<QgsMapLayerDependency> dependencies()
const FINAL;
625 int addExpressionField(
const QString &exp,
const QgsField &fld );
634 void removeExpressionField(
int index );
645 QString expressionField(
int index )
const;
656 void updateExpressionField(
int index,
const QString &exp );
684 int selectedFeatureCount()
const;
706 void selectByExpression(
const QString &expression,
SelectBehavior behavior = SetSelection );
734 void invertSelection();
798 bool labelsEnabled()
const;
809 void setLabelsEnabled(
bool enabled );
816 bool diagramsEnabled()
const;
847 QString sourceName()
const FINAL;
862 QString decodedSource(
const QString &source,
const QString &provider,
const QgsReadWriteContext &context )
const FINAL;
878 virtual void saveStyleToDatabase(
const QString &name,
const QString &description,
879 bool useAsDefault,
const QString &uiFileContent,
891 virtual int listStylesInDatabase( QStringList &ids SIP_OUT, QStringList &names SIP_OUT,
892 QStringList &descriptions SIP_OUT, QString &msgError SIP_OUT );
897 virtual QString getStyleFromDatabase(
const QString &styleId, QString &msgError SIP_OUT );
906 virtual bool deleteStyleFromDatabase(
const QString &styleId, QString &msgError SIP_OUT );
915 virtual QString loadNamedStyle(
const QString &theURI,
bool &resultFlag SIP_OUT,
bool loadFromLocalDb,
922 QString loadNamedStyle(
const QString &theURI,
bool &resultFlag SIP_OUT,
938 bool loadAuxiliaryLayer(
const QgsAuxiliaryStorage &storage,
const QString &key = QString() );
973 bool readSymbology(
const QDomNode &layerNode, QString &errorMessage,
984 bool readStyle(
const QDomNode &node, QString &errorMessage,
996 bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
1008 bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
1019 bool writeSld( QDomNode &node, QDomDocument &doc, QString &errorMessage,
const QgsStringMap &props =
QgsStringMap() )
const;
1021 bool readSld(
const QDomNode &node, QString &errorMessage )
FINAL;
1028 long featureCount(
const QString &legendKey )
const;
1036 QgsFeatureIds symbolFeatureIds(
const QString &legendKey )
const;
1061 Q_DECL_DEPRECATED
void setDataSource(
const QString &dataSource,
const QString &baseName,
const QString &provider,
bool loadDefaultStyleFlag =
false )
SIP_DEPRECATED;
1075 void setDataSource(
const QString &dataSource,
const QString &baseName,
const QString &provider,
const QgsDataProvider::ProviderOptions &options,
bool loadDefaultStyleFlag =
false )
override;
1077 QString loadDefaultStyle(
bool &resultFlag SIP_OUT )
FINAL;
1100 virtual bool setSubsetString(
const QString &subset );
1106 virtual QString subsetString()
const;
1156 bool addFeature(
QgsFeature &feature, QgsFeatureSink::Flags flags =
nullptr )
FINAL;
1183 bool updateFeature(
QgsFeature &feature,
bool skipDefaultValues =
false );
1196 bool insertVertex(
double x,
double y,
QgsFeatureId atFeatureId,
int beforeVertex );
1221 bool moveVertex(
double x,
double y,
QgsFeatureId atFeatureId,
int atVertex );
1251 bool deleteSelectedFeatures(
int *deletedCount =
nullptr );
1394 int translateFeature(
QgsFeatureId featureId,
double dx,
double dy );
1484 int addTopologicalPoints(
const QgsGeometry &geom );
1514 int addTopologicalPoints(
const QgsPoint &p );
1539 bool isEditable()
const FINAL;
1542 bool isSpatial()
const FINAL;
1545 virtual bool isModified()
const;
1553 bool isAuxiliaryField(
int index,
int &srcIndex )
const;
1556 void reload()
FINAL;
1590 long featureCount()
const FINAL;
1596 bool setReadOnly(
bool readonly =
true );
1650 bool changeAttributeValue(
QgsFeatureId fid,
int field,
const QVariant &newValue,
const QVariant &oldValue = QVariant(),
bool skipDefaultValues =
false );
1698 bool addAttribute(
const QgsField &field );
1705 void setFieldAlias(
int index,
const QString &aliasString );
1712 void removeFieldAlias(
int index );
1724 bool renameAttribute(
int index,
const QString &newName );
1732 QString attributeAlias(
int index )
const;
1735 QString attributeDisplayName(
int index )
const;
1768 virtual bool deleteAttribute(
int attr );
1777 bool deleteAttributes(
const QList<int> &attrs );
1779 bool addFeatures(
QgsFeatureList &features, QgsFeatureSink::Flags flags =
nullptr )
FINAL;
1825 bool commitChanges();
1832 QStringList commitErrors()
const;
1843 bool rollBack(
bool deleteBuffer =
true );
1851 QList<QgsRelation> referencingRelations(
int idx )
const;
1866 void beginEditCommand(
const QString &text );
1869 void endEditCommand();
1872 void destroyEditCommand();
1896 void updateFields();
1926 void setDefaultValueDefinition(
int index,
const QgsDefaultValue &definition );
1947 QgsFieldConstraints::Constraints fieldConstraints(
int fieldIndex )
const;
1954 QMap< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrength> fieldConstraintsAndStrength(
int fieldIndex )
const;
1982 QString constraintExpression(
int index )
const;
1991 QString constraintDescription(
int index )
const;
2001 void setConstraintExpression(
int index,
const QString &expression,
const QString &description = QString() );
2027 QSet<QVariant> uniqueValues(
int fieldIndex,
int limit = -1 ) const FINAL;
2042 QStringList uniqueStringsMatching(
int index, const QString &substring,
int limit = -1,
2053 QVariant minimumValue(
int index ) const FINAL;
2063 QVariant maximumValue(
int index ) const FINAL;
2078 const QString &fieldOrExpression,
2085 void setFeatureBlendMode( QPainter::CompositionMode blendMode );
2087 QPainter::CompositionMode featureBlendMode() const;
2096 void setOpacity(
double opacity );
2105 double opacity() const;
2107 QString htmlMetadata() const FINAL;
2156 QString mapTipTemplate()
const;
2165 void setMapTipTemplate(
const QString &mapTipTemplate );
2195 void setReadExtentFromXml(
bool readExtentFromXml );
2204 bool readExtentFromXml()
const;
2258 void setAllowCommit(
bool allowCommit )
SIP_SKIP;
2311 void removeSelection();
2331 virtual void updateExtents(
bool force =
false );
2347 bool startEditing();
2370 void layerModified();
2377 void allowCommitChanged();
2380 void beforeModifiedCheck()
const;
2383 void beforeEditingStarted();
2386 void editingStarted();
2389 void editingStopped();
2392 void beforeCommitChanges();
2395 void beforeRollBack();
2401 void afterRollBack();
2411 void attributeAdded(
int idx );
2419 void beforeAddingExpressionField(
const QString &fieldName );
2429 void attributeDeleted(
int idx );
2437 void beforeRemovingExpressionField(
int idx );
2471 void updatedFields();
2477 void subsetStringChanged();
2487 void attributeValueChanged(
QgsFeatureId fid,
int idx,
const QVariant &value );
2499 void committedAttributesDeleted(
const QString &layerId,
const QgsAttributeList &deletedAttributes );
2501 void committedAttributesAdded(
const QString &layerId,
const QList<QgsField> &addedAttributes );
2503 void committedFeaturesAdded(
const QString &layerId,
const QgsFeatureList &addedFeatures );
2505 void committedFeaturesRemoved(
const QString &layerId,
const QgsFeatureIds &deletedFeatureIds );
2507 void committedAttributeValuesChanges(
const QString &layerId,
const QgsChangedAttributesMap &changedAttributesValues );
2509 void committedGeometriesChanges(
const QString &layerId,
const QgsGeometryMap &changedGeometries );
2512 void labelingFontNotFound(
QgsVectorLayer *layer,
const QString &fontfamily );
2515 void featureBlendModeChanged( QPainter::CompositionMode blendMode );
2524 void opacityChanged(
double opacity );
2531 void editCommandStarted(
const QString &text );
2538 void editCommandEnded();
2545 void editCommandDestroyed();
2556 void readCustomSymbology(
const QDomElement &element, QString &errorMessage );
2567 void writeCustomSymbology( QDomElement &element, QDomDocument &doc, QString &errorMessage )
const;
2574 void mapTipTemplateChanged();
2581 void displayExpressionChanged();
2586 void raiseError(
const QString &msg );
2593 void editFormConfigChanged();
2601 void readOnlyChanged();
2608 void symbolFeatureCountMapChanged();
2615 void invalidateSymbolCountedFlag();
2616 void onFeatureCounterCompleted();
2617 void onFeatureCounterTerminated();
2618 void onJoinedFieldsChanged();
2620 void onRelationsLoaded();
2621 void onSymbolsCounted();
2622 void onDirtyTransaction(
const QString &sql,
const QString &name );
2623 void emitDataChanged();
2631 bool isReadOnly()
const FINAL;
2641 void readSldLabeling(
const QDomNode &node );
2649 QVariant minimumOrMaximumValue(
int index,
bool minimum )
const;
2659 QString mDisplayExpression;
2661 QString mMapTipTemplate;
2667 bool mReadOnly =
false;
2688 QMap<QString, QgsDefaultValue> mDefaultExpressionMap;
2691 QSet<int> mDefaultValueOnUpdateFields;
2694 QMap< QString, QgsFieldConstraints::Constraints > mFieldConstraints;
2700 QMap< QString, QPair< QString, QString > > mFieldConstraintExpressions;
2702 QMap< QString, QgsEditorWidgetSetup > mFieldWidgetSetups;
2708 QSet<QString> mExcludeAttributesWMS;
2711 QSet<QString> mExcludeAttributesWFS;
2726 bool mLabelsEnabled =
false;
2729 bool mLabelFontNotFoundNotified =
false;
2732 QPainter::CompositionMode mFeatureBlendMode = QPainter::CompositionMode_SourceOver;
2735 double mLayerOpacity = 1.0;
2738 bool mVertexMarkerOnlyForSelection =
false;
2740 QStringList mCommitErrors;
2751 std::unique_ptr< QgsVectorLayerServerProperties > mServerProperties;
2762 mutable bool mValidExtent =
false;
2763 mutable bool mLazyExtent =
true;
2766 std::unique_ptr<QgsAuxiliaryLayer> mAuxiliaryLayer;
2769 QString mAuxiliaryLayerKey;
2772 bool mSymbolFeatureCounted =
false;
2775 QHash<QString, long> mSymbolFeatureCountMap;
2776 QHash<QString, QgsFeatureIds> mSymbolFeatureIdMap;
2779 bool mEditCommandActive =
false;
2781 bool mReadExtentFromXml;
2788 mutable QMutex mFeatureSourceConstructorMutex;
2792 std::unique_ptr<QgsGeometryOptions> mGeometryOptions;
2794 bool mAllowCommit =
true;
2802 bool mDataChangedFired =
false;
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.
QSet< QgsFeatureId > QgsFeatureIds
void setExcludeAttributesWms(const QSet< QString > &att)
A set of attributes that are not advertised in WMS requests with QGIS server.
The QgsGeometryOptions class contains options to automatically adjust geometries to constraints on a ...
Abstract base class for all rendered symbols.
QSet< QString > excludeAttributesWms() const
A set of attributes that are not advertised in WMS requests with QGIS server.
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.
QSet< QString > excludeAttributesWfs() const
A set of attributes that are not advertised in WFS requests with QGIS server.
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.
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.
A geometry is the spatial representation of a feature.
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.
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.
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...
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
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 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.
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.
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...
Base class for utility classes that encapsulate information necessary for rendering of map layers...
QgsVectorLayerServerProperties * serverProperties()
Returns QGIS Server Properties of the vector layer.
const QgsFeatureRenderer * renderer() const
Returns const renderer.
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.