QGIS API Documentation  3.0.2-Girona (307d082)
Public Member Functions | Static Public Member Functions | List of all members
QgsAuxiliaryLayer Class Reference

Class allowing to manage the auxiliary storage for a vector layer. More...

#include <qgsauxiliarystorage.h>

Inheritance diagram for QgsAuxiliaryLayer:
Inheritance graph
[legend]

Public Member Functions

 QgsAuxiliaryLayer (const QString &pkField, const QString &filename, const QString &table, QgsVectorLayer *vlayer)
 Constructor. More...
 
 QgsAuxiliaryLayer (const QgsAuxiliaryLayer &rhs)=delete
 Copy constructor deactivated. More...
 
bool addAuxiliaryField (const QgsPropertyDefinition &definition)
 Adds an auxiliary field for the given property. More...
 
QgsFields auxiliaryFields () const
 Returns a list of all auxiliary fields currently managed by the layer. More...
 
bool clear ()
 Deletes all features from the layer. More...
 
QgsAuxiliaryLayerclone (QgsVectorLayer *layer) const
 Returns a new instance equivalent to this one. More...
 
bool deleteAttribute (int attr) override
 Removes attribute from the layer and commits changes. More...
 
bool exists (const QgsPropertyDefinition &definition) const
 Returns true if the property is stored in the layer already, false otherwise. More...
 
int indexOfPropertyDefinition (const QgsPropertyDefinition &definition) const
 Returns the index of the auxiliary field for a specific property definition. More...
 
bool isHiddenProperty (int index) const
 Returns true if the underlying field has to be hidden from editing tools like attribute table, false otherwise. More...
 
QgsVectorLayerJoinInfo joinInfo () const
 Returns information to use for joining with primary key and so on. More...
 
QgsAuxiliaryLayeroperator= (QgsAuxiliaryLayer const &rhs)=delete
 
QgsPropertyDefinition propertyDefinitionFromIndex (int index) const
 Returns the property definition for the underlying field index. More...
 
int propertyFromIndex (int index) const
 Returns the underlying property key for the field index. More...
 
bool save ()
 Commits changes and starts editing then. More...
 
QgsVectorLayertoSpatialLayer () const
 An auxiliary layer is not spatial. More...
 
- Public Member Functions inherited from QgsVectorLayer
 QgsVectorLayer (const QString &path=QString(), const QString &baseName=QString(), const QString &providerLib="ogr", const QgsVectorLayer::LayerOptions &options=QgsVectorLayer::LayerOptions())
 Constructor - creates a vector layer. More...
 
 QgsVectorLayer (const QgsVectorLayer &rhs)=delete
 QgsVectorLayer cannot be copied. More...
 
 ~QgsVectorLayer () override
 
QgsActionManageractions ()
 Get all layer actions defined on this layer. More...
 
const QgsActionManageractions () const
 Get all layer actions defined on this layer. More...
 
bool addAttribute (const QgsField &field)
 Add an attribute field (but does not commit it) returns true if the field was added. More...
 
int addExpressionField (const QString &exp, const QgsField &fld)
 Add a new field which is calculated by the expression specified. More...
 
bool addFeature (QgsFeature &feature, QgsFeatureSink::Flags flags=nullptr) override
 Adds a single feature to the sink. More...
 
bool addFeatures (QgsFeatureList &features, QgsFeatureSink::Flags flags=nullptr) override
 Adds a list of features to the sink. More...
 
bool addJoin (const QgsVectorLayerJoinInfo &joinInfo)
 Joins another vector layer to this layer. More...
 
QgsGeometry::OperationResult addPart (const QList< QgsPointXY > &ring)
 Adds a new part polygon to a multipart feature. More...
 
QgsGeometry::OperationResult addPart (const QgsPointSequence &ring)
 Adds a new part polygon to a multipart feature. More...
 
QgsGeometry::OperationResult addPart (QgsCurve *ring)
 
QgsGeometry::OperationResult addRing (const QVector< QgsPointXY > &ring, QgsFeatureId *featureId=nullptr)
 Adds a ring to polygon/multipolygon features. More...
 
QgsGeometry::OperationResult addRing (QgsCurve *ring, QgsFeatureId *featureId=nullptr)
 Adds a ring to polygon/multipolygon features (takes ownership) More...
 
int addTopologicalPoints (const QgsGeometry &geom)
 Adds topological points for every vertex of the geometry. More...
 
int addTopologicalPoints (const QgsPointXY &p)
 Adds a vertex to segments which intersect point p but don't already have a vertex there. More...
 
QVariant aggregate (QgsAggregateCalculator::Aggregate aggregate, const QString &fieldOrExpression, const QgsAggregateCalculator::AggregateParameters &parameters=QgsAggregateCalculator::AggregateParameters(), QgsExpressionContext *context=nullptr, bool *ok=nullptr) const
 Calculates an aggregated value from the layer's features. More...
 
QString attributeAlias (int index) const
 Returns the alias of an attribute name or a null string if there is no alias. More...
 
QgsStringMap attributeAliases () const
 Returns a map of field name to attribute alias. More...
 
QString attributeDisplayName (int index) const
 Convenience function that returns the attribute alias if defined or the field name else. More...
 
QgsAttributeList attributeList () const
 Returns list of attribute indexes. More...
 
QgsAttributeTableConfig attributeTableConfig () const
 Get the attribute table configuration object. More...
 
QgsAuxiliaryLayerauxiliaryLayer ()
 Returns the current auxiliary layer. More...
 
const QgsAuxiliaryLayerauxiliaryLayer () const
 Returns the current const auxiliary layer. More...
 
void beginEditCommand (const QString &text)
 Create edit command for undo/redo operations. More...
 
QgsRectangle boundingBoxOfSelected () const
 Returns the bounding box of the selected features. If there is no selection, QgsRectangle(0,0,0,0) is returned. More...
 
QString capabilitiesString () const
 Capabilities for this layer, comma separated and translated. More...
 
bool changeAttributeValue (QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue=QVariant(), bool skipDefaultValues=false)
 Changes an attribute value for a feature (but does not immediately commit the changes). More...
 
bool changeAttributeValues (QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues=QgsAttributeMap(), bool skipDefaultValues=false)
 Changes attributes' values for a feature (but does not immediately commit the changes). More...
 
bool changeGeometry (QgsFeatureId fid, const QgsGeometry &geometry, bool skipDefaultValue=false)
 Changes a feature's geometry within the layer's edit buffer (but does not immediately commit the changes). More...
 
QgsVectorLayerclone () const override
 Returns a new instance equivalent to this one. More...
 
bool commitChanges ()
 Attempts to commit to the underlying data provider any buffered changes made since the last to call to startEditing(). More...
 
QStringList commitErrors () const
 Returns a list containing any error messages generated when attempting to commit changes to the layer. More...
 
QgsConditionalLayerStylesconditionalStyles () const
 Return the conditional styles that are set for this layer. More...
 
QString constraintDescription (int index) const
 Returns the descriptive name for the constraint expression for a specified field index. More...
 
QString constraintExpression (int index) const
 Returns the constraint expression for for a specified field index, if set. More...
 
QgsVectorLayerFeatureCountercountSymbolFeatures ()
 Count features for symbols. More...
 
QgsExpressionContext createExpressionContext () const override
 This method needs to be reimplemented in all classes which implement this interface and return an expression context. More...
 
QgsExpressionContextScopecreateExpressionContextScope () const override
 This method needs to be reimplemented in all classes which implement this interface and return an expression context scope. More...
 
QgsMapLayerRenderercreateMapRenderer (QgsRenderContext &rendererContext) override
 Return new instance of QgsMapLayerRenderer that will be used for rendering of given context. More...
 
QString dataComment () const
 Returns a description for this layer as defined in the data provider. More...
 
QgsVectorDataProviderdataProvider () override
 Returns the layer's data provider. More...
 
const QgsVectorDataProviderdataProvider () const override
 Returns the layer's data provider in a const-correct manner. More...
 
QVariant defaultValue (int index, const QgsFeature &feature=QgsFeature(), QgsExpressionContext *context=nullptr) const
 Returns the calculated default value for the specified field index. More...
 
QgsDefaultValue defaultValueDefinition (int index) const
 Returns the definition of the expression used when calculating the default value for a field. More...
 
bool deleteAttributes (QList< int > attrs)
 Deletes a list of attribute fields (but does not commit it) More...
 
bool deleteFeature (QgsFeatureId fid)
 Deletes a feature from the layer (but does not commit it). More...
 
bool deleteFeatures (const QgsFeatureIds &fids)
 Deletes a set of features from the layer (but does not commit it) More...
 
bool deleteSelectedFeatures (int *deletedCount=nullptr)
 Deletes the selected features. More...
 
virtual bool deleteStyleFromDatabase (const QString &styleId, QString &msgError)
 Delete a style from the database. More...
 
EditResult deleteVertex (QgsFeatureId featureId, int vertex)
 Deletes a vertex from a feature. More...
 
QSet< QgsMapLayerDependencydependencies () const override
 Gets the list of dependencies. More...
 
void destroyEditCommand ()
 Destroy active command and reverts all changes in it. More...
 
const QgsDiagramLayerSettingsdiagramLayerSettings () const
 
const QgsDiagramRendererdiagramRenderer () const
 
bool diagramsEnabled () const
 Returns whether the layer contains diagrams which are enabled and should be drawn. More...
 
QString displayExpression () const
 Get the preview expression, used to create a human readable preview string. More...
 
QString displayField () const
 This is a shorthand for accessing the displayExpression if it is a simple field. More...
 
QgsVectorLayerEditBuffereditBuffer ()
 Buffer with uncommitted editing operations. Only valid after editing has been turned on. More...
 
const QgsVectorLayerEditBuffereditBuffer () const
 Buffer with uncommitted editing operations. More...
 
QgsEditFormConfig editFormConfig () const
 Get the configuration of the form used to represent this vector layer. More...
 
QgsEditorWidgetSetup editorWidgetSetup (int index) const
 The editor widget setup defines which QgsFieldFormatter and editor widget will be used for the field at index. More...
 
void endEditCommand ()
 Finish edit command and add it to undo/redo stack. More...
 
QSet< QString > excludeAttributesWfs () const
 A set of attributes that are not advertised in WFS requests with QGIS server. More...
 
QSet< QString > excludeAttributesWms () const
 A set of attributes that are not advertised in WMS requests with QGIS server. More...
 
QString expressionField (int index) const
 Returns the expression used for a given expression field. More...
 
QgsRectangle extent () const override
 Returns the extent of the layer. More...
 
QPainter::CompositionMode featureBlendMode () const
 Returns the current blending mode for features. More...
 
long featureCount (const QString &legendKey) const
 Number of features rendered with specified legend key. More...
 
long featureCount () const override
 Returns feature count including changes which have not yet been committed If you need only the count of committed features call this method on this layer's provider. More...
 
QgsFieldConstraints::Constraints fieldConstraints (int fieldIndex) const
 Returns any constraints which are present for a specified field index. More...
 
QMap< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrengthfieldConstraintsAndStrength (int fieldIndex) const
 Returns a map of constraint with their strength for a specific field of the layer. More...
 
QgsFields fields () const override
 Returns the list of fields of this layer. More...
 
QgsWkbTypes::GeometryType geometryType () const
 Returns point, line or polygon. More...
 
QgsFeature getFeature (QgsFeatureId fid) const
 Query the layer for the feature with the given id. More...
 
QgsFeatureIterator getFeatures (const QgsFeatureRequest &request=QgsFeatureRequest()) const override
 Query the layer for features specified in request. More...
 
QgsFeatureIterator getFeatures (const QString &expression)
 Query the layer for features matching a given expression. More...
 
QgsFeatureIterator getFeatures (const QgsFeatureIds &fids)
 Query the layer for the features with the given ids. More...
 
QgsFeatureIterator getFeatures (const QgsRectangle &rectangle)
 Query the layer for the features which intersect the specified rectangle. More...
 
QgsFeatureIterator getSelectedFeatures (QgsFeatureRequest request=QgsFeatureRequest()) const
 Get an iterator of the selected features. More...
 
virtual QString getStyleFromDatabase (const QString &styleId, QString &msgError)
 Will return the named style corresponding to style id provided. More...
 
QString htmlMetadata () const override
 Obtain a formatted HTML string containing assorted metadata for this layer. More...
 
bool insertVertex (double x, double y, QgsFeatureId atFeatureId, int beforeVertex)
 Insert a new vertex before the given vertex number, in the given ring, item (first number is index 0), and feature Not meaningful for Point geometries. More...
 
bool insertVertex (const QgsPoint &point, QgsFeatureId atFeatureId, int beforeVertex)
 Insert a new vertex before the given vertex number, in the given ring, item (first number is index 0), and feature Not meaningful for Point geometries. More...
 
void invertSelection ()
 Select not selected features and deselect selected ones. More...
 
void invertSelectionInRectangle (QgsRectangle &rect)
 Invert selection of features found within the search rectangle (in layer's coordinates) More...
 
bool isAuxiliaryField (int index, int &srcIndex) const
 Returns true if the field comes from the auxiliary layer, false otherwise. More...
 
bool isEditable () const override
 Returns true if the provider is in editing mode. More...
 
bool isEditCommandActive () const
 Test if an edit command is active. More...
 
virtual bool isModified () const
 Returns true if the provider has been modified since the last commit. More...
 
bool isSpatial () const override
 Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeometry. More...
 
QgsVectorLayerJoinBufferjoinBuffer ()
 Accessor to the join buffer object. More...
 
const QgsAbstractVectorLayerLabelinglabeling () const
 Access to const labeling configuration. More...
 
QgsAbstractVectorLayerLabelinglabeling ()
 Access to labeling configuration. More...
 
bool labelsEnabled () const
 Returns whether the layer contains labels which are enabled and should be drawn. More...
 
virtual int listStylesInDatabase (QStringList &ids, QStringList &names, QStringList &descriptions, QString &msgError)
 Lists all the style in db split into related to the layer and not related to. More...
 
bool loadAuxiliaryLayer (const QgsAuxiliaryStorage &storage, const QString &key=QString())
 Loads the auxiliary layer for this vector layer. More...
 
virtual QString loadNamedStyle (const QString &theURI, bool &resultFlag, bool loadFromLocalDb)
 Load a named style from file/local db/datasource db. More...
 
QString loadNamedStyle (const QString &theURI, bool &resultFlag) override
 Calls loadNamedStyle( theURI, resultFlag, false ); Retained for backward compatibility. More...
 
QString mapTipTemplate () const
 The mapTip is a pretty, html representation for feature information. More...
 
QVariant maximumValue (int index) const override
 Returns the maximum value for an attribute column or an invalid variant in case of error. More...
 
QVariant minimumValue (int index) const override
 Returns the minimum value for an attribute column or an invalid variant in case of error. More...
 
void modifySelection (const QgsFeatureIds &selectIds, const QgsFeatureIds &deselectIds)
 Modifies the current selection on this layer. More...
 
bool moveVertex (double x, double y, QgsFeatureId atFeatureId, int atVertex)
 Moves the vertex at the given position number, ring and item (first number is index 0), and feature to the given coordinates. More...
 
bool moveVertex (const QgsPoint &p, QgsFeatureId atFeatureId, int atVertex)
 Moves the vertex at the given position number, ring and item (first number is index 0), and feature to the given coordinates. More...
 
double opacity () const
 Returns the opacity for the vector layer, where opacity is a value between 0 (totally transparent) and 1.0 (fully opaque). More...
 
QgsVectorLayeroperator= (QgsVectorLayer const &rhs)=delete
 QgsVectorLayer cannot be copied. More...
 
QgsAttributeList primaryKeyAttributes () const
 Returns the list of attributes which make up the layer's primary keys. More...
 
QString providerType () const
 Return the provider type for this layer. More...
 
bool readExtentFromXml () const
 Returns true if the extent is read from the XML document when data source has no metadata, false if it's the data provider which determines it. More...
 
bool readSld (const QDomNode &node, QString &errorMessage) override
 
bool readStyle (const QDomNode &node, QString &errorMessage, const QgsReadWriteContext &context) override
 Read the style for the current layer from the Dom node supplied. More...
 
bool readSymbology (const QDomNode &layerNode, QString &errorMessage, const QgsReadWriteContext &context) override
 Read the symbology for the current layer from the Dom node supplied. More...
 
bool readXml (const QDomNode &layer_node, const QgsReadWriteContext &context) override
 Reads vector layer specific state from project file Dom node. More...
 
QList< QgsRelationreferencingRelations (int idx) const
 Get relations, where the foreign key is on this layer. More...
 
void reload () override
 Synchronises with changes in the datasource. More...
 
void removeExpressionField (int index)
 Remove an expression field. More...
 
void removeFieldAlias (int index)
 Removes an alias (a display name) for attributes to display in dialogs. More...
 
void removeFieldConstraint (int index, QgsFieldConstraints::Constraint constraint)
 Removes a constraint for a specified field index. More...
 
bool removeJoin (const QString &joinLayerId)
 Removes a vector layer join. More...
 
bool renameAttribute (int index, const QString &newName)
 Renames an attribute field (but does not commit it). More...
 
QgsFeatureRendererrenderer ()
 Return renderer. More...
 
const QgsFeatureRendererrenderer () const
 Return const renderer. More...
 
void resolveReferences (QgsProject *project) override
 Resolve references to other layers (kept as layer IDs after reading XML) into layer objects. More...
 
bool rollBack (bool deleteBuffer=true)
 Stops a current editing operation and discards any uncommitted edits. More...
 
virtual void saveStyleToDatabase (const QString &name, const QString &description, bool useAsDefault, const QString &uiFileContent, QString &msgError)
 Save named and sld style of the layer to the style table in the db. More...
 
void selectAll ()
 Select all the features. More...
 
void selectByExpression (const QString &expression, SelectBehavior behavior=SetSelection)
 Select matching features using an expression. More...
 
void selectByIds (const QgsFeatureIds &ids, SelectBehavior behavior=SetSelection)
 Select matching features using a list of feature IDs. More...
 
void selectByRect (QgsRectangle &rect, SelectBehavior behavior=SetSelection)
 Select features found within the search rectangle (in layer's coordinates) More...
 
int selectedFeatureCount () const
 The number of features that are selected in this layer. More...
 
const QgsFeatureIdsselectedFeatureIds () const
 Return reference to identifiers of selected features. More...
 
QgsFeatureList selectedFeatures () const
 Get a copy of the user-selected features. More...
 
void setAttributeTableConfig (const QgsAttributeTableConfig &attributeTableConfig)
 Set the attribute table configuration object. More...
 
void setAuxiliaryLayer (QgsAuxiliaryLayer *layer=nullptr)
 Sets the current auxiliary layer. More...
 
void setConstraintExpression (int index, const QString &expression, const QString &description=QString())
 Set the constraint expression for the specified field index. More...
 
void setCoordinateSystem ()
 Setup the coordinate system transformation for the layer. More...
 
void setDataSource (const QString &dataSource, const QString &baseName, const QString &provider, bool loadDefaultStyleFlag=false)
 Update the data source of the layer. More...
 
void setDefaultValueDefinition (int index, const QgsDefaultValue &definition)
 Sets the definition of the expression to use when calculating the default value for a field. More...
 
bool setDependencies (const QSet< QgsMapLayerDependency > &layers) override
 Sets the list of dependencies. More...
 
void setDiagramLayerSettings (const QgsDiagramLayerSettings &s)
 
void setDiagramRenderer (QgsDiagramRenderer *r)
 Sets diagram rendering object (takes ownership) More...
 
void setDisplayExpression (const QString &displayExpression)
 Set the preview expression, used to create a human readable preview string. More...
 
void setEditFormConfig (const QgsEditFormConfig &editFormConfig)
 Get the configuration of the form used to represent this vector layer. More...
 
void setEditorWidgetSetup (int index, const QgsEditorWidgetSetup &setup)
 The editor widget setup defines which QgsFieldFormatter and editor widget will be used for the field at index. More...
 
void setExcludeAttributesWfs (const QSet< QString > &att)
 A set of attributes that are not advertised in WFS requests with QGIS server. More...
 
void setExcludeAttributesWms (const QSet< QString > &att)
 A set of attributes that are not advertised in WMS requests with QGIS server. More...
 
void setFeatureBlendMode (QPainter::CompositionMode blendMode)
 Set the blending mode used for rendering each feature. More...
 
void setFieldAlias (int index, const QString &aliasString)
 Sets an alias (a display name) for attributes to display in dialogs. More...
 
void setFieldConstraint (int index, QgsFieldConstraints::Constraint constraint, QgsFieldConstraints::ConstraintStrength strength=QgsFieldConstraints::ConstraintStrengthHard)
 Sets a constraint for a specified field index. More...
 
void setLabeling (QgsAbstractVectorLayerLabeling *labeling)
 Set labeling configuration. More...
 
void setLabelsEnabled (bool enabled)
 Sets whether labels should be enabled for the layer. More...
 
void setMapTipTemplate (const QString &mapTipTemplate)
 The mapTip is a pretty, html representation for feature information. More...
 
void setOpacity (double opacity)
 Sets the opacity for the vector layer, where opacity is a value between 0 (totally transparent) and 1.0 (fully opaque). More...
 
void setProviderEncoding (const QString &encoding)
 Sets the textencoding of the data provider. More...
 
void setReadExtentFromXml (bool readExtentFromXml)
 Flag allowing to indicate if the extent has to be read from the XML document when data source has no metadata or if the data provider has to determine it. More...
 
bool setReadOnly (bool readonly=true)
 Make layer read-only (editing disabled) or not. More...
 
void setRenderer (QgsFeatureRenderer *r)
 Set renderer which will be invoked to represent this layer. More...
 
void setSimplifyMethod (const QgsVectorSimplifyMethod &simplifyMethod)
 Set the simplification settings for fast rendering of features. More...
 
virtual bool setSubsetString (const QString &subset)
 Set the string (typically sql) used to define a subset of the layer. More...
 
bool simplifyDrawingCanbeApplied (const QgsRenderContext &renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint) const
 Returns whether the VectorLayer can apply the specified simplification hint. More...
 
const QgsVectorSimplifyMethodsimplifyMethod () const
 Returns the simplification settings for fast rendering of features. More...
 
QgsCoordinateReferenceSystem sourceCrs () const override
 Returns the coordinate reference system for features in the source. More...
 
QgsRectangle sourceExtent () const override
 Returns the extent of all geometries from the source. More...
 
QString sourceName () const override
 Returns a friendly display name for the source. More...
 
QgsGeometry::OperationResult splitFeatures (const QVector< QgsPointXY > &splitLine, bool topologicalEditing=false)
 Splits features cut by the given line. More...
 
QgsGeometry::OperationResult splitParts (const QVector< QgsPointXY > &splitLine, bool topologicalEditing=false)
 Splits parts cut by the given line. More...
 
QString storageType () const
 Returns the permanent storage type for this layer as a friendly name. More...
 
virtual QString subsetString () const
 Get the string (typically sql) used to define a subset of the layer. More...
 
int translateFeature (QgsFeatureId featureId, double dx, double dy)
 Translates feature by dx, dy. More...
 
QStringList uniqueStringsMatching (int index, const QString &substring, int limit=-1, QgsFeedback *feedback=nullptr) const
 Returns unique string values of an attribute which contain a specified subset string. More...
 
QSet< QVariant > uniqueValues (int fieldIndex, int limit=-1) const override
 Calculates a list of unique values contained within an attribute in the layer. More...
 
void updateExpressionField (int index, const QString &exp)
 Changes the expression used to define an expression based (virtual) field. More...
 
bool updateFeature (const QgsFeature &feature, bool skipDefaultValues=false)
 Updates an existing feature in the layer, replacing the attributes and geometry for the feature with matching QgsFeature::id() with the attributes and geometry from feature. More...
 
void updateFields ()
 Will regenerate the fields property of this layer by obtaining all fields from the dataProvider, joined fields and virtual fields. More...
 
const QList< QgsVectorLayerJoinInfovectorJoins () const
 
QgsWkbTypes::Type wkbType () const override
 Returns the WKBType or WKBUnknown in case of error. More...
 
bool writeSld (QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsStringMap &props=QgsStringMap()) const
 Writes the symbology of the layer into the document provided in SLD 1.1 format. More...
 
bool writeStyle (QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context) const override
 Write just the style information for the layer into the document. More...
 
bool writeSymbology (QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context) const override
 Write the symbology for the layer into the docment provided. More...
 
bool writeXml (QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context) const override
 Write vector layer specific state to project file Dom node. More...
 
- Public Member Functions inherited from QgsMapLayer
 QgsMapLayer (QgsMapLayer::LayerType type=VectorLayer, const QString &name=QString(), const QString &source=QString())
 Constructor for QgsMapLayer. More...
 
 QgsMapLayer (QgsMapLayer const &)=delete
 QgsMapLayer cannot be copied. More...
 
 ~QgsMapLayer () override
 
QString abstract () const
 Returns the abstract of the layer used by QGIS Server in GetCapabilities request. More...
 
QString attribution () const
 Returns the attribution of the layer used by QGIS Server in GetCapabilities request. More...
 
QString attributionUrl () const
 Returns the attribution URL of the layer used by QGIS Server in GetCapabilities request. More...
 
int autoRefreshInterval () const
 Returns the auto refresh interval (in milliseconds). More...
 
QPainter::CompositionMode blendMode () const
 Returns the current blending mode for a layer. More...
 
QgsCoordinateReferenceSystem crs () const
 Returns the layer's spatial reference system. More...
 
QVariant customProperty (const QString &value, const QVariant &defaultValue=QVariant()) const
 Read a custom property from layer. More...
 
QStringList customPropertyKeys () const
 Returns list of all keys within custom properties. More...
 
QString dataUrl () const
 Returns the DataUrl of the layer used by QGIS Server in GetCapabilities request. More...
 
QString dataUrlFormat () const
 Returns the DataUrl format of the layer used by QGIS Server in GetCapabilities request. More...
 
virtual QgsError error () const
 Get current status error. More...
 
void exportNamedMetadata (QDomDocument &doc, QString &errorMsg) const
 Export the current metadata of this layer as named metadata in a QDomDocument. More...
 
virtual void exportNamedStyle (QDomDocument &doc, QString &errorMsg) const
 Export the properties of this layer as named style in a QDomDocument. More...
 
virtual void exportSldStyle (QDomDocument &doc, QString &errorMsg) const
 Export the properties of this layer as SLD style in a QDomDocument. More...
 
bool hasAutoRefreshEnabled () const
 Returns true if auto refresh is enabled for the layer. More...
 
bool hasScaleBasedVisibility () const
 Returns whether scale based visibility is enabled for the layer. More...
 
QString id () const
 Returns the layer's unique ID, which is used to access this layer from QgsProject. More...
 
bool importNamedMetadata (QDomDocument &document, QString &errorMessage)
 Import the metadata of this layer from a QDomDocument. More...
 
virtual bool importNamedStyle (QDomDocument &doc, QString &errorMsg)
 Import the properties of this layer from a QDomDocument. More...
 
bool isInScaleRange (double scale) const
 Tests whether the layer should be visible at the specified scale. More...
 
bool isRefreshOnNotifyEnabled () const
 Returns true if the refresh on provider nofification is enabled. More...
 
bool isValid () const
 Return the status of the layer. More...
 
QString keywordList () const
 Returns the keyword list of the layer used by QGIS Server in GetCapabilities request. More...
 
QgsMapLayerLegendlegend () const
 Can be null. More...
 
QString legendUrl () const
 Returns the URL for the layer's legend. More...
 
QString legendUrlFormat () const
 Returns the format for a URL based layer legend. More...
 
QString loadDefaultMetadata (bool &resultFlag)
 Retrieve the default metadata for this layer if one exists (either as a .qmd file on disk or as a record in the users metadata table in their personal qgis.db) More...
 
virtual QString loadDefaultStyle (bool &resultFlag)
 Retrieve the default style for this layer if one exists (either as a .qml file on disk or as a record in the users style table in their personal qgis.db) More...
 
virtual QString loadNamedMetadata (const QString &uri, bool &resultFlag)
 Retrieve a named metadata for this layer if one exists (either as a .qmd file on disk or as a record in the users style table in their personal qgis.db) More...
 
bool loadNamedMetadataFromDatabase (const QString &db, const QString &uri, QString &qmd)
 Retrieve a named metadata for this layer from a sqlite database. More...
 
virtual bool loadNamedStyleFromDatabase (const QString &db, const QString &uri, QString &qml)
 Retrieve a named style for this layer from a sqlite database. More...
 
virtual QString loadSldStyle (const QString &uri, bool &resultFlag)
 Attempts to style the layer using the formatting from an SLD type file. More...
 
double maximumScale () const
 Returns the maximum map scale (i.e. More...
 
virtual const QgsLayerMetadatametadata () const
 Returns a reference to the layer's metadata store. More...
 
virtual QString metadataUri () const
 Retrieve the metadata URI for this layer (either as a .qmd file on disk or as a record in the users style table in their personal qgis.db) More...
 
QString metadataUrl () const
 Returns the metadata URL of the layer used by QGIS Server in GetCapabilities request. More...
 
QString metadataUrlFormat () const
 Returns the metadata format of the layer used by QGIS Server in GetCapabilities request. More...
 
QString metadataUrlType () const
 Returns the metadata type of the layer used by QGIS Server in GetCapabilities request. More...
 
double minimumScale () const
 Returns the minimum map scale (i.e. More...
 
QString name () const
 Returns the display name of the layer. More...
 
QgsMapLayeroperator= (QgsMapLayer const &)=delete
 QgsMapLayer cannot be copied. More...
 
QString publicSource () const
 Gets a version of the internal layer definition that has sensitive bits removed (for example, the password). More...
 
bool readLayerXml (const QDomElement &layerElement, const QgsReadWriteContext &context)
 Sets state from Dom document. More...
 
bool readOnly () const
 Returns if this layer is read only. More...
 
QString refreshOnNotifyMessage () const
 Returns the message that should be notified by the provider to triggerRepaint. More...
 
void removeCustomProperty (const QString &key)
 Remove a custom property from layer. More...
 
QgsAbstract3DRendererrenderer3D () const
 Returns 3D renderer associated with the layer. More...
 
virtual QString saveDefaultMetadata (bool &resultFlag)
 Save the current metadata of this layer as the default metadata (either as a .qmd file on disk or as a record in the users style table in their personal qgis.db) More...
 
virtual QString saveDefaultStyle (bool &resultFlag)
 Save the properties of this layer as the default style (either as a .qml file on disk or as a record in the users style table in their personal qgis.db) More...
 
QString saveNamedMetadata (const QString &uri, bool &resultFlag)
 Save the current metadata of this layer as a named metadata (either as a .qmd file on disk or as a record in the users style table in their personal qgis.db) More...
 
virtual QString saveNamedStyle (const QString &uri, bool &resultFlag)
 Save the properties of this layer as a named style (either as a .qml file on disk or as a record in the users style table in their personal qgis.db) More...
 
virtual QString saveSldStyle (const QString &uri, bool &resultFlag) const
 Saves the properties of this layer to an SLD format file. More...
 
void setAbstract (const QString &abstract)
 Sets the abstract of the layer used by QGIS Server in GetCapabilities request. More...
 
void setAttribution (const QString &attrib)
 Sets the attribution of the layer used by QGIS Server in GetCapabilities request. More...
 
void setAttributionUrl (const QString &attribUrl)
 Sets the attribution URL of the layer used by QGIS Server in GetCapabilities request. More...
 
void setAutoRefreshEnabled (bool enabled)
 Sets whether auto refresh is enabled for the layer. More...
 
void setAutoRefreshInterval (int interval)
 Sets the auto refresh interval (in milliseconds) for the layer. More...
 
void setBlendMode (QPainter::CompositionMode blendMode)
 Set the blending mode used for rendering a layer. More...
 
void setCrs (const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
 Sets layer's spatial reference system. More...
 
void setCustomProperties (const QgsObjectCustomProperties &properties)
 Set custom properties for layer. More...
 
void setCustomProperty (const QString &key, const QVariant &value)
 Set a custom property for layer. More...
 
void setDataUrl (const QString &dataUrl)
 Sets the DataUrl of the layer used by QGIS Server in GetCapabilities request. More...
 
void setDataUrlFormat (const QString &dataUrlFormat)
 Sets the DataUrl format of the layer used by QGIS Server in GetCapabilities request. More...
 
void setKeywordList (const QString &keywords)
 Sets the keyword list of the layer used by QGIS Server in GetCapabilities request. More...
 
virtual void setLayerOrder (const QStringList &layers)
 Reorders the previously selected sublayers of this layer from bottom to top. More...
 
void setLegend (QgsMapLayerLegend *legend)
 Assign a legend controller to the map layer. More...
 
void setLegendUrl (const QString &legendUrl)
 Sets the URL for the layer's legend. More...
 
void setLegendUrlFormat (const QString &legendUrlFormat)
 Sets the format for a URL based layer legend. More...
 
virtual void setMetadata (const QgsLayerMetadata &metadata)
 Sets the layer's metadata store. More...
 
void setMetadataUrl (const QString &metaUrl)
 Sets the metadata URL of the layer used by QGIS Server in GetCapabilities request. More...
 
void setMetadataUrlFormat (const QString &metaUrlFormat)
 Sets the metadata format of the layer used by QGIS Server in GetCapabilities request. More...
 
void setMetadataUrlType (const QString &metaUrlType)
 Set the metadata type of the layer used by QGIS Server in GetCapabilities request MetadataUrlType indicates the standard to which the metadata complies. More...
 
void setName (const QString &name)
 Set the display name of the layer. More...
 
void setRenderer3D (QgsAbstract3DRenderer *renderer)
 Sets 3D renderer for the layer. More...
 
void setShortName (const QString &shortName)
 Sets the short name of the layer used by QGIS Server to identify the layer. More...
 
virtual void setSubLayerVisibility (const QString &name, bool visible)
 Set the visibility of the given sublayer name. More...
 
void setTitle (const QString &title)
 Sets the title of the layer used by QGIS Server in GetCapabilities request. More...
 
QString shortName () const
 Returns the short name of the layer used by QGIS Server to identify the layer. More...
 
QString source () const
 Returns the source for the layer. More...
 
QgsMapLayerStyleManagerstyleManager () const
 Get access to the layer's style manager. More...
 
virtual QString styleURI () const
 Retrieve the style URI for this layer (either as a .qml file on disk or as a record in the users style table in their personal qgis.db) More...
 
virtual QStringList subLayers () const
 Returns the sublayers of this layer. More...
 
virtual QDateTime timestamp () const
 Time stamp of data source in the moment when data/metadata were loaded by provider. More...
 
QString title () const
 Returns the title of the layer used by QGIS Server in GetCapabilities request. More...
 
QgsMapLayer::LayerType type () const
 Returns the type of the layer. More...
 
QUndoStack * undoStack ()
 Return pointer to layer's undo stack. More...
 
QUndoStack * undoStackStyles ()
 Return pointer to layer's style undo stack. More...
 
bool writeLayerXml (QDomElement &layerElement, QDomDocument &document, const QgsReadWriteContext &context) const
 Stores state in Dom node. More...
 
- Public Member Functions inherited from QgsExpressionContextGenerator
virtual ~QgsExpressionContextGenerator ()=default
 
- Public Member Functions inherited from QgsExpressionContextScopeGenerator
virtual ~QgsExpressionContextScopeGenerator ()=default
 
- Public Member Functions inherited from QgsFeatureSink
virtual ~QgsFeatureSink ()=default
 
virtual bool addFeatures (QgsFeatureIterator &iterator, QgsFeatureSink::Flags flags=nullptr)
 Adds all features from the specified iterator to the sink. More...
 
virtual bool flushBuffer ()
 Flushes any internal buffer which may exist in the sink, causing any buffered features to be added to the sink's destination. More...
 
- Public Member Functions inherited from QgsFeatureSource
virtual ~QgsFeatureSource ()=default
 
virtual QgsFeatureIds allFeatureIds () const
 Returns a list of all feature IDs for features present in the source. More...
 
QgsVectorLayermaterialize (const QgsFeatureRequest &request, QgsFeedback *feedback=nullptr)
 Materializes a request (query) made against this feature source, by running it over the source and returning a new memory based vector layer containing the result. More...
 

Static Public Member Functions

static QgsField createAuxiliaryField (const QgsPropertyDefinition &definition)
 Creates a new auxiliary field from a property definition. More...
 
static QgsField createAuxiliaryField (const QgsField &field)
 Creates a new auxiliary field from a field. More...
 
static int createProperty (QgsPalLayerSettings::Property property, QgsVectorLayer *vlayer)
 Creates if necessary a new auxiliary field for a PAL property and activates this property in settings. More...
 
static int createProperty (QgsDiagramLayerSettings::Property property, QgsVectorLayer *vlayer)
 Creates if necessary a new auxiliary field for a diagram's property and activates this property in settings. More...
 
static QString nameFromProperty (const QgsPropertyDefinition &def, bool joined=false)
 Returns the name of the auxiliary field for a property definition. More...
 
static QgsPropertyDefinition propertyDefinitionFromField (const QgsField &field)
 Returns the property definition from an auxiliary field. More...
 
- Static Public Member Functions inherited from QgsVectorLayer
static void drawVertexMarker (double x, double y, QPainter &p, QgsVectorLayer::VertexMarkerType type, int vertexSize)
 Draws a vertex symbol at (screen) coordinates x, y. (Useful to assist vertex editing.) More...
 
- Static Public Member Functions inherited from QgsMapLayer
static QString extensionPropertyType (PropertyType type)
 Returns the extension of a Property. More...
 
static QString formatLayerName (const QString &name)
 A convenience function to capitalize and format a layer name. More...
 

Additional Inherited Members

- Public Types inherited from QgsVectorLayer
enum  EditResult {
  Success = 0, EmptyGeometry = 1, EditFailed = 2, FetchFeatureFailed = 3,
  InvalidLayer = 4
}
 Result of an edit operation. More...
 
enum  SelectBehavior { SetSelection, AddToSelection, IntersectSelection, RemoveFromSelection }
 Selection behavior. More...
 
enum  VertexMarkerType { SemiTransparentCircle, Cross, NoMarker }
 Editing vertex markers. More...
 
- Public Types inherited from QgsMapLayer
enum  LayerType { VectorLayer, RasterLayer, PluginLayer }
 Types of layers that can be added to a map. More...
 
enum  PropertyType { Style = 0, Metadata }
 Maplayer has a style and a metadata property. More...
 
- Public Types inherited from QgsFeatureSink
enum  Flag { FastInsert = 1 << 1 }
 Flags controlling how features are added to a sink. More...
 
- Public Slots inherited from QgsVectorLayer
void deselect (const QgsFeatureId featureId)
 Deselect feature by its ID. More...
 
void deselect (const QgsFeatureIds &featureIds)
 Deselect features by their ID. More...
 
void removeSelection ()
 Clear selection. More...
 
void select (QgsFeatureId featureId)
 Select feature by its ID. More...
 
void select (const QgsFeatureIds &featureIds)
 Select features by their ID. More...
 
bool startEditing ()
 Makes the layer editable. More...
 
virtual void updateExtents (bool force=false)
 Update the extents for the layer. More...
 
- Public Slots inherited from QgsMapLayer
void emitStyleChanged ()
 Triggers an emission of the styleChanged() signal. More...
 
void setMaximumScale (double scale)
 Sets the maximum map scale (i.e. More...
 
void setMinimumScale (double scale)
 Sets the minimum map scale (i.e. More...
 
void setRefreshOnNofifyMessage (const QString &message)
 Set the notification message that triggers repaine If refresh on notification is enabled, the notification will triggerRepaint only if the notification message is equal to. More...
 
void setRefreshOnNotifyEnabled (bool enabled)
 Set whether provider notification is connected to triggerRepaint. More...
 
void setScaleBasedVisibility (const bool enabled)
 Sets whether scale based visibility is enabled for the layer. More...
 
void triggerRepaint (bool deferredUpdate=false)
 Will advise the map canvas (and any other interested party) that this layer requires to be repainted. More...
 
- Signals inherited from QgsVectorLayer
void attributeAdded (int idx)
 Will be emitted, when a new attribute has been added to this vector layer. More...
 
void attributeDeleted (int idx)
 Will be emitted, when an attribute has been deleted from this vector layer. More...
 
void attributeValueChanged (QgsFeatureId fid, int idx, const QVariant &value)
 Is emitted whenever an attribute value change is done in the edit buffer. More...
 
void beforeAddingExpressionField (const QString &fieldName)
 Will be emitted, when an expression field is going to be added to this vector layer. More...
 
void beforeCommitChanges ()
 Is emitted, before changes are committed to the data provider. More...
 
void beforeEditingStarted ()
 Is emitted, before editing on this layer is started. More...
 
void beforeModifiedCheck () const
 Is emitted, when layer is checked for modifications. Use for last-minute additions. More...
 
void beforeRemovingExpressionField (int idx)
 Will be emitted, when an expression field is going to be deleted from this vector layer. More...
 
void beforeRollBack ()
 Is emitted, before changes are rolled back. More...
 
void committedAttributesAdded (const QString &layerId, const QList< QgsField > &addedAttributes)
 This signal is emitted, when attributes are added to the provider. More...
 
void committedAttributesDeleted (const QString &layerId, const QgsAttributeList &deletedAttributes)
 This signal is emitted, when attributes are deleted from the provider. More...
 
void committedAttributeValuesChanges (const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues)
 This signal is emitted, when attribute value changes are saved to the provider. More...
 
void committedFeaturesAdded (const QString &layerId, const QgsFeatureList &addedFeatures)
 This signal is emitted, when features are added to the provider. More...
 
void committedFeaturesRemoved (const QString &layerId, const QgsFeatureIds &deletedFeatureIds)
 This signal is emitted, when features are deleted from the provider. More...
 
void committedGeometriesChanges (const QString &layerId, const QgsGeometryMap &changedGeometries)
 This signal is emitted, when geometry changes are saved to the provider. More...
 
void displayExpressionChanged ()
 Emitted when the display expression changes. More...
 
void editCommandDestroyed ()
 Signal emitted, whan an edit command is destroyed. More...
 
void editCommandEnded ()
 Signal emitted, when an edit command successfully ended. More...
 
void editCommandStarted (const QString &text)
 Signal emitted when a new edit command has been started. More...
 
void editFormConfigChanged ()
 Will be emitted whenever the edit form configuration of this layer changes. More...
 
void editingStarted ()
 Is emitted, when editing on this layer has started. More...
 
void editingStopped ()
 Is emitted, when edited changes successfully have been written to the data provider. More...
 
void featureAdded (QgsFeatureId fid)
 Emitted when a new feature has been added to the layer. More...
 
void featureBlendModeChanged (QPainter::CompositionMode blendMode)
 Signal emitted when setFeatureBlendMode() is called. More...
 
void featureDeleted (QgsFeatureId fid)
 Emitted when a feature has been deleted. More...
 
void featuresDeleted (const QgsFeatureIds &fids)
 Emitted when features have been deleted. More...
 
void geometryChanged (QgsFeatureId fid, const QgsGeometry &geometry)
 Is emitted whenever a geometry change is done in the edit buffer. More...
 
void labelingFontNotFound (QgsVectorLayer *layer, const QString &fontfamily)
 Emitted when the font family defined for labeling layer is not found on system. More...
 
void layerModified ()
 This signal is emitted when modifications has been done on layer. More...
 
void mapTipTemplateChanged ()
 Emitted when the map tip changes. More...
 
void opacityChanged (double opacity)
 Emitted when the layer's opacity is changed, where opacity is a value between 0 (transparent) and 1 (opaque). More...
 
void raiseError (const QString &msg)
 Signals an error related to this vector layer. More...
 
void readCustomSymbology (const QDomElement &element, QString &errorMessage)
 Signal emitted whenever the symbology (QML-file) for this layer is being read. More...
 
void readOnlyChanged ()
 Emitted when the read only state of this layer is changed. More...
 
void selectionChanged (const QgsFeatureIds &selected, const QgsFeatureIds &deselected, const bool clearAndSelect)
 This signal is emitted when selection was changed. More...
 
void symbolFeatureCountMapChanged ()
 Emitted when the feature count for symbols on this layer has been recalculated. More...
 
void updatedFields ()
 Is emitted, whenever the fields available from this layer have been changed. More...
 
void writeCustomSymbology (QDomElement &element, QDomDocument &doc, QString &errorMessage) const
 Signal emitted whenever the symbology (QML-file) for this layer is being written. More...
 
- Signals inherited from QgsMapLayer
void autoRefreshIntervalChanged (int interval)
 Emitted when the auto refresh interval changes. More...
 
void blendModeChanged (QPainter::CompositionMode blendMode)
 Signal emitted when the blend mode is changed, through QgsMapLayer::setBlendMode() More...
 
void configChanged ()
 Emitted whenever the configuration is changed. More...
 
void crsChanged ()
 Emit a signal that layer's CRS has been reset. More...
 
void dataChanged ()
 Data of layer changed. More...
 
void dependenciesChanged ()
 Emitted when dependencies are changed. More...
 
void legendChanged ()
 Signal emitted when legend of the layer has changed. More...
 
void metadataChanged ()
 Emitted when the layer's metadata is changed. More...
 
void nameChanged ()
 Emitted when the name has been changed. More...
 
void recalculateExtents () const
 This is used to send a request that any mapcanvas using this layer update its extents. More...
 
void renderer3DChanged ()
 Signal emitted when 3D renderer associated with the layer has changed. More...
 
void rendererChanged ()
 Signal emitted when renderer is changed. More...
 
void repaintRequested (bool deferredUpdate=false)
 By emitting this signal the layer tells that either appearance or content have been changed and any view showing the rendered layer should refresh itself. More...
 
void statusChanged (const QString &status)
 Emit a signal with status (e.g. to be caught by QgisApp and display a msg on status bar) More...
 
void styleChanged ()
 Signal emitted whenever a change affects the layer's style. More...
 
void willBeDeleted ()
 Emitted in the destructor when the layer is about to be deleted, but it is still in a perfectly valid state: the last chance for other pieces of code for some cleanup if they use the layer. More...
 
- Protected Member Functions inherited from QgsVectorLayer
void setExtent (const QgsRectangle &rect) override
 Set the extent. More...
 
- Protected Member Functions inherited from QgsMapLayer
void appendError (const QgsErrorMessage &error)
 Add error message. More...
 
void clone (QgsMapLayer *layer) const
 Copies attributes like name, short name, ... More...
 
bool hasDependencyCycle (const QSet< QgsMapLayerDependency > &layers) const
 Checks whether a new set of dependencies will introduce a cycle. More...
 
void readCommonStyle (const QDomElement &layerElement, const QgsReadWriteContext &context)
 Read style data common to all layer types. More...
 
void readCustomProperties (const QDomNode &layerNode, const QString &keyStartsWith=QString())
 Read custom properties from project file. More...
 
void readStyleManager (const QDomNode &layerNode)
 Read style manager's configuration (if any). To be called by subclasses. More...
 
void setError (const QgsError &error)
 Set error message. More...
 
void setValid (bool valid)
 Set whether layer is valid or not - should be used in constructor. More...
 
void writeCommonStyle (QDomElement &layerElement, QDomDocument &document, const QgsReadWriteContext &context) const
 Write style data common to all layer types. More...
 
void writeCustomProperties (QDomNode &layerNode, QDomDocument &doc) const
 Write custom properties to project file. More...
 
void writeStyleManager (QDomNode &layerNode, QDomDocument &doc) const
 Write style manager's configuration (if exists). To be called by subclasses. More...
 
- Protected Attributes inherited from QgsMapLayer
QString mAbstract
 Description of the layer. More...
 
QString mAttribution
 Attribution of the layer. More...
 
QString mAttributionUrl
 
QString mDataSource
 Data source description string, varies by layer type. More...
 
QString mDataUrl
 DataUrl of the layer. More...
 
QString mDataUrlFormat
 
QSet< QgsMapLayerDependencymDependencies
 List of layers that may modify this layer on modification. More...
 
QgsError mError
 Error. More...
 
QgsRectangle mExtent
 Extent of the layer. More...
 
bool mIsRefreshOnNofifyEnabled = false
 
QString mKeywordList
 
QString mLayerName
 Name of the layer - used for display. More...
 
QString mLegendUrl
 WMS legend. More...
 
QString mLegendUrlFormat
 
QString mMetadataUrl
 MetadataUrl of the layer. More...
 
QString mMetadataUrlFormat
 
QString mMetadataUrlType
 
QString mRefreshOnNofifyMessage
 
QString mShortName
 
QString mTitle
 
bool mValid = false
 Indicates if the layer is valid and can be drawn. More...
 
- Properties inherited from QgsVectorLayer
QString displayExpression
 
QgsEditFormConfig editFormConfig
 
QString mapTipTemplate
 
double opacity
 
bool readOnly
 
- Properties inherited from QgsMapLayer
int autoRefreshInterval
 
QgsLayerMetadata metadata
 
QString name
 

Detailed Description

Class allowing to manage the auxiliary storage for a vector layer.

Such auxiliary data are data used mostly for the needs of QGIS (symbology) and have no real interest in being stored with the native raw geospatial data.

The need arises from the restrictions existing in the manual placement of labels. Manual placement of labels are possible in QGIS by setting some labeling properties (X and Y position, and rotation angle optionally) as being "data-defined", meaning that values come from a column (or an expression). But setting this up on an existing layer requires either to add new columns to the source layer, while it is not always possible or desirable.

This QgsAuxiliaryLayer provides the solution to this limitation. Actually it's an editable join to the original vector layer with some synchronisation mechanisms activated such as "Upsert On Edit" or "Delete Cascade". Thus, auxiliary fields are editable even if the source layer is not and edition of a joined field is also possible.

Since
QGIS 3.0

Definition at line 59 of file qgsauxiliarystorage.h.

Constructor & Destructor Documentation

◆ QgsAuxiliaryLayer() [1/2]

QgsAuxiliaryLayer::QgsAuxiliaryLayer ( const QString &  pkField,
const QString &  filename,
const QString &  table,
QgsVectorLayer vlayer 
)

Constructor.

Parameters
pkFieldThe primary key to use for joining
filenameThe database path
tableThe table name
vlayerThe target vector layer in join definition

Definition at line 63 of file qgsauxiliarystorage.cpp.

◆ QgsAuxiliaryLayer() [2/2]

QgsAuxiliaryLayer::QgsAuxiliaryLayer ( const QgsAuxiliaryLayer rhs)
delete

Copy constructor deactivated.

Member Function Documentation

◆ addAuxiliaryField()

bool QgsAuxiliaryLayer::addAuxiliaryField ( const QgsPropertyDefinition definition)

Adds an auxiliary field for the given property.

Setup for widget editors are updated in the target layer as well as the attribute table config to hide auxiliary fields by default.

Parameters
definitionThe definition of the property to add
Returns
true if the auxiliary field is well added, false otherwise

Definition at line 135 of file qgsauxiliarystorage.cpp.

◆ auxiliaryFields()

QgsFields QgsAuxiliaryLayer::auxiliaryFields ( ) const

Returns a list of all auxiliary fields currently managed by the layer.

Definition at line 187 of file qgsauxiliarystorage.cpp.

◆ clear()

bool QgsAuxiliaryLayer::clear ( )

Deletes all features from the layer.

Changes are automatically committed and the layer remains editable.

Returns
true if changes are committed without error, false otherwise.

Definition at line 86 of file qgsauxiliarystorage.cpp.

◆ clone()

QgsAuxiliaryLayer * QgsAuxiliaryLayer::clone ( QgsVectorLayer layer) const

Returns a new instance equivalent to this one.

The underlying table is duplicate for the layer given in parameter. Note that the current auxiliary layer should be saved to have a proper duplicated table.

Parameters
layerThe layer for which the clone is made

Definition at line 80 of file qgsauxiliarystorage.cpp.

◆ createAuxiliaryField() [1/2]

QgsField QgsAuxiliaryLayer::createAuxiliaryField ( const QgsPropertyDefinition definition)
static

Creates a new auxiliary field from a property definition.

Parameters
definitionThe property definition of the auxiliary field to create

Definition at line 380 of file qgsauxiliarystorage.cpp.

◆ createAuxiliaryField() [2/2]

QgsField QgsAuxiliaryLayer::createAuxiliaryField ( const QgsField field)
static

Creates a new auxiliary field from a field.

Parameters
fieldThe field to use to create the auxiliary field

Definition at line 483 of file qgsauxiliarystorage.cpp.

◆ createProperty() [1/2]

int QgsAuxiliaryLayer::createProperty ( QgsPalLayerSettings::Property  property,
QgsVectorLayer vlayer 
)
static

Creates if necessary a new auxiliary field for a PAL property and activates this property in settings.

Parameters
propertyThe property to create
vlayerThe vector layer
Returns
The index of the auxiliary field or -1

Definition at line 219 of file qgsauxiliarystorage.cpp.

◆ createProperty() [2/2]

int QgsAuxiliaryLayer::createProperty ( QgsDiagramLayerSettings::Property  property,
QgsVectorLayer vlayer 
)
static

Creates if necessary a new auxiliary field for a diagram's property and activates this property in settings.

Parameters
propertyThe property to create
vlayerThe vector layer
Returns
The index of the auxiliary field or -1

Definition at line 256 of file qgsauxiliarystorage.cpp.

◆ deleteAttribute()

bool QgsAuxiliaryLayer::deleteAttribute ( int  attr)
overridevirtual

Removes attribute from the layer and commits changes.

The layer remains editable.

Parameters
attrThe index of the attribute to remove
Returns
true if the attribute is well deleted, false otherwise

Reimplemented from QgsVectorLayer.

Definition at line 197 of file qgsauxiliarystorage.cpp.

◆ exists()

bool QgsAuxiliaryLayer::exists ( const QgsPropertyDefinition definition) const

Returns true if the property is stored in the layer already, false otherwise.

Parameters
definitionThe property definition to check
Returns
true if the property is stored, false otherwise

Definition at line 130 of file qgsauxiliarystorage.cpp.

◆ indexOfPropertyDefinition()

int QgsAuxiliaryLayer::indexOfPropertyDefinition ( const QgsPropertyDefinition definition) const

Returns the index of the auxiliary field for a specific property definition.

Parameters
definitionThe property definition
Returns
The index of the field corresponding to the property or -1

Definition at line 359 of file qgsauxiliarystorage.cpp.

◆ isHiddenProperty()

bool QgsAuxiliaryLayer::isHiddenProperty ( int  index) const

Returns true if the underlying field has to be hidden from editing tools like attribute table, false otherwise.

Parameters
indexThe index of the field for which visibility is checked

Definition at line 285 of file qgsauxiliarystorage.cpp.

◆ joinInfo()

QgsVectorLayerJoinInfo QgsAuxiliaryLayer::joinInfo ( ) const

Returns information to use for joining with primary key and so on.

Definition at line 125 of file qgsauxiliarystorage.cpp.

◆ nameFromProperty()

QString QgsAuxiliaryLayer::nameFromProperty ( const QgsPropertyDefinition def,
bool  joined = false 
)
static

Returns the name of the auxiliary field for a property definition.

Parameters
defThe property definition
joinedThe join prefix is taken into account if true

Definition at line 364 of file qgsauxiliarystorage.cpp.

◆ operator=()

QgsAuxiliaryLayer& QgsAuxiliaryLayer::operator= ( QgsAuxiliaryLayer const &  rhs)
delete

◆ propertyDefinitionFromField()

QgsPropertyDefinition QgsAuxiliaryLayer::propertyDefinitionFromField ( const QgsField field)
static

Returns the property definition from an auxiliary field.

Parameters
fieldThe auxiliary field

Definition at line 418 of file qgsauxiliarystorage.cpp.

◆ propertyDefinitionFromIndex()

QgsPropertyDefinition QgsAuxiliaryLayer::propertyDefinitionFromIndex ( int  index) const

Returns the property definition for the underlying field index.

Parameters
indexThe index of the field

Definition at line 354 of file qgsauxiliarystorage.cpp.

◆ propertyFromIndex()

int QgsAuxiliaryLayer::propertyFromIndex ( int  index) const

Returns the underlying property key for the field index.

The key may be a PAL, diagram or symbology property according to the underlying property definition of the field. The key -1 is returned if an error happened.

Parameters
indexThe index of the field

Definition at line 306 of file qgsauxiliarystorage.cpp.

◆ save()

bool QgsAuxiliaryLayer::save ( )

Commits changes and starts editing then.

Returns
true if commit step passed, false otherwise

Definition at line 205 of file qgsauxiliarystorage.cpp.

◆ toSpatialLayer()

QgsVectorLayer * QgsAuxiliaryLayer::toSpatialLayer ( ) const

An auxiliary layer is not spatial.

This method returns a spatial representation of auxiliary data.

Returns
A new spatial vector layer

Definition at line 94 of file qgsauxiliarystorage.cpp.


The documentation for this class was generated from the following files: