18 #ifndef QGSVECTORLAYER_H 19 #define QGSVECTORLAYER_H 22 #include "qgis_core.h" 26 #include <QStringList> 58 class QgsGeometryVertexIndex;
366 Q_PROPERTY( QString subsetString READ subsetString WRITE setSubsetString NOTIFY subsetStringChanged )
367 Q_PROPERTY( QString displayExpression READ displayExpression WRITE setDisplayExpression NOTIFY displayExpressionChanged )
368 Q_PROPERTY( QString mapTipTemplate READ mapTipTemplate WRITE setMapTipTemplate NOTIFY mapTipTemplateChanged )
369 Q_PROPERTY(
QgsEditFormConfig editFormConfig READ editFormConfig WRITE setEditFormConfig NOTIFY editFormConfigChanged )
370 Q_PROPERTY(
bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged )
371 Q_PROPERTY(
double opacity READ opacity WRITE setOpacity NOTIFY opacityChanged )
381 FetchFeatureFailed = 3,
405 bool readExtentFromXml =
false )
406 : loadDefaultStyle( loadDefaultStyle )
407 , readExtentFromXml( readExtentFromXml )
415 bool loadDefaultStyle =
true,
416 bool readExtentFromXml =
false 418 : loadDefaultStyle( loadDefaultStyle )
419 , readExtentFromXml( readExtentFromXml )
420 , transformContext( transformContext )
424 bool loadDefaultStyle =
true;
430 bool readExtentFromXml =
false;
479 explicit QgsVectorLayer(
const QString &path = QString(),
const QString &baseName = QString(),
503 QString storageType() const;
508 QString capabilitiesString() const;
513 QString dataComment() const;
522 QString displayField() const;
531 void setDisplayExpression( const QString &displayExpression );
539 QString displayExpression() const;
545 void setProviderEncoding( const QString &encoding );
548 void setCoordinateSystem();
561 bool removeJoin( const QString &joinLayerId );
568 const QList<QgsVectorLayerJoinInfo> vectorJoins()
const;
578 bool setDependencies(
const QSet<QgsMapLayerDependency> &layers )
FINAL;
587 QSet<QgsMapLayerDependency> dependencies()
const FINAL;
599 int addExpressionField(
const QString &exp,
const QgsField &fld );
608 void removeExpressionField(
int index );
619 QString expressionField(
int index )
const;
630 void updateExpressionField(
int index,
const QString &exp );
652 int selectedFeatureCount()
const;
674 void selectByExpression(
const QString &expression,
SelectBehavior behavior = SetSelection );
702 void invertSelection();
766 bool labelsEnabled()
const;
777 void setLabelsEnabled(
bool enabled );
784 bool diagramsEnabled()
const;
815 QString sourceName()
const FINAL;
830 QString decodedSource(
const QString &source,
const QString &provider,
const QgsReadWriteContext &context )
const FINAL;
846 virtual void saveStyleToDatabase(
const QString &name,
const QString &description,
847 bool useAsDefault,
const QString &uiFileContent,
859 virtual int listStylesInDatabase( QStringList &ids SIP_OUT, QStringList &names SIP_OUT,
860 QStringList &descriptions SIP_OUT, QString &msgError SIP_OUT );
865 virtual QString getStyleFromDatabase(
const QString &styleId, QString &msgError SIP_OUT );
874 virtual bool deleteStyleFromDatabase(
const QString &styleId, QString &msgError SIP_OUT );
883 virtual QString loadNamedStyle(
const QString &theURI,
bool &resultFlag SIP_OUT,
bool loadFromLocalDb,
890 QString loadNamedStyle(
const QString &theURI,
bool &resultFlag SIP_OUT,
906 bool loadAuxiliaryLayer(
const QgsAuxiliaryStorage &storage,
const QString &key = QString() );
941 bool readSymbology(
const QDomNode &layerNode, QString &errorMessage,
952 bool readStyle(
const QDomNode &node, QString &errorMessage,
964 bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
976 bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
987 bool writeSld( QDomNode &node, QDomDocument &doc, QString &errorMessage,
const QgsStringMap &props =
QgsStringMap() )
const;
989 bool readSld(
const QDomNode &node, QString &errorMessage )
FINAL;
996 long featureCount(
const QString &legendKey )
const;
1021 Q_DECL_DEPRECATED
void setDataSource(
const QString &dataSource,
const QString &baseName,
const QString &provider,
bool loadDefaultStyleFlag =
false )
SIP_DEPRECATED;
1035 void setDataSource(
const QString &dataSource,
const QString &baseName,
const QString &provider,
const QgsDataProvider::ProviderOptions &options,
bool loadDefaultStyleFlag =
false )
override;
1037 QString loadDefaultStyle(
bool &resultFlag SIP_OUT )
FINAL;
1060 virtual bool setSubsetString(
const QString &subset );
1066 virtual QString subsetString()
const;
1116 bool addFeature(
QgsFeature &feature, QgsFeatureSink::Flags flags =
nullptr )
FINAL;
1143 bool updateFeature(
QgsFeature &feature,
bool skipDefaultValues =
false );
1156 bool insertVertex(
double x,
double y,
QgsFeatureId atFeatureId,
int beforeVertex );
1181 bool moveVertex(
double x,
double y,
QgsFeatureId atFeatureId,
int atVertex );
1211 bool deleteSelectedFeatures(
int *deletedCount =
nullptr );
1311 int translateFeature(
QgsFeatureId featureId,
double dx,
double dy );
1361 int addTopologicalPoints(
const QgsGeometry &geom );
1375 int addTopologicalPoints(
const QgsPointXY &p );
1400 bool isEditable()
const FINAL;
1403 bool isSpatial()
const FINAL;
1406 virtual bool isModified()
const;
1414 bool isAuxiliaryField(
int index,
int &srcIndex )
const;
1417 void reload()
FINAL;
1451 long featureCount()
const FINAL;
1457 bool setReadOnly(
bool readonly =
true );
1511 bool changeAttributeValue(
QgsFeatureId fid,
int field,
const QVariant &newValue,
const QVariant &oldValue = QVariant(),
bool skipDefaultValues =
false );
1559 bool addAttribute(
const QgsField &field );
1566 void setFieldAlias(
int index,
const QString &aliasString );
1573 void removeFieldAlias(
int index );
1585 bool renameAttribute(
int index,
const QString &newName );
1593 QString attributeAlias(
int index )
const;
1596 QString attributeDisplayName(
int index )
const;
1629 virtual bool deleteAttribute(
int attr );
1638 bool deleteAttributes(
const QList<int> &attrs );
1640 bool addFeatures(
QgsFeatureList &features, QgsFeatureSink::Flags flags =
nullptr )
FINAL;
1686 bool commitChanges();
1693 QStringList commitErrors()
const;
1704 bool rollBack(
bool deleteBuffer =
true );
1712 QList<QgsRelation> referencingRelations(
int idx )
const;
1727 void beginEditCommand(
const QString &text );
1730 void endEditCommand();
1733 void destroyEditCommand();
1757 void updateFields();
1787 void setDefaultValueDefinition(
int index,
const QgsDefaultValue &definition );
1808 QgsFieldConstraints::Constraints fieldConstraints(
int fieldIndex )
const;
1815 QMap< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrength> fieldConstraintsAndStrength(
int fieldIndex )
const;
1843 QString constraintExpression(
int index )
const;
1852 QString constraintDescription(
int index )
const;
1862 void setConstraintExpression(
int index,
const QString &expression,
const QString &description = QString() );
1888 QSet<QVariant> uniqueValues(
int fieldIndex,
int limit = -1 ) const FINAL;
1903 QStringList uniqueStringsMatching(
int index, const QString &substring,
int limit = -1,
1914 QVariant minimumValue(
int index ) const FINAL;
1924 QVariant maximumValue(
int index ) const FINAL;
1939 const QString &fieldOrExpression,
1946 void setFeatureBlendMode( QPainter::CompositionMode blendMode );
1948 QPainter::CompositionMode featureBlendMode() const;
1957 void setOpacity(
double opacity );
1966 double opacity() const;
1968 QString htmlMetadata() const FINAL;
2017 QString mapTipTemplate()
const;
2026 void setMapTipTemplate(
const QString &mapTipTemplate );
2056 void setReadExtentFromXml(
bool readExtentFromXml );
2065 bool readExtentFromXml()
const;
2119 void setAllowCommit(
bool allowCommit )
SIP_SKIP;
2165 void removeSelection();
2173 virtual void updateExtents(
bool force =
false );
2189 bool startEditing();
2210 void layerModified();
2217 void allowCommitChanged();
2220 void beforeModifiedCheck()
const;
2223 void beforeEditingStarted();
2226 void editingStarted();
2229 void editingStopped();
2232 void beforeCommitChanges();
2235 void beforeRollBack();
2241 void afterRollBack();
2251 void attributeAdded(
int idx );
2259 void beforeAddingExpressionField(
const QString &fieldName );
2269 void attributeDeleted(
int idx );
2277 void beforeRemovingExpressionField(
int idx );
2311 void updatedFields();
2317 void subsetStringChanged();
2327 void attributeValueChanged(
QgsFeatureId fid,
int idx,
const QVariant &value );
2339 void committedAttributesDeleted(
const QString &layerId,
const QgsAttributeList &deletedAttributes );
2341 void committedAttributesAdded(
const QString &layerId,
const QList<QgsField> &addedAttributes );
2343 void committedFeaturesAdded(
const QString &layerId,
const QgsFeatureList &addedFeatures );
2345 void committedFeaturesRemoved(
const QString &layerId,
const QgsFeatureIds &deletedFeatureIds );
2347 void committedAttributeValuesChanges(
const QString &layerId,
const QgsChangedAttributesMap &changedAttributesValues );
2349 void committedGeometriesChanges(
const QString &layerId,
const QgsGeometryMap &changedGeometries );
2352 void labelingFontNotFound(
QgsVectorLayer *layer,
const QString &fontfamily );
2355 void featureBlendModeChanged( QPainter::CompositionMode blendMode );
2364 void opacityChanged(
double opacity );
2371 void editCommandStarted(
const QString &text );
2378 void editCommandEnded();
2385 void editCommandDestroyed();
2396 void readCustomSymbology(
const QDomElement &element, QString &errorMessage );
2407 void writeCustomSymbology( QDomElement &element, QDomDocument &doc, QString &errorMessage )
const;
2414 void mapTipTemplateChanged();
2421 void displayExpressionChanged();
2426 void raiseError(
const QString &msg );
2433 void editFormConfigChanged();
2441 void readOnlyChanged();
2448 void symbolFeatureCountMapChanged();
2455 void invalidateSymbolCountedFlag();
2456 void onFeatureCounterCompleted();
2457 void onFeatureCounterTerminated();
2458 void onJoinedFieldsChanged();
2460 void onRelationsLoaded();
2461 void onSymbolsCounted();
2462 void onDirtyTransaction(
const QString &sql,
const QString &name );
2470 bool isReadOnly()
const FINAL;
2480 void readSldLabeling(
const QDomNode &node );
2496 QString mDisplayExpression;
2498 QString mMapTipTemplate;
2504 bool mReadOnly =
false;
2520 QMap<QString, QgsDefaultValue> mDefaultExpressionMap;
2523 QSet<int> mDefaultValueOnUpdateFields;
2526 QMap< QString, QgsFieldConstraints::Constraints > mFieldConstraints;
2532 QMap< QString, QPair< QString, QString > > mFieldConstraintExpressions;
2534 QMap< QString, QgsEditorWidgetSetup > mFieldWidgetSetups;
2540 QSet<QString> mExcludeAttributesWMS;
2543 QSet<QString> mExcludeAttributesWFS;
2558 bool mLabelsEnabled =
false;
2561 bool mLabelFontNotFoundNotified =
false;
2564 QPainter::CompositionMode mFeatureBlendMode = QPainter::CompositionMode_SourceOver;
2567 double mLayerOpacity = 1.0;
2570 bool mVertexMarkerOnlyForSelection =
false;
2572 QStringList mCommitErrors;
2591 mutable bool mValidExtent =
false;
2592 mutable bool mLazyExtent =
true;
2595 std::unique_ptr<QgsAuxiliaryLayer> mAuxiliaryLayer;
2598 QString mAuxiliaryLayerKey;
2601 bool mSymbolFeatureCounted =
false;
2604 QHash<QString, long> mSymbolFeatureCountMap;
2607 bool mEditCommandActive =
false;
2609 bool mReadExtentFromXml;
2616 mutable QMutex mFeatureSourceConstructorMutex;
2620 std::unique_ptr<QgsGeometryOptions> mGeometryOptions;
2622 bool mAllowCommit =
true;
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.
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...
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...
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)...
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.
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...
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.
Abstract base class for simplify geometries using a specific algorithm.