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();
718 bool labelsEnabled()
const;
729 void setLabelsEnabled(
bool enabled );
736 bool diagramsEnabled()
const;
767 QString providerType()
const;
770 QString sourceName()
const FINAL;
785 QString decodedSource(
const QString &source,
const QString &provider,
const QgsReadWriteContext &context )
const FINAL;
801 virtual void saveStyleToDatabase(
const QString &name,
const QString &description,
802 bool useAsDefault,
const QString &uiFileContent,
814 virtual int listStylesInDatabase( QStringList &ids SIP_OUT, QStringList &names SIP_OUT,
815 QStringList &descriptions SIP_OUT, QString &msgError SIP_OUT );
820 virtual QString getStyleFromDatabase(
const QString &styleId, QString &msgError SIP_OUT );
829 virtual bool deleteStyleFromDatabase(
const QString &styleId, QString &msgError SIP_OUT );
838 virtual QString loadNamedStyle(
const QString &theURI,
bool &resultFlag SIP_OUT,
bool loadFromLocalDb,
845 QString loadNamedStyle(
const QString &theURI,
bool &resultFlag SIP_OUT,
861 bool loadAuxiliaryLayer(
const QgsAuxiliaryStorage &storage,
const QString &key = QString() );
896 bool readSymbology(
const QDomNode &layerNode, QString &errorMessage,
907 bool readStyle(
const QDomNode &node, QString &errorMessage,
919 bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
931 bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
942 bool writeSld( QDomNode &node, QDomDocument &doc, QString &errorMessage,
const QgsStringMap &props =
QgsStringMap() )
const;
944 bool readSld(
const QDomNode &node, QString &errorMessage )
FINAL;
951 long featureCount(
const QString &legendKey )
const;
976 Q_DECL_DEPRECATED
void setDataSource(
const QString &dataSource,
const QString &baseName,
const QString &provider,
bool loadDefaultStyleFlag =
false )
SIP_DEPRECATED;
990 void setDataSource(
const QString &dataSource,
const QString &baseName,
const QString &provider,
const QgsDataProvider::ProviderOptions &options,
bool loadDefaultStyleFlag =
false );
992 QString loadDefaultStyle(
bool &resultFlag SIP_OUT )
FINAL;
1015 virtual bool setSubsetString(
const QString &subset );
1021 virtual QString subsetString()
const;
1071 bool addFeature(
QgsFeature &feature, QgsFeatureSink::Flags flags =
nullptr )
FINAL;
1098 bool updateFeature(
QgsFeature &feature,
bool skipDefaultValues =
false );
1110 bool insertVertex(
double x,
double y,
QgsFeatureId atFeatureId,
int beforeVertex );
1134 bool moveVertex(
double x,
double y,
QgsFeatureId atFeatureId,
int atVertex );
1164 bool deleteSelectedFeatures(
int *deletedCount =
nullptr );
1264 int translateFeature(
QgsFeatureId featureId,
double dx,
double dy );
1314 int addTopologicalPoints(
const QgsGeometry &geom );
1328 int addTopologicalPoints(
const QgsPointXY &p );
1353 bool isEditable()
const FINAL;
1356 bool isSpatial()
const FINAL;
1359 virtual bool isModified()
const;
1367 bool isAuxiliaryField(
int index,
int &srcIndex )
const;
1370 void reload()
FINAL;
1403 long featureCount()
const FINAL;
1409 bool setReadOnly(
bool readonly =
true );
1463 bool changeAttributeValue(
QgsFeatureId fid,
int field,
const QVariant &newValue,
const QVariant &oldValue = QVariant(),
bool skipDefaultValues =
false );
1511 bool addAttribute(
const QgsField &field );
1518 void setFieldAlias(
int index,
const QString &aliasString );
1525 void removeFieldAlias(
int index );
1537 bool renameAttribute(
int index,
const QString &newName );
1545 QString attributeAlias(
int index )
const;
1548 QString attributeDisplayName(
int index )
const;
1581 virtual bool deleteAttribute(
int attr );
1590 bool deleteAttributes(
const QList<int> &attrs );
1592 bool addFeatures(
QgsFeatureList &features, QgsFeatureSink::Flags flags =
nullptr )
FINAL;
1638 bool commitChanges();
1645 QStringList commitErrors()
const;
1656 bool rollBack(
bool deleteBuffer =
true );
1664 QList<QgsRelation> referencingRelations(
int idx )
const;
1679 void beginEditCommand(
const QString &text );
1682 void endEditCommand();
1685 void destroyEditCommand();
1709 void updateFields();
1739 void setDefaultValueDefinition(
int index,
const QgsDefaultValue &definition );
1760 QgsFieldConstraints::Constraints fieldConstraints(
int fieldIndex )
const;
1767 QMap< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrength> fieldConstraintsAndStrength(
int fieldIndex )
const;
1795 QString constraintExpression(
int index )
const;
1804 QString constraintDescription(
int index )
const;
1814 void setConstraintExpression(
int index,
const QString &expression,
const QString &description = QString() );
1840 QSet<QVariant> uniqueValues(
int fieldIndex,
int limit = -1 ) const FINAL;
1855 QStringList uniqueStringsMatching(
int index, const QString &substring,
int limit = -1,
1866 QVariant minimumValue(
int index ) const FINAL;
1876 QVariant maximumValue(
int index ) const FINAL;
1889 const QString &fieldOrExpression,
1892 bool *ok =
nullptr ) const;
1895 void setFeatureBlendMode( QPainter::CompositionMode blendMode );
1897 QPainter::CompositionMode featureBlendMode() const;
1906 void setOpacity(
double opacity );
1915 double opacity() const;
1917 QString htmlMetadata() const FINAL;
1966 QString mapTipTemplate()
const;
1975 void setMapTipTemplate(
const QString &mapTipTemplate );
2005 void setReadExtentFromXml(
bool readExtentFromXml );
2014 bool readExtentFromXml()
const;
2068 void setAllowCommit(
bool allowCommit )
SIP_SKIP;
2113 void removeSelection();
2121 virtual void updateExtents(
bool force =
false );
2137 bool startEditing();
2148 void dataSourceChanged();
2160 void layerModified();
2167 void allowCommitChanged();
2170 void beforeModifiedCheck()
const;
2173 void beforeEditingStarted();
2176 void editingStarted();
2179 void editingStopped();
2182 void beforeCommitChanges();
2185 void beforeRollBack();
2191 void afterRollBack();
2201 void attributeAdded(
int idx );
2209 void beforeAddingExpressionField(
const QString &fieldName );
2219 void attributeDeleted(
int idx );
2227 void beforeRemovingExpressionField(
int idx );
2261 void updatedFields();
2267 void subsetStringChanged();
2277 void attributeValueChanged(
QgsFeatureId fid,
int idx,
const QVariant &value );
2289 void committedAttributesDeleted(
const QString &layerId,
const QgsAttributeList &deletedAttributes );
2291 void committedAttributesAdded(
const QString &layerId,
const QList<QgsField> &addedAttributes );
2293 void committedFeaturesAdded(
const QString &layerId,
const QgsFeatureList &addedFeatures );
2295 void committedFeaturesRemoved(
const QString &layerId,
const QgsFeatureIds &deletedFeatureIds );
2297 void committedAttributeValuesChanges(
const QString &layerId,
const QgsChangedAttributesMap &changedAttributesValues );
2299 void committedGeometriesChanges(
const QString &layerId,
const QgsGeometryMap &changedGeometries );
2302 void labelingFontNotFound(
QgsVectorLayer *layer,
const QString &fontfamily );
2305 void featureBlendModeChanged( QPainter::CompositionMode blendMode );
2314 void opacityChanged(
double opacity );
2321 void editCommandStarted(
const QString &text );
2328 void editCommandEnded();
2335 void editCommandDestroyed();
2346 void readCustomSymbology(
const QDomElement &element, QString &errorMessage );
2357 void writeCustomSymbology( QDomElement &element, QDomDocument &doc, QString &errorMessage )
const;
2364 void mapTipTemplateChanged();
2371 void displayExpressionChanged();
2376 void raiseError(
const QString &msg );
2383 void editFormConfigChanged();
2391 void readOnlyChanged();
2398 void symbolFeatureCountMapChanged();
2405 void invalidateSymbolCountedFlag();
2406 void onFeatureCounterCompleted();
2407 void onFeatureCounterTerminated();
2408 void onJoinedFieldsChanged();
2410 void onRelationsLoaded();
2411 void onSymbolsCounted();
2412 void onDirtyTransaction(
const QString &sql,
const QString &name );
2420 bool isReadOnly()
const FINAL;
2430 void readSldLabeling(
const QDomNode &node );
2446 QString mDisplayExpression;
2448 QString mMapTipTemplate;
2451 QString mProviderKey;
2457 bool mReadOnly =
false;
2473 QMap<QString, QgsDefaultValue> mDefaultExpressionMap;
2476 QSet<int> mDefaultValueOnUpdateFields;
2479 QMap< QString, QgsFieldConstraints::Constraints > mFieldConstraints;
2485 QMap< QString, QPair< QString, QString > > mFieldConstraintExpressions;
2487 QMap< QString, QgsEditorWidgetSetup > mFieldWidgetSetups;
2493 QSet<QString> mExcludeAttributesWMS;
2496 QSet<QString> mExcludeAttributesWFS;
2511 bool mLabelsEnabled =
false;
2514 bool mLabelFontNotFoundNotified =
false;
2517 QPainter::CompositionMode mFeatureBlendMode = QPainter::CompositionMode_SourceOver;
2520 double mLayerOpacity = 1.0;
2523 bool mVertexMarkerOnlyForSelection =
false;
2525 QStringList mCommitErrors;
2544 mutable bool mValidExtent =
false;
2545 mutable bool mLazyExtent =
true;
2548 std::unique_ptr<QgsAuxiliaryLayer> mAuxiliaryLayer;
2551 QString mAuxiliaryLayerKey;
2554 bool mSymbolFeatureCounted =
false;
2557 QHash<QString, long> mSymbolFeatureCountMap;
2560 bool mEditCommandActive =
false;
2562 bool mReadExtentFromXml;
2569 mutable QMutex mFeatureSourceConstructorMutex;
2573 std::unique_ptr<QgsGeometryOptions> mGeometryOptions;
2575 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.
QgsAttributeList attributeList() const
Returns list of attribute indexes.
QSet< QgsFeatureId > QgsFeatureIds
void setExcludeAttributesWms(const QSet< QString > &att)
A set of attributes that are not advertised in WMS requests with QGIS server.
QSet< QString > excludeAttributesWfs() const
A set of attributes that are not advertised in WFS requests with QGIS server.
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.
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings for fast rendering of features.
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.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
const QgsDiagramLayerSettings * diagramLayerSettings() const
const QgsVectorLayerEditBuffer * editBuffer() const
Buffer with uncommitted editing operations.
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 QgsFeatureRenderer * renderer() const
Returns const renderer.
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...
QgsFeature getFeature(QgsFeatureId fid) const
Query the layer for the feature with the given id.
Type
The WKB type describes the number of dimensions a geometry has.
const QgsAbstractVectorLayerLabeling * labeling() const
Access to const labeling configuration.
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.
const QgsActionManager * actions() const
Returns all layer actions defined on this layer.
QgsFeatureRenderer * renderer()
Returns renderer.
Abstract base class for curved geometry type.
Encapsulate a field in an attribute table or data source.
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.
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.
const QgsDiagramRenderer * diagramRenderer() const
Buffers information about expression fields for a vector layer.
QSet< QString > excludeAttributesWms() const
A set of attributes that are not advertised in WMS requests with QGIS server.
QMap< QgsFeatureId, QgsAttributeMap > QgsChangedAttributesMap
Abstract interface for generating an expression context scope.
An interface for objects which provide features via a getFeatures method.
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...
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
Represents a vector layer which manages a vector based data sets.
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.
bool isEditCommandActive() const
Test if an edit command is active.