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,
404 explicit LayerOptions(
bool loadDefaultStyle =
true,
bool readExtentFromXml =
false )
405 : loadDefaultStyle( loadDefaultStyle )
406 , readExtentFromXml( readExtentFromXml )
410 bool loadDefaultStyle =
true;
416 bool readExtentFromXml =
false;
433 explicit QgsVectorLayer(
const QString &path = QString(),
const QString &baseName = QString(),
458 QString storageType() const;
463 QString capabilitiesString() const;
468 QString dataComment() const;
477 QString displayField() const;
486 void setDisplayExpression( const QString &displayExpression );
494 QString displayExpression() const;
500 void setProviderEncoding( const QString &encoding );
503 void setCoordinateSystem();
514 bool removeJoin( const QString &joinLayerId );
521 const QList<QgsVectorLayerJoinInfo> vectorJoins()
const;
531 bool setDependencies(
const QSet<QgsMapLayerDependency> &layers )
FINAL;
540 QSet<QgsMapLayerDependency> dependencies()
const FINAL;
552 int addExpressionField(
const QString &exp,
const QgsField &fld );
561 void removeExpressionField(
int index );
572 QString expressionField(
int index )
const;
583 void updateExpressionField(
int index,
const QString &exp );
605 int selectedFeatureCount()
const;
627 void selectByExpression(
const QString &expression,
SelectBehavior behavior = SetSelection );
655 void invertSelection();
719 bool labelsEnabled()
const;
730 void setLabelsEnabled(
bool enabled );
737 bool diagramsEnabled()
const;
768 QString sourceName()
const FINAL;
783 QString decodedSource(
const QString &source,
const QString &provider,
const QgsReadWriteContext &context )
const FINAL;
799 virtual void saveStyleToDatabase(
const QString &name,
const QString &description,
800 bool useAsDefault,
const QString &uiFileContent,
812 virtual int listStylesInDatabase( QStringList &ids SIP_OUT, QStringList &names SIP_OUT,
813 QStringList &descriptions SIP_OUT, QString &msgError SIP_OUT );
818 virtual QString getStyleFromDatabase(
const QString &styleId, QString &msgError SIP_OUT );
827 virtual bool deleteStyleFromDatabase(
const QString &styleId, QString &msgError SIP_OUT );
836 virtual QString loadNamedStyle(
const QString &theURI,
bool &resultFlag SIP_OUT,
bool loadFromLocalDb,
843 QString loadNamedStyle(
const QString &theURI,
bool &resultFlag SIP_OUT,
859 bool loadAuxiliaryLayer(
const QgsAuxiliaryStorage &storage,
const QString &key = QString() );
894 bool readSymbology(
const QDomNode &layerNode, QString &errorMessage,
905 bool readStyle(
const QDomNode &node, QString &errorMessage,
917 bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
929 bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
940 bool writeSld( QDomNode &node, QDomDocument &doc, QString &errorMessage,
const QgsStringMap &props =
QgsStringMap() )
const;
942 bool readSld(
const QDomNode &node, QString &errorMessage )
FINAL;
949 long featureCount(
const QString &legendKey )
const;
974 Q_DECL_DEPRECATED
void setDataSource(
const QString &dataSource,
const QString &baseName,
const QString &provider,
bool loadDefaultStyleFlag =
false )
SIP_DEPRECATED;
988 void setDataSource(
const QString &dataSource,
const QString &baseName,
const QString &provider,
const QgsDataProvider::ProviderOptions &options,
bool loadDefaultStyleFlag =
false )
override;
990 QString loadDefaultStyle(
bool &resultFlag SIP_OUT )
FINAL;
1013 virtual bool setSubsetString(
const QString &subset );
1019 virtual QString subsetString()
const;
1069 bool addFeature(
QgsFeature &feature, QgsFeatureSink::Flags flags =
nullptr )
FINAL;
1096 bool updateFeature(
QgsFeature &feature,
bool skipDefaultValues =
false );
1108 bool insertVertex(
double x,
double y,
QgsFeatureId atFeatureId,
int beforeVertex );
1132 bool moveVertex(
double x,
double y,
QgsFeatureId atFeatureId,
int atVertex );
1162 bool deleteSelectedFeatures(
int *deletedCount =
nullptr );
1262 int translateFeature(
QgsFeatureId featureId,
double dx,
double dy );
1312 int addTopologicalPoints(
const QgsGeometry &geom );
1326 int addTopologicalPoints(
const QgsPointXY &p );
1351 bool isEditable()
const FINAL;
1354 bool isSpatial()
const FINAL;
1357 virtual bool isModified()
const;
1365 bool isAuxiliaryField(
int index,
int &srcIndex )
const;
1368 void reload()
FINAL;
1402 long featureCount()
const FINAL;
1408 bool setReadOnly(
bool readonly =
true );
1462 bool changeAttributeValue(
QgsFeatureId fid,
int field,
const QVariant &newValue,
const QVariant &oldValue = QVariant(),
bool skipDefaultValues =
false );
1510 bool addAttribute(
const QgsField &field );
1517 void setFieldAlias(
int index,
const QString &aliasString );
1524 void removeFieldAlias(
int index );
1536 bool renameAttribute(
int index,
const QString &newName );
1544 QString attributeAlias(
int index )
const;
1547 QString attributeDisplayName(
int index )
const;
1580 virtual bool deleteAttribute(
int attr );
1589 bool deleteAttributes(
const QList<int> &attrs );
1591 bool addFeatures(
QgsFeatureList &features, QgsFeatureSink::Flags flags =
nullptr )
FINAL;
1637 bool commitChanges();
1644 QStringList commitErrors()
const;
1655 bool rollBack(
bool deleteBuffer =
true );
1663 QList<QgsRelation> referencingRelations(
int idx )
const;
1678 void beginEditCommand(
const QString &text );
1681 void endEditCommand();
1684 void destroyEditCommand();
1708 void updateFields();
1738 void setDefaultValueDefinition(
int index,
const QgsDefaultValue &definition );
1759 QgsFieldConstraints::Constraints fieldConstraints(
int fieldIndex )
const;
1766 QMap< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrength> fieldConstraintsAndStrength(
int fieldIndex )
const;
1794 QString constraintExpression(
int index )
const;
1803 QString constraintDescription(
int index )
const;
1813 void setConstraintExpression(
int index,
const QString &expression,
const QString &description = QString() );
1839 QSet<QVariant> uniqueValues(
int fieldIndex,
int limit = -1 ) const FINAL;
1854 QStringList uniqueStringsMatching(
int index, const QString &substring,
int limit = -1,
1865 QVariant minimumValue(
int index ) const FINAL;
1875 QVariant maximumValue(
int index ) const FINAL;
1888 const QString &fieldOrExpression,
1891 bool *ok =
nullptr ) const;
1894 void setFeatureBlendMode( QPainter::CompositionMode blendMode );
1896 QPainter::CompositionMode featureBlendMode() const;
1905 void setOpacity(
double opacity );
1914 double opacity() const;
1916 QString htmlMetadata() const FINAL;
1965 QString mapTipTemplate()
const;
1974 void setMapTipTemplate(
const QString &mapTipTemplate );
2004 void setReadExtentFromXml(
bool readExtentFromXml );
2013 bool readExtentFromXml()
const;
2067 void setAllowCommit(
bool allowCommit )
SIP_SKIP;
2112 void removeSelection();
2120 virtual void updateExtents(
bool force =
false );
2136 bool startEditing();
2150 void layerModified();
2157 void allowCommitChanged();
2160 void beforeModifiedCheck()
const;
2163 void beforeEditingStarted();
2166 void editingStarted();
2169 void editingStopped();
2172 void beforeCommitChanges();
2175 void beforeRollBack();
2181 void afterRollBack();
2191 void attributeAdded(
int idx );
2199 void beforeAddingExpressionField(
const QString &fieldName );
2209 void attributeDeleted(
int idx );
2217 void beforeRemovingExpressionField(
int idx );
2251 void updatedFields();
2257 void subsetStringChanged();
2267 void attributeValueChanged(
QgsFeatureId fid,
int idx,
const QVariant &value );
2279 void committedAttributesDeleted(
const QString &layerId,
const QgsAttributeList &deletedAttributes );
2281 void committedAttributesAdded(
const QString &layerId,
const QList<QgsField> &addedAttributes );
2283 void committedFeaturesAdded(
const QString &layerId,
const QgsFeatureList &addedFeatures );
2285 void committedFeaturesRemoved(
const QString &layerId,
const QgsFeatureIds &deletedFeatureIds );
2287 void committedAttributeValuesChanges(
const QString &layerId,
const QgsChangedAttributesMap &changedAttributesValues );
2289 void committedGeometriesChanges(
const QString &layerId,
const QgsGeometryMap &changedGeometries );
2292 void labelingFontNotFound(
QgsVectorLayer *layer,
const QString &fontfamily );
2295 void featureBlendModeChanged( QPainter::CompositionMode blendMode );
2304 void opacityChanged(
double opacity );
2311 void editCommandStarted(
const QString &text );
2318 void editCommandEnded();
2325 void editCommandDestroyed();
2336 void readCustomSymbology(
const QDomElement &element, QString &errorMessage );
2347 void writeCustomSymbology( QDomElement &element, QDomDocument &doc, QString &errorMessage )
const;
2354 void mapTipTemplateChanged();
2361 void displayExpressionChanged();
2366 void raiseError(
const QString &msg );
2373 void editFormConfigChanged();
2381 void readOnlyChanged();
2388 void symbolFeatureCountMapChanged();
2395 void invalidateSymbolCountedFlag();
2396 void onFeatureCounterCompleted();
2397 void onFeatureCounterTerminated();
2398 void onJoinedFieldsChanged();
2400 void onRelationsLoaded();
2401 void onSymbolsCounted();
2402 void onDirtyTransaction(
const QString &sql,
const QString &name );
2410 bool isReadOnly()
const FINAL;
2420 void readSldLabeling(
const QDomNode &node );
2436 QString mDisplayExpression;
2438 QString mMapTipTemplate;
2444 bool mReadOnly =
false;
2460 QMap<QString, QgsDefaultValue> mDefaultExpressionMap;
2463 QSet<int> mDefaultValueOnUpdateFields;
2466 QMap< QString, QgsFieldConstraints::Constraints > mFieldConstraints;
2472 QMap< QString, QPair< QString, QString > > mFieldConstraintExpressions;
2474 QMap< QString, QgsEditorWidgetSetup > mFieldWidgetSetups;
2480 QSet<QString> mExcludeAttributesWMS;
2483 QSet<QString> mExcludeAttributesWFS;
2498 bool mLabelsEnabled =
false;
2501 bool mLabelFontNotFoundNotified =
false;
2504 QPainter::CompositionMode mFeatureBlendMode = QPainter::CompositionMode_SourceOver;
2507 double mLayerOpacity = 1.0;
2510 bool mVertexMarkerOnlyForSelection =
false;
2512 QStringList mCommitErrors;
2531 mutable bool mValidExtent =
false;
2532 mutable bool mLazyExtent =
true;
2535 std::unique_ptr<QgsAuxiliaryLayer> mAuxiliaryLayer;
2538 QString mAuxiliaryLayerKey;
2541 bool mSymbolFeatureCounted =
false;
2544 QHash<QString, long> mSymbolFeatureCountMap;
2547 bool mEditCommandActive =
false;
2549 bool mReadExtentFromXml;
2556 mutable QMutex mFeatureSourceConstructorMutex;
2560 std::unique_ptr<QgsGeometryOptions> mGeometryOptions;
2562 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
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.
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
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.
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...
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
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.