QGIS API Documentation  2.7.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Types | Public Slots | Signals | Public Member Functions | Static Public Member Functions | Protected Slots | Protected Member Functions | Friends | List of all members
QgsVectorLayer Class Reference

Represents a vector layer which manages a vector based data sets. More...

#include <qgsvectorlayer.h>

Inheritance diagram for QgsVectorLayer:
Inheritance graph
[legend]

Classes

struct  GroupData
 
struct  RangeData
 
struct  TabData
 
struct  ValueRelationData
 

Public Types

enum  EditorLayout { GeneratedLayout = 0, TabLayout = 1, UiFileLayout = 2 }
 The different types to layout the attribute editor. More...
 
enum  EditType {
  LineEdit, UniqueValues, UniqueValuesEditable, ValueMap,
  Classification, EditRange, SliderRange, CheckBox,
  FileName, Enumeration, Immutable, Hidden,
  TextEdit, Calendar, DialRange, ValueRelation,
  UuidGenerator, Photo, WebView, Color,
  EditorWidgetV2
}
 
enum  FeatureFormSuppress { SuppressDefault = 0, SuppressOn = 1, SuppressOff = 2 }
 Types of feature form suppression after feature creation. More...
 
enum  VertexMarkerType { SemiTransparentCircle, Cross, NoMarker }
 Editing vertex markers. More...
 
- Public Types inherited from QgsMapLayer
enum  LayerType { VectorLayer, RasterLayer, PluginLayer }
 Layers enum defining the types of layers that can be added to a map. More...
 

Public Slots

void checkJoinLayerRemove (QString theLayerId)
 Check if there is a join with a layer that will be removed. More...
 
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 (const QgsFeatureId &featureId)
 Select feature by its ID. More...
 
void select (const QgsFeatureIds &featureIds)
 Select features by their ID. More...
 
virtual void updateExtents ()
 Update the extents for the layer. More...
 
- Public Slots inherited from QgsMapLayer
Q_DECL_DEPRECATED void clearCacheImage ()
 Clear cached image. More...
 
virtual void invalidTransformInput ()
 Event handler for when a coordinate transform fails due to bad vertex error. More...
 
void setMaximumScale (const float theMaxScale)
 Sets the maximum scale denominator at which the layer will be visible. More...
 
void setMinimumScale (const float theMinScale)
 Sets the minimum scale denominator at which the layer will be visible. More...
 
void setScaleBasedVisibility (const bool enabled)
 Sets whether scale based visibility is enabled for the layer. More...
 
virtual QDateTime timestamp () const
 Time stamp of data source in the moment when data/metadata were loaded by provider. More...
 
Q_DECL_DEPRECATED void toggleScaleBasedVisibility (bool theVisibilityFlag)
 Accessor for the scale based visilibility flag. More...
 
void triggerRepaint ()
 Will advice the map canvas (and any other interested party) that this layer requires to be repainted. More...
 

Signals

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 &)
 
void beforeCommitChanges ()
 Is emitted, before changes are commited to the data provider. More...
 
void beforeModifiedCheck () const
 Is emitted, when layer is checked for modifications. More...
 
void beforeRollBack ()
 Is emitted, before changes are rolled back. More...
 
void committedAttributesAdded (const QString &layerId, const QList< QgsField > &addedAttributes)
 
void committedAttributesDeleted (const QString &layerId, const QgsAttributeList &deletedAttributes)
 Signals emitted after committing changes. More...
 
void committedAttributeValuesChanges (const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues)
 
void committedFeaturesAdded (const QString &layerId, const QgsFeatureList &addedFeatures)
 
void committedFeaturesRemoved (const QString &layerId, const QgsFeatureIds &deletedFeatureIds)
 
void committedGeometriesChanges (const QString &layerId, const QgsGeometryMap &changedGeometries)
 
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 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)
 
void featureBlendModeChanged (const QPainter::CompositionMode &blendMode)
 Signal emitted when setFeatureBlendMode() is called. More...
 
void featureDeleted (QgsFeatureId fid)
 
void geometryChanged (QgsFeatureId fid, QgsGeometry &geom)
 
void labelingFontNotFound (QgsVectorLayer *layer, const QString &fontfamily)
 Emitted when the font family defined for labeling layer is not found on system. More...
 
void layerDeleted ()
 
void layerModified ()
 This signal is emitted when modifications has been done on layer. More...
 
void layerTransparencyChanged (int layerTransparency)
 Signal emitted when setLayerTransparency() is called. More...
 
void readCustomSymbology (const QDomElement &element, QString &errorMessage)
 Signal emitted whenever the symbology (QML-file) for this layer is being read. More...
 
void saveLayerToProject ()
 
void selectionChanged (const QgsFeatureIds selected, const QgsFeatureIds deselected, const bool clearAndSelect)
 This signal is emitted when selection was changed. More...
 
void selectionChanged ()
 This signal is emitted when selection was changed. 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 blendModeChanged (const QPainter::CompositionMode &blendMode)
 Signal emitted when the blend mode is changed, through QgsMapLayer::setBlendMode() More...
 
void dataChanged ()
 data of layer changed More...
 
void drawingProgress (int theProgress, int theTotalSteps)
 
void layerCrsChanged ()
 Emit a signal that layer's CRS has been reset. More...
 
void layerNameChanged ()
 Emit a signal that the layer name has been changed. More...
 
void legendChanged ()
 Signal emitted when legend of the layer has changed. More...
 
void recalculateExtents ()
 This is used to send a request that any mapcanvas using this layer update its extents. More...
 
void rendererChanged ()
 Signal emitted when renderer is changed. More...
 
void repaintRequested ()
 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 screenUpdateRequested ()
 
void statusChanged (QString theStatus)
 Emit a signal with status (e.g. More...
 

Public Member Functions

 QgsVectorLayer (QString path=QString::null, QString baseName=QString::null, QString providerLib=QString::null, bool loadDefaultStyleFlag=true)
 Constructor - creates a vector layer. More...
 
virtual ~QgsVectorLayer ()
 Destructor. More...
 
QgsAttributeActionactions ()
 
bool addAttribute (const QgsField &field)
 add an attribute field (but does not commit it) returns true if the field was added More...
 
void addAttributeAlias (int attIndex, QString aliasString)
 Sets an alias (a display name) for attributes to display in dialogs. More...
 
void addAttributeEditorWidget (QgsAttributeEditorElement *data)
 Adds a tab (for the attribute editor form) holding groups and fields. More...
 
void addExpressionField (const QString &exp, const QgsField &fld)
 Add a new field which is calculated by the expression specified. More...
 
bool addFeature (QgsFeature &f, bool alsoUpdateExtent=true)
 Adds a feature. More...
 
bool addFeatures (QgsFeatureList features, bool makeSelected=true)
 Insert a copy of the given features into the layer (but does not commit it) More...
 
bool addJoin (const QgsVectorJoinInfo &joinInfo)
 Joins another vector layer to this layer. More...
 
int addPart (const QList< QgsPoint > &ring)
 Adds a new part polygon to a multipart feature. More...
 
int addRing (const QList< QgsPoint > &ring)
 Adds a ring to polygon/multipolygon features. More...
 
int addTopologicalPoints (QgsGeometry *geom)
 Adds topological points for every vertex of the geometry. More...
 
int addTopologicalPoints (const QgsPoint &p)
 Adds a vertex to segments which intersect point p but don't already have a vertex there. More...
 
QgsFeatureIds allFeatureIds ()
 Get all feature Ids. More...
 
QString annotationForm () const
 get annotation form More...
 
virtual bool applyNamedStyle (QString namedStyle, QString errorMsg)
 
QString attributeAlias (int attributeIndex) const
 Returns the alias of an attribute name or an empty string if there is no alias. More...
 
const QMap< QString, QString > & attributeAliases () const
 
QString attributeDisplayName (int attributeIndex) const
 Convenience function that returns the attribute alias if defined or the field name else. More...
 
QgsAttributeEditorElementattributeEditorElementFromDomElement (QDomElement &elem, QObject *parent)
 convert a saved attribute editor element into a AttributeEditor structure as it's used internally. More...
 
QList
< QgsAttributeEditorElement * > & 
attributeEditorElements ()
 Returns a list of tabs holding groups and fields. More...
 
void beginEditCommand (QString text)
 Create edit command for undo/redo operations. More...
 
QgsRectangle boundingBoxOfSelected ()
 Returns the bounding box of the selected features. More...
 
QgsGeometryCachecache ()
 
QString capabilitiesString () const
 Capabilities for this layer in a friendly format. More...
 
Q_DECL_DEPRECATED bool changeAttributeValue (QgsFeatureId fid, int field, QVariant value, bool emitSignal)
 Changes an attribute value (but does not commit it) More...
 
bool changeAttributeValue (QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue=QVariant())
 Changes an attribute value (but does not commit it) More...
 
bool changeGeometry (QgsFeatureId fid, QgsGeometry *geom)
 change feature's geometry More...
 
void clearAttributeEditorWidgets ()
 Clears all the tabs for the attribute editor form. More...
 
bool commitChanges ()
 Attempts to commit any changes to disk. More...
 
const QStringList & commitErrors ()
 
bool countSymbolFeatures (bool showProgress=true)
 Count features for symbols. More...
 
void createJoinCaches ()
 Caches joined attributes if required (and not already done) More...
 
virtual QgsMapLayerRenderercreateMapRenderer (QgsRenderContext &rendererContext)
 Return new instance of QgsMapLayerRenderer that will be used for rendering of given context. More...
 
QString dataComment () const
 Returns a comment for the data in the layer. More...
 
QgsVectorDataProviderdataProvider ()
 Returns the data provider. More...
 
const QgsVectorDataProviderdataProvider () const
 Returns the data provider in a const-correct manner. More...
 
Q_DECL_DEPRECATED QString dateFormat (int idx)
 Access date format. More...
 
bool deleteAttribute (int attr)
 delete an attribute field (but does not commit it) More...
 
bool deleteAttributes (QList< int > attrs)
 Deletes a list of attribute fields (but does not commit it) More...
 
bool deleteFeature (QgsFeatureId fid)
 delete a feature from the layer (but does not commit it) More...
 
bool deleteSelectedFeatures ()
 Deletes the selected features. More...
 
bool deleteVertex (QgsFeatureId atFeatureId, int atVertex)
 Deletes a vertex from a feature. More...
 
void destroyEditCommand ()
 Destroy active command and reverts all changes in it. More...
 
const QgsDiagramLayerSettingsdiagramLayerSettings () const
 
const QgsDiagramRendererV2diagramRenderer () const
 
const QString displayExpression ()
 Get the preview expression, used to create a human readable preview string. More...
 
const QString displayField () const
 Returns the primary display field name used in the identify results dialog. More...
 
bool draw (QgsRenderContext &rendererContext)
 Draws the layer. More...
 
void drawLabels (QgsRenderContext &rendererContext)
 Draws the layer labels using coordinate transformation. More...
 
QgsVectorLayerEditBuffereditBuffer ()
 Buffer with uncommitted editing operations. Only valid after editing has been turned on. More...
 
QString editForm ()
 get edit form More...
 
QString editFormInit ()
 get python function for edit form initialization More...
 
EditorLayout editorLayout ()
 get the active layout for the attribute editor for this layer More...
 
const QString editorWidgetV2 (int fieldIdx) const
 Get the id for the editor widget used to represent the field at the given index. More...
 
const QString editorWidgetV2 (const QString &fieldName) const
 Get the id for the editor widget used to represent the field at the given index. More...
 
const QgsEditorWidgetConfig editorWidgetV2Config (int fieldIdx) const
 Get the configuration for the editor widget used to represent the field at the given index. More...
 
const QgsEditorWidgetConfig editorWidgetV2Config (const QString &fieldName) const
 Get the configuration for the editor widget used to represent the field at the given index. More...
 
Q_DECL_DEPRECATED EditType editType (int idx)
 Get edit type. More...
 
void enableLabels (bool on)
 Set labels on. More...
 
void endEditCommand ()
 Finish edit command and add it to undo/redo stack. More...
 
const QSet< QString > & excludeAttributesWFS () const
 
const QSet< QString > & excludeAttributesWMS () const
 
QgsRectangle extent ()
 Return the extent of the layer as a QRect. More...
 
QPainter::CompositionMode featureBlendMode () const
 Read blend mode for layer. More...
 
virtual long featureCount () const
 Number of features in the layer. More...
 
long featureCount (QgsSymbolV2 *symbol)
 Number of features rendered with specified symbol. More...
 
QgsVectorLayer::FeatureFormSuppress featureFormSuppress () const
 Type of feature form pop-up suppression after feature creation (overrides app setting) More...
 
bool fieldEditable (int idx)
 is edit widget editable More...
 
int fieldNameIndex (const QString &fieldName) const
 Returns the index of a field name or -1 if the field does not exist. More...
 
QGis::GeometryType geometryType () const
 Returns point, line or polygon. More...
 
QgsFeatureIterator getFeatures (const QgsFeatureRequest &request=QgsFeatureRequest())
 Query the provider for features specified in request. More...
 
virtual QString getStyleFromDatabase (QString styleId, QString &msgError)
 Will return the named style corresponding to style id provided. More...
 
bool hasGeometryType () const
 Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeometry. More...
 
bool hasLabelsEnabled () const
 Label is on. More...
 
int insertSegmentVerticesForSnap (const QList< QgsSnappingResult > &snapResults)
 Inserts vertices to the snapped segments. 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...
 
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...
 
virtual bool isEditable () const
 Returns true if the provider is in editing mode. More...
 
virtual bool isModified () const
 Returns true if the provider has been modified since the last commit. More...
 
virtual bool isReadOnly () const
 Returns true if the provider is in read-only mode. More...
 
QgsLabellabel ()
 Get the label object associated with this layer. More...
 
const QgsLabellabel () const
 
bool labelOnTop (int idx)
 label widget on top More...
 
int layerTransparency () const
 Read transparency for layer. 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...
 
virtual QString loadNamedStyle (const QString &theURI, bool &theResultFlag, bool loadFromLocalDb)
 Load a named style from file/local db/datasource db. More...
 
virtual QString loadNamedStyle (const QString &theURI, bool &theResultFlag)
 Calls loadNamedStyle( theURI, theResultFlag, false ); Retained for backward compatibility. More...
 
QVariant maximumValue (int index)
 Returns maximum value for an attribute column or invalid variant in case of error. More...
 
QString metadata ()
 Obtain Metadata for this layer. More...
 
QVariant minimumValue (int index)
 Returns minimum value for an attribute column or invalid variant in case of error. More...
 
void modifySelection (QgsFeatureIds selectIds, 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...
 
QgsAttributeList pendingAllAttributesList ()
 returns list of attributes More...
 
int pendingFeatureCount ()
 returns feature count after commit More...
 
const QgsFieldspendingFields () const
 returns field list in the to-be-committed state More...
 
QgsAttributeList pendingPkAttributesList ()
 returns list of attribute making up the primary key More...
 
QString providerType () const
 Return the provider type for this layer. More...
 
Q_DECL_DEPRECATED RangeData range (int idx)
 Access range widget config data. More...
 
bool readSld (const QDomNode &node, QString &errorMessage)
 
bool readSymbology (const QDomNode &node, QString &errorMessage)
 Read the symbology for the current layer from the Dom node supplied. More...
 
virtual bool readXml (const QDomNode &layer_node)
 reads vector layer specific state from project file Dom node. More...
 
QList< QgsRelationreferencingRelations (int idx)
 Get relations, where the foreign key is on this layer. More...
 
virtual void reload ()
 Synchronises with changes in the datasource. More...
 
void remAttributeAlias (int attIndex)
 Removes an alias (a display name) for attributes to display in dialogs. More...
 
void removeExpressionField (int index)
 Remove an expression field. More...
 
void removeJoin (const QString &joinLayerId)
 Removes a vector layer join. More...
 
Q_DECL_DEPRECATED int removePolygonIntersections (QgsGeometry *geom, QgsFeatureIds ignoreFeatures=QgsFeatureIds())
 Changes the specified geometry such that it has no intersections with other polygon (or multipolygon) geometries in this vector layer. More...
 
QgsFeatureRendererV2rendererV2 ()
 Return renderer V2. More...
 
bool rollBack (bool deleteBuffer=true)
 Stop editing and discard the edits. More...
 
virtual void saveStyleToDatabase (QString name, QString description, bool useAsDefault, QString uiFileContent, QString &msgError)
 Save named and sld style of the layer to the style table in the db. More...
 
void select (QgsRectangle &rect, bool addToSelection)
 Select features found within the search rectangle (in layer's coordinates) More...
 
void selectAll ()
 Select all the features. More...
 
int selectedFeatureCount ()
 The number of features that are selected in this layer. More...
 
QgsFeatureList selectedFeatures ()
 Get a copy of the user-selected features. More...
 
const QgsFeatureIdsselectedFeaturesIds () const
 Return reference to identifiers of selected features. More...
 
QgsFeatureIterator selectedFeaturesIterator (QgsFeatureRequest request=QgsFeatureRequest())
 Get an iterator of the selected features. More...
 
void setAnnotationForm (const QString &ui)
 set annotation form for layer More...
 
Q_DECL_DEPRECATED void setCheckedState (int idx, QString checked, QString notChecked)
 Set string representing 'true' for a checkbox. More...
 
void setCoordinateSystem ()
 Setup the coordinate system transformation for the layer. More...
 
void setDiagramLayerSettings (const QgsDiagramLayerSettings &s)
 
void setDiagramRenderer (QgsDiagramRendererV2 *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 setDisplayField (QString fldName="")
 Set the primary display field to be used in the identify results dialog. More...
 
void setEditForm (QString ui)
 set edit form More...
 
void setEditFormInit (QString function)
 set python function for edit form initialization More...
 
void setEditorLayout (EditorLayout editorLayout)
 set the active layout for the attribute editor for this layer More...
 
void setEditorWidgetV2 (int attrIdx, const QString &widgetType)
 Set the editor widget type for a field. More...
 
void setEditorWidgetV2Config (int attrIdx, const QgsEditorWidgetConfig &config)
 Set the editor widget config for a field. More...
 
Q_DECL_DEPRECATED void setEditType (int idx, EditType edit)
 Get edit type. More...
 
void setExcludeAttributesWFS (const QSet< QString > &att)
 
void setExcludeAttributesWMS (const QSet< QString > &att)
 
void setFeatureBlendMode (const QPainter::CompositionMode &blendMode)
 Write blend mode for features. More...
 
void setFeatureFormSuppress (QgsVectorLayer::FeatureFormSuppress s)
 Set type of feature form pop-up suppression after feature creation (overrides app setting) More...
 
void setFieldEditable (int idx, bool editable)
 set edit widget editable More...
 
void setLabelOnTop (int idx, bool onTop)
 label widget on top More...
 
void setLayerTransparency (int layerTransparency)
 Write transparency for layer. More...
 
void setProviderEncoding (const QString &encoding)
 Sets the textencoding of the data provider. More...
 
bool setReadOnly (bool readonly=true)
 Make layer read-only (editing disabled) or not. More...
 
void setRendererV2 (QgsFeatureRendererV2 *r)
 Set renderer V2. More...
 
void setSelectedFeatures (const QgsFeatureIds &ids)
 Change selection to the new set of features. More...
 
void setSimplifyMethod (const QgsVectorSimplifyMethod &simplifyMethod)
 Set the simplification settings for fast rendering of features. More...
 
virtual bool setSubsetString (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...
 
bool snapPoint (QgsPoint &point, double tolerance)
 Snaps a point to the closest vertex if there is one within the snapping tolerance. More...
 
int snapWithContext (const QgsPoint &startPoint, double snappingTolerance, QMultiMap< double, QgsSnappingResult > &snappingResults, QgsSnapper::SnappingType snap_to)
 Snaps to segment or vertex within given tolerance. More...
 
int splitFeatures (const QList< QgsPoint > &splitLine, bool topologicalEditing=false)
 Splits features cut by the given line. More...
 
int splitParts (const QList< QgsPoint > &splitLine, bool topologicalEditing=false)
 Splits parts cut by the given line. More...
 
bool startEditing ()
 Make layer editable. More...
 
QString storageType () const
 Returns the permanent storage type for this layer as a friendly name. More...
 
virtual QString subsetString ()
 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...
 
void uniqueValues (int index, QList< QVariant > &uniqueValues, int limit=-1)
 Returns unique values for column. More...
 
bool updateFeature (QgsFeature &f)
 Updates an existing feature. More...
 
void updateFields ()
 Assembles mUpdatedFields considering provider fields, joined fields and added fields. More...
 
Q_DECL_DEPRECATED QMap
< QString, QVariant > 
valueMap (int idx)
 Access value map. More...
 
ValueRelationData valueRelation (int idx)
 Access value relation widget data. More...
 
const QList< QgsVectorJoinInfo > & vectorJoins () const
 
Q_DECL_DEPRECATED QSize widgetSize (int idx)
 Access widget size for photo and webview widget. More...
 
QGis::WkbType wkbType () const
 Returns the WKBType or WKBUnknown in case of error. More...
 
bool writeSld (QDomNode &node, QDomDocument &doc, QString &errorMessage) const
 
bool writeSymbology (QDomNode &node, QDomDocument &doc, QString &errorMessage) const
 Write the symbology for the layer into the docment provided. More...
 
virtual bool writeXml (QDomNode &layer_node, QDomDocument &doc)
 write vector layer specific state to project file Dom node. More...
 
- Public Member Functions inherited from QgsMapLayer
 QgsMapLayer (QgsMapLayer::LayerType type=VectorLayer, QString lyrname=QString::null, QString source=QString::null)
 Constructor. More...
 
virtual ~QgsMapLayer ()
 Destructor. More...
 
const QString & abstract () const
 
const QString & attribution () const
 
const QString & attributionUrl () const
 
QPainter::CompositionMode blendMode () const
 Read blend mode for layer. More...
 
Q_DECL_DEPRECATED QImage * cacheImage ()
 
const
QgsCoordinateReferenceSystem
crs () const
 Returns layer's spatial reference system. More...
 
QVariant customProperty (const QString &value, const QVariant &defaultValue=QVariant()) const
 Read a custom property from layer. More...
 
const QString & dataUrl () const
 
const QString & dataUrlFormat () const
 
virtual QgsError error () const
 Get current status error. More...
 
virtual void exportNamedStyle (QDomDocument &doc, QString &errorMsg)
 Export the properties of this layer as named style in a QDomDocument. More...
 
virtual void exportSldStyle (QDomDocument &doc, QString &errorMsg)
 Export the properties of this layer as SLD style in a QDomDocument. More...
 
bool hasScaleBasedVisibility () const
 Returns whether scale based visibility is enabled for the layer. More...
 
QString id () const
 Get this layer's unique ID, this ID is used to access this layer from map layer registry. More...
 
bool isValid ()
 
const QString & keywordList () const
 
virtual Q_DECL_DEPRECATED QString lastError ()
 
virtual Q_DECL_DEPRECATED QString lastErrorTitle ()
 
QgsMapLayerLegendlegend () const
 Can be null. More...
 
const QString & legendUrl () const
 
const QString & legendUrlFormat () const
 
virtual QString loadDefaultStyle (bool &theResultFlag)
 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 bool loadNamedStyleFromDb (const QString &db, const QString &theURI, QString &qml)
 
virtual QString loadSldStyle (const QString &theURI, bool &theResultFlag)
 
float maximumScale () const
 Returns the maximum scale denominator at which the layer is visible. More...
 
const QString & metadataUrl () const
 
const QString & metadataUrlFormat () const
 
const QString & metadataUrlType () const
 
float minimumScale () const
 Returns the minimum scale denominator at which the layer is visible. More...
 
const QString & name () const
 Get the display name of the layer. More...
 
virtual Q_DECL_DEPRECATED void onCacheImageDelete ()
 
const QString & originalName () const
 Get the original name of the layer. More...
 
QString publicSource () const
 
bool readLayerXML (const QDomElement &layerElement)
 sets state from Dom document More...
 
void removeCustomProperty (const QString &key)
 Remove a custom property from layer. More...
 
virtual QString saveDefaultStyle (bool &theResultFlag)
 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...
 
virtual QString saveNamedStyle (const QString &theURI, bool &theResultFlag)
 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 &theURI, bool &theResultFlag)
 
void setAbstract (const QString &abstract)
 
void setAttribution (const QString &attrib)
 
void setAttributionUrl (const QString &attribUrl)
 
void setBlendMode (const QPainter::CompositionMode &blendMode)
 Write blend mode for layer. More...
 
Q_DECL_DEPRECATED void setCacheImage (QImage *)
 
void setCrs (const QgsCoordinateReferenceSystem &srs, bool emitSignal=true)
 Sets layer's spatial reference system. More...
 
void setCustomProperty (const QString &key, const QVariant &value)
 Set a custom property for layer. More...
 
void setDataUrl (const QString &dataUrl)
 
void setDataUrlFormat (const QString &dataUrlFormat)
 
void setKeywordList (const QString &keywords)
 
void setLayerName (const QString &name)
 Set the display name of the layer. More...
 
virtual void setLayerOrder (const QStringList &layers)
 Reorders the previously selected sublayers of this layer from bottom to top (Useful for providers that manage their own layers, such as WMS) More...
 
void setLegend (QgsMapLayerLegend *legend)
 Assign a legend controller to the map layer. More...
 
void setLegendUrl (const QString &legendUrl)
 
void setLegendUrlFormat (const QString &legendUrlFormat)
 
void setMetadataUrl (const QString &metaUrl)
 
void setMetadataUrlFormat (const QString &metaUrlFormat)
 
void setMetadataUrlType (const QString &metaUrlType)
 
virtual void setSubLayerVisibility (QString name, bool vis)
 Set the visibility of the given sublayer name. More...
 
void setTitle (const QString &title)
 
const QString & source () const
 Returns the source for the layer. More...
 
virtual QString styleURI ()
 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 (Useful for providers that manage their own layers, such as WMS) More...
 
const QString & title () const
 
QgsMapLayer::LayerType type () const
 Get the type of the layer. More...
 
QUndoStack * undoStack ()
 Return pointer to layer's undo stack. More...
 
bool writeLayerXML (QDomElement &layerElement, QDomDocument &document, QString relativeBasePath=QString::null)
 stores state in Dom node More...
 

Static Public Member Functions

static void drawVertexMarker (double x, double y, QPainter &p, QgsVectorLayer::VertexMarkerType type, int vertexSize)
 Draws a vertex symbol at (screen) coordinates x, y. More...
 
- Static Public Member Functions inherited from QgsMapLayer
static QDomDocument asLayerDefinition (QList< QgsMapLayer * > layers, QString relativeBasePath=QString::null)
 Returns the given layer as a layer definition document Layer definitions store the data source as well as styling and custom properties. More...
 
static QString capitaliseLayerName (const QString &name)
 A convenience function to (un)capitalise the layer name. More...
 
static QList< QgsMapLayer * > fromLayerDefinition (QDomDocument &document)
 Creates a new layer from a layer defininition document. More...
 
static QList< QgsMapLayer * > fromLayerDefinitionFile (const QString &qlrfile)
 

Protected Slots

void invalidateSymbolCountedFlag ()
 

Protected Member Functions

void setExtent (const QgsRectangle &rect)
 Set the extent. More...
 
- Protected Member Functions inherited from QgsMapLayer
void appendError (const QgsErrorMessage &theMessage)
 Add error message. More...
 
void connectNotify (const char *signal)
 debugging member - invoked when a connect() is made to this object More...
 
void readCustomProperties (const QDomNode &layerNode, const QString &keyStartsWith="")
 Read custom properties from project file. More...
 
void setError (const QgsError &theError)
 Set error message. More...
 
void setValid (bool valid)
 set whether layer is valid or not - should be used in constructor. More...
 
void writeCustomProperties (QDomNode &layerNode, QDomDocument &doc) const
 Write custom properties to project file. More...
 

Friends

class QgsVectorLayerEditBuffer
 
class QgsVectorLayerFeatureSource
 

Additional Inherited Members

- 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
 
QgsError mError
 Error. More...
 
QgsRectangle mExtent
 Extent of the layer. More...
 
QString mKeywordList
 
QString mLayerName
 Name of the layer - used for display. More...
 
QString mLayerOrigName
 Original name of the layer. More...
 
QString mLegendUrl
 WMS legend. More...
 
QString mLegendUrlFormat
 
QString mMetadataUrl
 MetadataUrl of the layer. More...
 
QString mMetadataUrlFormat
 
QString mMetadataUrlType
 
QString mTitle
 
bool mValid
 Indicates if the layer is valid and can be drawn. More...
 

Detailed Description

Represents a vector layer which manages a vector based data sets.

The QgsVectorLayer is instantiated by specifying the name of a data provider, such as postgres or wfs, and url defining the specific data set to connect to. The vector layer constructor in turn instantiates a QgsVectorDataProvider subclass corresponding to the provider type, and passes it the url. The data provider connects to the data source.

The QgsVectorLayer provides a common interface to the different data types. It also manages editing transactions.

Sample usage of the QgsVectorLayer class:

QString uri = "point?crs=epsg:4326&field=id:integer";
QgsVectorLayer *scratchLayer = new QgsVectorLayer(uri, "Scratch point layer", "memory");

The main data providers supported by QGIS are listed below.

Vector data providers

Memory data providerType (memory)

The memory data provider is used to construct in memory data, for example scratch data or data generated from spatial operations such as contouring. There is no inherent persistent storage of the data. The data source uri is constructed. The url specifies the geometry type ("point", "linestring", "polygon", "multipoint","multilinestring","multipolygon"), optionally followed by url parameters as follows:

An example url is "Point?crs=epsg:4326&field=id:integer&field=name:string(20)&index=yes"

OGR data provider (ogr)

Accesses data using the OGR drivers (http://www.gdal.org/ogr/ogr_formats.html). The url is the OGR connection string. A wide variety of data formats can be accessed using this driver, including file based formats used by many GIS systems, database formats, and web services. Some of these formats are also supported by custom data providers listed below.

Spatialite data provider (spatialite)

Access data in a spatialite database. The url defines the connection parameters, table, geometry column, and other attributes. The url can be constructed using the QgsDataSourceURI class.

Postgresql data provider (postgres)

Connects to a postgresql database. The url defines the connection parameters, table, geometry column, and other attributes. The url can be constructed using the QgsDataSourceURI class.

Microsoft SQL server data provider (mssql)

Connects to a Microsoft SQL server database. The url defines the connection parameters, table, geometry column, and other attributes. The url can be constructed using the QgsDataSourceURI class.

WFS (web feature service) data provider (wfs)

Used to access data provided by a web feature service.

The url can be a HTTP url to a WFS 1.0.0 server or a GML2 data file path. Examples are http://foobar/wfs or /foo/bar/file.gml

If a GML2 file path is provided the driver will attempt to read the schema from a file in the same directory with the same basename + “.xsd”. This xsd file must be in the same format as a WFS describe feature type response. If no xsd file is provide then the driver will attempt to guess the attribute types from the file.

In the case of a HTTP URL the ‘FILTER’ query string parameter can be used to filter the WFS feature type. The ‘FILTER’ key value can either be a QGIS expression or an OGC XML filter. If the value is set to a QGIS expression the driver will turn it into OGC XML filter before passing it to the WFS server. Beware the QGIS expression filter only supports” =, !=, <, >, <=, >=, AND, OR, NOT, LIKE, IS NULL” attribute operators, “BBOX, Disjoint, Intersects, Touches, Crosses, Contains, Overlaps, Within” spatial binary operators and the QGIS local “geomFromWKT, geomFromGML” geometry constructor functions.

Also note:

Delimited text file data provider (delimitedtext)

Accesses data in a delimited text file, for example CSV files generated by spreadsheets. The contents of the file are split into columns based on specified delimiter characters. Each record may be represented spatially either by an X and Y coordinate column, or by a WKT (well known text) formatted columns.

The url defines the filename, the formatting options (how the text in the file is divided into data fields, and which fields contain the X,Y coordinates or WKT text definition. The options are specified as url query items.

At its simplest the url can just be the filename, in which case it will be loaded as a CSV formatted file.

The url may include the following items:

-subsetIndex=(yes|no)

Determines whether the provider generates an index to improve the efficiency of subsets. The default is yes

-spatialIndex=(yes|no)

Determines whether the provider generates a spatial index. The default is no.

-watchFile=(yes|no)

Defines whether the file will be monitored for changes. The default is to monitor for changes.

GPX data provider (gpx)

Provider reads tracks, routes, and waypoints from a GPX file. The url defines the name of the file, and the type of data to retrieve from it ("track", "route", or "waypoint").

An example url is "/home/user/data/holiday.gpx?type=route"

Grass data provider (grass)

Provider to display vector data in a GRASS GIS layer.

Definition at line 468 of file qgsvectorlayer.h.

Constructor & Destructor Documentation

QgsVectorLayer::QgsVectorLayer ( QString  path = QString::null,
QString  baseName = QString::null,
QString  providerLib = QString::null,
bool  loadDefaultStyleFlag = true 
)

Constructor - creates a vector layer.

The QgsVectorLayer is constructed by instantiating a data provider. The provider interprets the supplied path (url) of the data source to connect to and access the data.

Parameters
pathThe path or url of the parameter. Typically this encodes parameters used by the data provider as url query items.
baseNameThe name used to represent the layer in the legend
providerLibThe name of the data provider, eg "memory", "postgres"
loadDefaultStyleFlagwhether to load the default style

Definition at line 120 of file qgsvectorlayer.cpp.

QgsVectorLayer::~QgsVectorLayer ( )
virtual

Destructor.

Definition at line 197 of file qgsvectorlayer.cpp.

Member Function Documentation

QgsAttributeAction* QgsVectorLayer::actions ( )
inline

Definition at line 670 of file qgsvectorlayer.h.

bool QgsVectorLayer::addAttribute ( const QgsField field)

add an attribute field (but does not commit it) returns true if the field was added

Definition at line 2039 of file qgsvectorlayer.cpp.

void QgsVectorLayer::addAttributeAlias ( int  attIndex,
QString  aliasString 
)

Sets an alias (a display name) for attributes to display in dialogs.

Definition at line 2060 of file qgsvectorlayer.cpp.

void QgsVectorLayer::addAttributeEditorWidget ( QgsAttributeEditorElement data)

Adds a tab (for the attribute editor form) holding groups and fields.

Definition at line 2071 of file qgsvectorlayer.cpp.

void QgsVectorLayer::addExpressionField ( const QString &  exp,
const QgsField fld 
)

Add a new field which is calculated by the expression specified.

Parameters
expThe expression which calculates the field
fldThe field to calculate
Note
added in 2.6

Definition at line 2776 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::addFeature ( QgsFeature f,
bool  alsoUpdateExtent = true 
)

Adds a feature.

Parameters
ffeature to add
alsoUpdateExtentIf True, will also go to the effort of e.g. updating the extents.
Returns
True in case of success and False in case of error

Definition at line 950 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::addFeatures ( QgsFeatureList  features,
bool  makeSelected = true 
)

Insert a copy of the given features into the layer (but does not commit it)

Definition at line 2333 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::addJoin ( const QgsVectorJoinInfo joinInfo)

Joins another vector layer to this layer.

Parameters
joinInfojoin object containing join layer id, target and source field
Note
since 2.6 returns bool indicating whether the join can be added

Definition at line 2756 of file qgsvectorlayer.cpp.

int QgsVectorLayer::addPart ( const QList< QgsPoint > &  ring)

Adds a new part polygon to a multipart feature.

Returns
0 in case of success, 1 if selected feature is not multipart, 2 if ring is not a valid geometry, 3 if new polygon ring not disjoint with existing rings, 4 if no feature was selected, 5 if several features are selected, 6 if selected geometry not found 7 layer not editable

Definition at line 1074 of file qgsvectorlayer.cpp.

int QgsVectorLayer::addRing ( const QList< QgsPoint > &  ring)

Adds a ring to polygon/multipolygon features.

Returns
0 in case of success, 1 problem with feature type, 2 ring not closed, 3 ring not valid, 4 ring crosses existing rings, 5 no feature found where ring can be inserted 6 layer not editable

Definition at line 1065 of file qgsvectorlayer.cpp.

int QgsVectorLayer::addTopologicalPoints ( QgsGeometry geom)

Adds topological points for every vertex of the geometry.

Parameters
geomthe geometry where each vertex is added to segments of other features
Note
geom is not going to be modified by the function
Returns
0 in case of success

Definition at line 1168 of file qgsvectorlayer.cpp.

int QgsVectorLayer::addTopologicalPoints ( const QgsPoint p)

Adds a vertex to segments which intersect point p but don't already have a vertex there.

If a feature already has a vertex at position p, no additional vertex is inserted. This method is useful for topological editing.

Parameters
pposition of the vertex
Returns
0 in case of success

Definition at line 1177 of file qgsvectorlayer.cpp.

QgsFeatureIds QgsVectorLayer::allFeatureIds ( )

Get all feature Ids.

Definition at line 515 of file qgsvectorlayer.cpp.

QString QgsVectorLayer::annotationForm ( ) const
inline

get annotation form

Definition at line 1331 of file qgsvectorlayer.h.

bool QgsVectorLayer::applyNamedStyle ( QString  namedStyle,
QString  errorMsg 
)
virtual

Definition at line 3787 of file qgsvectorlayer.cpp.

void QgsVectorLayer::attributeAdded ( int  idx)
signal

Will be emitted, when a new attribute has been added to this vector layer.

Applies only to types QgsFields::OriginEdit and QgsFields::OriginProvider

Parameters
idxThe index of the new attribute
See also
updatedFields()
QString QgsVectorLayer::attributeAlias ( int  attributeIndex) const

Returns the alias of an attribute name or an empty string if there is no alias.

Definition at line 2096 of file qgsvectorlayer.cpp.

const QMap< QString, QString >& QgsVectorLayer::attributeAliases ( ) const
inline

Definition at line 1193 of file qgsvectorlayer.h.

void QgsVectorLayer::attributeDeleted ( int  idx)
signal

Will be emitted, when an attribute has been deleted from this vector layer.

Applies only to types QgsFields::OriginEdit and QgsFields::OriginProvider

Parameters
idxThe index of the deleted attribute
See also
updatedFields()
QString QgsVectorLayer::attributeDisplayName ( int  attributeIndex) const

Convenience function that returns the attribute alias if defined or the field name else.

Definition at line 2106 of file qgsvectorlayer.cpp.

QgsAttributeEditorElement * QgsVectorLayer::attributeEditorElementFromDomElement ( QDomElement &  elem,
QObject *  parent 
)

convert a saved attribute editor element into a AttributeEditor structure as it's used internally.

Parameters
elemthe DOM element
parentthe QObject which will own this object

Definition at line 1732 of file qgsvectorlayer.cpp.

QList< QgsAttributeEditorElement * > & QgsVectorLayer::attributeEditorElements ( )

Returns a list of tabs holding groups and fields.

Definition at line 3615 of file qgsvectorlayer.cpp.

void QgsVectorLayer::attributeValueChanged ( QgsFeatureId  fid,
int  idx,
const QVariant &   
)
signal
void QgsVectorLayer::beforeCommitChanges ( )
signal

Is emitted, before changes are commited to the data provider.

void QgsVectorLayer::beforeModifiedCheck ( ) const
signal

Is emitted, when layer is checked for modifications.

Use for last-minute additions

void QgsVectorLayer::beforeRollBack ( )
signal

Is emitted, before changes are rolled back.

void QgsVectorLayer::beginEditCommand ( QString  text)

Create edit command for undo/redo operations.

Parameters
texttext which is to be displayed in undo window

Definition at line 2723 of file qgsvectorlayer.cpp.

QgsRectangle QgsVectorLayer::boundingBoxOfSelected ( )

Returns the bounding box of the selected features.

If there is no selection, QgsRectangle(0,0,0,0) is returned

Definition at line 656 of file qgsvectorlayer.cpp.

QgsGeometryCache* QgsVectorLayer::cache ( )
inline
Note
not available in python bindings

Definition at line 1452 of file qgsvectorlayer.h.

QString QgsVectorLayer::capabilitiesString ( ) const

Capabilities for this layer in a friendly format.

Definition at line 228 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::changeAttributeValue ( QgsFeatureId  fid,
int  field,
QVariant  value,
bool  emitSignal 
)

Changes an attribute value (but does not commit it)

Deprecated:
The emitSignal parameter is obsolete and not considered at the moment. It will be removed in future releases. Remove it to be prepared for the future. (Since 2.1)

Definition at line 2025 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::changeAttributeValue ( QgsFeatureId  fid,
int  field,
const QVariant &  newValue,
const QVariant &  oldValue = QVariant() 
)

Changes an attribute value (but does not commit it)

Parameters
fidThe feature id of the feature to be changed
fieldThe index of the field to be updated
newValueThe value which will be assigned to the field
oldValueThe previous value to restore on undo (will otherwise be retrieved)
Returns
true in case of success

Definition at line 2031 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::changeGeometry ( QgsFeatureId  fid,
QgsGeometry geom 
)

change feature's geometry

Definition at line 2012 of file qgsvectorlayer.cpp.

void QgsVectorLayer::checkJoinLayerRemove ( QString  theLayerId)
slot

Check if there is a join with a layer that will be removed.

Definition at line 2761 of file qgsvectorlayer.cpp.

void QgsVectorLayer::clearAttributeEditorWidgets ( )

Clears all the tabs for the attribute editor form.

Definition at line 3620 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::commitChanges ( )

Attempts to commit any changes to disk.

Returns the result of the attempt. If a commit fails, the in-memory changes are left alone.

This allows editing to continue if the commit failed on e.g. a disallowed value in a Postgres database - the user can re-edit and try again.

The commits occur in distinct stages, (add attributes, add features, change attribute values, change geometries, delete features, delete attributes) so if a stage fails, it's difficult to roll back cleanly. Therefore any error message also includes which stage failed so that the user has some chance of repairing the damage cleanly.

Definition at line 2202 of file qgsvectorlayer.cpp.

const QStringList & QgsVectorLayer::commitErrors ( )

Definition at line 2247 of file qgsvectorlayer.cpp.

void QgsVectorLayer::committedAttributesAdded ( const QString &  layerId,
const QList< QgsField > &  addedAttributes 
)
signal
void QgsVectorLayer::committedAttributesDeleted ( const QString &  layerId,
const QgsAttributeList deletedAttributes 
)
signal

Signals emitted after committing changes.

void QgsVectorLayer::committedAttributeValuesChanges ( const QString &  layerId,
const QgsChangedAttributesMap changedAttributesValues 
)
signal
void QgsVectorLayer::committedFeaturesAdded ( const QString &  layerId,
const QgsFeatureList addedFeatures 
)
signal
void QgsVectorLayer::committedFeaturesRemoved ( const QString &  layerId,
const QgsFeatureIds deletedFeatureIds 
)
signal
void QgsVectorLayer::committedGeometriesChanges ( const QString &  layerId,
const QgsGeometryMap changedGeometries 
)
signal
bool QgsVectorLayer::countSymbolFeatures ( bool  showProgress = true)

Count features for symbols.

Feature counts may be get by featureCount( QgsSymbolV2*).

Parameters
showProgressshow progress dialog
Returns
true if calculated, false if failed or was canceled by user

Definition at line 733 of file qgsvectorlayer.cpp.

void QgsVectorLayer::createJoinCaches ( )

Caches joined attributes if required (and not already done)

Definition at line 2817 of file qgsvectorlayer.cpp.

QgsMapLayerRenderer * QgsVectorLayer::createMapRenderer ( QgsRenderContext rendererContext)
virtual

Return new instance of QgsMapLayerRenderer that will be used for rendering of given context.

Note
added in 2.4

Reimplemented from QgsMapLayer.

Definition at line 405 of file qgsvectorlayer.cpp.

QString QgsVectorLayer::dataComment ( ) const

Returns a comment for the data in the layer.

Definition at line 237 of file qgsvectorlayer.cpp.

QgsVectorDataProvider * QgsVectorLayer::dataProvider ( )

Returns the data provider.

Definition at line 569 of file qgsvectorlayer.cpp.

const QgsVectorDataProvider * QgsVectorLayer::dataProvider ( ) const

Returns the data provider in a const-correct manner.

Note
not available in python bindings

Definition at line 574 of file qgsvectorlayer.cpp.

QString QgsVectorLayer::dateFormat ( int  idx)

Access date format.

Deprecated:
Use setEditorWidgetV2Config() instead

Definition at line 2652 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::deleteAttribute ( int  attr)

delete an attribute field (but does not commit it)

Definition at line 2120 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::deleteAttributes ( QList< int >  attrs)

Deletes a list of attribute fields (but does not commit it)

Parameters
attrsthe indices of the attributes to delete
Returns
true if at least one attribute has been deleted

Definition at line 2137 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::deleteFeature ( QgsFeatureId  fid)

delete a feature from the layer (but does not commit it)

Definition at line 2157 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::deleteSelectedFeatures ( )

Deletes the selected features.

Returns
true in case of success and false otherwise

Definition at line 1038 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::deleteVertex ( QgsFeatureId  atFeatureId,
int  atVertex 
)

Deletes a vertex from a feature.

Definition at line 1028 of file qgsvectorlayer.cpp.

void QgsVectorLayer::deselect ( const QgsFeatureId  featureId)
slot

Deselect feature by its ID.

Parameters
featureIdThe id of the feature to deselect
See also
deselect(QgsFeatureIds)

Definition at line 446 of file qgsvectorlayer.cpp.

void QgsVectorLayer::deselect ( const QgsFeatureIds featureIds)
slot

Deselect features by their ID.

Parameters
featureIdsThe ids of the features to deselect
See also
deselect(QgsFeatureId)

Definition at line 453 of file qgsvectorlayer.cpp.

void QgsVectorLayer::destroyEditCommand ( )

Destroy active command and reverts all changes in it.

Definition at line 2735 of file qgsvectorlayer.cpp.

const QgsDiagramLayerSettings* QgsVectorLayer::diagramLayerSettings ( ) const
inline

Definition at line 768 of file qgsvectorlayer.h.

const QgsDiagramRendererV2* QgsVectorLayer::diagramRenderer ( ) const
inline

Definition at line 765 of file qgsvectorlayer.h.

const QString QgsVectorLayer::displayExpression ( )

Get the preview expression, used to create a human readable preview string.

Uses QgsExpression

Returns
The expression which will be used to preview features for this layer

Definition at line 2534 of file qgsvectorlayer.cpp.

const QString QgsVectorLayer::displayField ( ) const

Returns the primary display field name used in the identify results dialog.

Definition at line 2524 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::draw ( QgsRenderContext rendererContext)
virtual

Draws the layer.

Returns
false if an error occurred during drawing

Reimplemented from QgsMapLayer.

Definition at line 410 of file qgsvectorlayer.cpp.

void QgsVectorLayer::drawLabels ( QgsRenderContext rendererContext)
virtual

Draws the layer labels using coordinate transformation.

Reimplemented from QgsMapLayer.

Definition at line 335 of file qgsvectorlayer.cpp.

void QgsVectorLayer::drawVertexMarker ( double  x,
double  y,
QPainter &  p,
QgsVectorLayer::VertexMarkerType  type,
int  vertexSize 
)
static

Draws a vertex symbol at (screen) coordinates x, y.

(Useful to assist vertex editing.)

Definition at line 416 of file qgsvectorlayer.cpp.

QgsVectorLayerEditBuffer* QgsVectorLayer::editBuffer ( )
inline

Buffer with uncommitted editing operations. Only valid after editing has been turned on.

Definition at line 1393 of file qgsvectorlayer.h.

void QgsVectorLayer::editCommandDestroyed ( )
signal

Signal emitted, whan an edit command is destroyed.

Note
This is not a rollback, it is only related to the current edit command. See beforeRollBack()
void QgsVectorLayer::editCommandEnded ( )
signal

Signal emitted, when an edit command successfully ended.

Note
This does not mean it is also committed, only that it is written to the edit buffer. See beforeCommitChanges()
void QgsVectorLayer::editCommandStarted ( const QString &  text)
signal

Signal emitted when a new edit command has been started.

Parameters
textDescription for this edit command
QString QgsVectorLayer::editForm ( )

get edit form

Definition at line 2604 of file qgsvectorlayer.cpp.

QString QgsVectorLayer::editFormInit ( )

get python function for edit form initialization

Definition at line 2627 of file qgsvectorlayer.cpp.

void QgsVectorLayer::editingStarted ( )
signal

Is emitted, when editing on this layer has started.

void QgsVectorLayer::editingStopped ( )
signal

Is emitted, when edited changes successfully have been written to the data provider.

QgsVectorLayer::EditorLayout QgsVectorLayer::editorLayout ( )

get the active layout for the attribute editor for this layer

Definition at line 2584 of file qgsvectorlayer.cpp.

const QString QgsVectorLayer::editorWidgetV2 ( int  fieldIdx) const

Get the id for the editor widget used to represent the field at the given index.

Parameters
fieldIdxThe index of the field
Returns
The id for the editor widget or a NULL string if not applicable

Definition at line 2076 of file qgsvectorlayer.cpp.

const QString QgsVectorLayer::editorWidgetV2 ( const QString &  fieldName) const

Get the id for the editor widget used to represent the field at the given index.

Parameters
fieldNameThe name of the field
Returns
The id for the editor widget or a NULL string if not applicable
Note
python method name editorWidgetV2ByName

Definition at line 2081 of file qgsvectorlayer.cpp.

const QgsEditorWidgetConfig QgsVectorLayer::editorWidgetV2Config ( int  fieldIdx) const

Get the configuration for the editor widget used to represent the field at the given index.

Parameters
fieldIdxThe index of the field
Returns
The configuration for the editor widget or an empty config if the field does not exist

Definition at line 2086 of file qgsvectorlayer.cpp.

const QgsEditorWidgetConfig QgsVectorLayer::editorWidgetV2Config ( const QString &  fieldName) const

Get the configuration for the editor widget used to represent the field at the given index.

Parameters
fieldNameThe name of the field
Returns
The configuration for the editor widget or an empty config if the field does not exist
Note
python method name is editorWidgetV2ConfigByName

Definition at line 2091 of file qgsvectorlayer.cpp.

QgsVectorLayer::EditType QgsVectorLayer::editType ( int  idx)

Get edit type.

Deprecated:
Use editorWidgetV2() instead

Definition at line 2565 of file qgsvectorlayer.cpp.

void QgsVectorLayer::enableLabels ( bool  on)

Set labels on.

Definition at line 1196 of file qgsvectorlayer.cpp.

void QgsVectorLayer::endEditCommand ( )

Finish edit command and add it to undo/redo stack.

Definition at line 2729 of file qgsvectorlayer.cpp.

const QSet<QString>& QgsVectorLayer::excludeAttributesWFS ( ) const
inline

Definition at line 1198 of file qgsvectorlayer.h.

const QSet<QString>& QgsVectorLayer::excludeAttributesWMS ( ) const
inline

Definition at line 1195 of file qgsvectorlayer.h.

QgsRectangle QgsVectorLayer::extent ( )
virtual

Return the extent of the layer as a QRect.

Reimplemented from QgsMapLayer.

Definition at line 814 of file qgsvectorlayer.cpp.

void QgsVectorLayer::featureAdded ( QgsFeatureId  fid)
signal
QPainter::CompositionMode QgsVectorLayer::featureBlendMode ( ) const

Read blend mode for layer.

Definition at line 3045 of file qgsvectorlayer.cpp.

void QgsVectorLayer::featureBlendModeChanged ( const QPainter::CompositionMode &  blendMode)
signal

Signal emitted when setFeatureBlendMode() is called.

long QgsVectorLayer::featureCount ( ) const
virtual

Number of features in the layer.

This is necessary if features are added/deleted or the layer has been subsetted. If the data provider chooses not to support this feature, the total number of features can be returned.

Returns
long containing number of features

Definition at line 716 of file qgsvectorlayer.cpp.

long QgsVectorLayer::featureCount ( QgsSymbolV2 symbol)

Number of features rendered with specified symbol.

Features must be first calculated by countSymbolFeatures()

Parameters
symbolthe symbol
Returns
number of features rendered by symbol or -1 if failed or counts are not available

Definition at line 727 of file qgsvectorlayer.cpp.

void QgsVectorLayer::featureDeleted ( QgsFeatureId  fid)
signal
QgsVectorLayer::FeatureFormSuppress QgsVectorLayer::featureFormSuppress ( ) const
inline

Type of feature form pop-up suppression after feature creation (overrides app setting)

Note
added in 2.1

Definition at line 1324 of file qgsvectorlayer.h.

bool QgsVectorLayer::fieldEditable ( int  idx)

is edit widget editable

Definition at line 2663 of file qgsvectorlayer.cpp.

int QgsVectorLayer::fieldNameIndex ( const QString &  fieldName) const

Returns the index of a field name or -1 if the field does not exist.

Definition at line 2751 of file qgsvectorlayer.cpp.

void QgsVectorLayer::geometryChanged ( QgsFeatureId  fid,
QgsGeometry geom 
)
signal
QGis::GeometryType QgsVectorLayer::geometryType ( ) const

Returns point, line or polygon.

Definition at line 594 of file qgsvectorlayer.cpp.

QgsFeatureIterator QgsVectorLayer::getFeatures ( const QgsFeatureRequest request = QgsFeatureRequest())

Query the provider for features specified in request.

Definition at line 941 of file qgsvectorlayer.cpp.

QString QgsVectorLayer::getStyleFromDatabase ( QString  styleId,
QString &  msgError 
)
virtual

Will return the named style corresponding to style id provided.

Definition at line 3692 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::hasGeometryType ( ) const

Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeometry.

Definition at line 645 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::hasLabelsEnabled ( void  ) const

Label is on.

Definition at line 1201 of file qgsvectorlayer.cpp.

int QgsVectorLayer::insertSegmentVerticesForSnap ( const QList< QgsSnappingResult > &  snapResults)

Inserts vertices to the snapped segments.

This is useful for topological editing if snap to segment is enabled.

Parameters
snapResultsresults collected from the snapping operation
Returns
0 in case of success

Definition at line 2496 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::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.

Definition at line 1008 of file qgsvectorlayer.cpp.

void QgsVectorLayer::invalidateSymbolCountedFlag ( )
protectedslot

Definition at line 3561 of file qgsvectorlayer.cpp.

void QgsVectorLayer::invertSelection ( )

Select not selected features and deselect selected ones.

Definition at line 503 of file qgsvectorlayer.cpp.

void QgsVectorLayer::invertSelectionInRectangle ( QgsRectangle rect)

Invert selection of features found within the search rectangle (in layer's coordinates)

Parameters
rectThe rectangle in which the selection of features will be inverted
See also
invertSelection()

Definition at line 532 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::isEditable ( ) const
virtual

Returns true if the provider is in editing mode.

Reimplemented from QgsMapLayer.

Definition at line 2539 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::isModified ( ) const
virtual

Returns true if the provider has been modified since the last commit.

Definition at line 2559 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::isReadOnly ( ) const
virtual

Returns true if the provider is in read-only mode.

Definition at line 2544 of file qgsvectorlayer.cpp.

QgsLabel * QgsVectorLayer::label ( )

Get the label object associated with this layer.

Definition at line 1186 of file qgsvectorlayer.cpp.

const QgsLabel * QgsVectorLayer::label ( ) const

Definition at line 1191 of file qgsvectorlayer.cpp.

void QgsVectorLayer::labelingFontNotFound ( QgsVectorLayer layer,
const QString &  fontfamily 
)
signal

Emitted when the font family defined for labeling layer is not found on system.

bool QgsVectorLayer::labelOnTop ( int  idx)

label widget on top

Definition at line 2677 of file qgsvectorlayer.cpp.

void QgsVectorLayer::layerDeleted ( )
signal
void QgsVectorLayer::layerModified ( )
signal

This signal is emitted when modifications has been done on layer.

int QgsVectorLayer::layerTransparency ( ) const

Read transparency for layer.

Definition at line 3058 of file qgsvectorlayer.cpp.

void QgsVectorLayer::layerTransparencyChanged ( int  layerTransparency)
signal

Signal emitted when setLayerTransparency() is called.

int QgsVectorLayer::listStylesInDatabase ( QStringList &  ids,
QStringList &  names,
QStringList &  descriptions,
QString &  msgError 
)
virtual

Lists all the style in db split into related to the layer and not related to.

Parameters
idsthe list in which will be stored the style db ids
namesthe list in which will be stored the style names
descriptionsthe list in which will be stored the style descriptions
msgError
Returns
the number of styles related to current layer

Definition at line 3671 of file qgsvectorlayer.cpp.

QString QgsVectorLayer::loadNamedStyle ( const QString &  theURI,
bool &  theResultFlag,
bool  loadFromLocalDb 
)
virtual

Load a named style from file/local db/datasource db.

Parameters
theURIthe URI of the style or the URI of the layer
theResultFlagwill be set to true if a named style is correctly loaded
loadFromLocalDbif true forces to load from local db instead of datasource one

Definition at line 3761 of file qgsvectorlayer.cpp.

QString QgsVectorLayer::loadNamedStyle ( const QString &  theURI,
bool &  theResultFlag 
)
virtual

Calls loadNamedStyle( theURI, theResultFlag, false ); Retained for backward compatibility.

Reimplemented from QgsMapLayer.

Definition at line 3756 of file qgsvectorlayer.cpp.

QVariant QgsVectorLayer::maximumValue ( int  index)

Returns maximum value for an attribute column or invalid variant in case of error.

Definition at line 2975 of file qgsvectorlayer.cpp.

QString QgsVectorLayer::metadata ( )
virtual

Obtain Metadata for this layer.

Reimplemented from QgsMapLayer.

Definition at line 3307 of file qgsvectorlayer.cpp.

QVariant QgsVectorLayer::minimumValue ( int  index)

Returns minimum value for an attribute column or invalid variant in case of error.

Definition at line 2913 of file qgsvectorlayer.cpp.

void QgsVectorLayer::modifySelection ( QgsFeatureIds  selectIds,
QgsFeatureIds  deselectIds 
)

Modifies the current selection on this layer.

Parameters
selectIdsSelect these ids
deselectIdsDeselect these ids
See also
select(QgsFeatureIds)
select(QgsFeatureId)
deselect(QgsFeatureIds)
deselect(QgsFeatureId)

Definition at line 489 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::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.

Definition at line 1018 of file qgsvectorlayer.cpp.

QgsAttributeList QgsVectorLayer::pendingAllAttributesList ( )

returns list of attributes

Definition at line 2176 of file qgsvectorlayer.cpp.

int QgsVectorLayer::pendingFeatureCount ( )

returns feature count after commit

Definition at line 2196 of file qgsvectorlayer.cpp.

const QgsFields & QgsVectorLayer::pendingFields ( ) const

returns field list in the to-be-committed state

Definition at line 2171 of file qgsvectorlayer.cpp.

QgsAttributeList QgsVectorLayer::pendingPkAttributesList ( )

returns list of attribute making up the primary key

Definition at line 2181 of file qgsvectorlayer.cpp.

QString QgsVectorLayer::providerType ( ) const

Return the provider type for this layer.

Definition at line 247 of file qgsvectorlayer.cpp.

QgsVectorLayer::RangeData QgsVectorLayer::range ( int  idx)

Access range widget config data.

Deprecated:
Use editorWidgetV2Config() instead

Definition at line 2642 of file qgsvectorlayer.cpp.

void QgsVectorLayer::readCustomSymbology ( const QDomElement &  element,
QString &  errorMessage 
)
signal

Signal emitted whenever the symbology (QML-file) for this layer is being read.

If there is custom style information saved in the file, you can connect to this signal and update the layer style accordingly.

Parameters
elementThe XML layer style element.
errorMessageWrite error messages into this string.
bool QgsVectorLayer::readSld ( const QDomNode &  node,
QString &  errorMessage 
)
virtual

Reimplemented from QgsMapLayer.

Definition at line 1971 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::readSymbology ( const QDomNode &  node,
QString &  errorMessage 
)
virtual

Read the symbology for the current layer from the Dom node supplied.

Parameters
nodenode that will contain the symbology definition for this layer.
errorMessagereference to string that will be updated with any error messages
Returns
true in case of success.

Implements QgsMapLayer.

Definition at line 1486 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::readXml ( const QDomNode &  layer_node)
virtual

reads vector layer specific state from project file Dom node.

Note
Called by QgsMapLayer::readXML().

Reimplemented from QgsMapLayer.

Definition at line 1251 of file qgsvectorlayer.cpp.

QList< QgsRelation > QgsVectorLayer::referencingRelations ( int  idx)

Get relations, where the foreign key is on this layer.

Parameters
idxOnly get relations, where idx forms part of the foreign key
Returns
A list of relations

Definition at line 3610 of file qgsvectorlayer.cpp.

void QgsVectorLayer::reload ( )
virtual

Synchronises with changes in the datasource.

Reimplemented from QgsMapLayer.

Definition at line 397 of file qgsvectorlayer.cpp.

void QgsVectorLayer::remAttributeAlias ( int  attIndex)

Removes an alias (a display name) for attributes to display in dialogs.

Definition at line 2047 of file qgsvectorlayer.cpp.

void QgsVectorLayer::removeExpressionField ( int  index)

Remove an expression field.

Parameters
indexThe index of the field
Note
added in 2.6

Definition at line 2784 of file qgsvectorlayer.cpp.

void QgsVectorLayer::removeJoin ( const QString &  joinLayerId)

Removes a vector layer join.

Definition at line 2766 of file qgsvectorlayer.cpp.

int QgsVectorLayer::removePolygonIntersections ( QgsGeometry geom,
QgsFeatureIds  ignoreFeatures = QgsFeatureIds() 
)

Changes the specified geometry such that it has no intersections with other polygon (or multipolygon) geometries in this vector layer.

Parameters
geomgeometry to modify
ignoreFeatureslist of feature ids where intersections should be ignored
Returns
0 in case of success
Deprecated:
since 2.2 - not being used for "avoid intersections" functionality anymore

Definition at line 1124 of file qgsvectorlayer.cpp.

void QgsVectorLayer::removeSelection ( )
slot

Clear selection.

See also
setSelectedFeatures(const QgsFeatureIds&)

Definition at line 561 of file qgsvectorlayer.cpp.

QgsFeatureRendererV2 * QgsVectorLayer::rendererV2 ( )

Return renderer V2.

Definition at line 2700 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::rollBack ( bool  deleteBuffer = true)

Stop editing and discard the edits.

Parameters
deleteBufferwhether to delete editing buffer

Definition at line 2252 of file qgsvectorlayer.cpp.

void QgsVectorLayer::saveLayerToProject ( )
signal
void QgsVectorLayer::saveStyleToDatabase ( QString  name,
QString  description,
bool  useAsDefault,
QString  uiFileContent,
QString &  msgError 
)
virtual

Save named and sld style of the layer to the style table in the db.

Parameters
name
description
useAsDefault
uiFileContent
msgError

Definition at line 3714 of file qgsvectorlayer.cpp.

void QgsVectorLayer::select ( QgsRectangle rect,
bool  addToSelection 
)

Select features found within the search rectangle (in layer's coordinates)

Parameters
rectThe search rectangle
addToSelectionIf set to true will not clear before selecting
See also
invertSelectionInRectangle(QgsRectangle & rect)

Definition at line 460 of file qgsvectorlayer.cpp.

void QgsVectorLayer::select ( const QgsFeatureId featureId)
slot

Select feature by its ID.

Parameters
featureIdThe id of the feature to select
See also
select(QgsFeatureIds)

Definition at line 432 of file qgsvectorlayer.cpp.

void QgsVectorLayer::select ( const QgsFeatureIds featureIds)
slot

Select features by their ID.

Parameters
featureIdsThe ids of the features to select
See also
select(QgsFeatureId)

Definition at line 439 of file qgsvectorlayer.cpp.

void QgsVectorLayer::selectAll ( )

Select all the features.

Definition at line 510 of file qgsvectorlayer.cpp.

int QgsVectorLayer::selectedFeatureCount ( )

The number of features that are selected in this layer.

Returns
See description

Definition at line 2298 of file qgsvectorlayer.cpp.

QgsFeatureList QgsVectorLayer::selectedFeatures ( )

Get a copy of the user-selected features.

Returns
A list of QgsFeature 's
See also
selectedFeaturesIds()
selectedFeaturesIterator() which is more memory friendly when handling large selections

Definition at line 2308 of file qgsvectorlayer.cpp.

const QgsFeatureIds & QgsVectorLayer::selectedFeaturesIds ( ) const

Return reference to identifiers of selected features.

Returns
A list of QgsFeatureId 's
See also
selectedFeatures()

Definition at line 2303 of file qgsvectorlayer.cpp.

QgsFeatureIterator QgsVectorLayer::selectedFeaturesIterator ( QgsFeatureRequest  request = QgsFeatureRequest())

Get an iterator of the selected features.

Parameters
requestYou may specify a request, e.g. to limit the set of requested attributes. Any filter on the request will be discarded.
Returns
Iterator over the selected features
See also
selectedFeaturesIds()
selectedFeatures()

Definition at line 2323 of file qgsvectorlayer.cpp.

void QgsVectorLayer::selectionChanged ( const QgsFeatureIds  selected,
const QgsFeatureIds  deselected,
const bool  clearAndSelect 
)
signal

This signal is emitted when selection was changed.

Parameters
selectedNewly selected feature ids
deselectedIds of all features which have previously been selected but are not any more
clearAndSelectIn case this is set to true, the old selection was dismissed and the new selection corresponds to selected
void QgsVectorLayer::selectionChanged ( )
signal

This signal is emitted when selection was changed.

void QgsVectorLayer::setAnnotationForm ( const QString &  ui)

set annotation form for layer

Definition at line 2622 of file qgsvectorlayer.cpp.

void QgsVectorLayer::setCheckedState ( int  idx,
QString  checked,
QString  notChecked 
)

Set string representing 'true' for a checkbox.

Deprecated:
Use setEditorWidgetV2Config() instead

Definition at line 2743 of file qgsvectorlayer.cpp.

void QgsVectorLayer::setCoordinateSystem ( )

Setup the coordinate system transformation for the layer.

Definition at line 2503 of file qgsvectorlayer.cpp.

void QgsVectorLayer::setDiagramLayerSettings ( const QgsDiagramLayerSettings s)

Definition at line 3300 of file qgsvectorlayer.cpp.

void QgsVectorLayer::setDiagramRenderer ( QgsDiagramRendererV2 r)

Sets diagram rendering object (takes ownership)

Definition at line 588 of file qgsvectorlayer.cpp.

void QgsVectorLayer::setDisplayExpression ( const QString &  displayExpression)

Set the preview expression, used to create a human readable preview string.

Used e.g. in the attribute table feature list. Uses QgsExpression.

Parameters
displayExpressionThe expression which will be used to preview features for this layer

Definition at line 2529 of file qgsvectorlayer.cpp.

void QgsVectorLayer::setDisplayField ( QString  fldName = "")

Set the primary display field to be used in the identify results dialog.

sets the preferred display field based on some fuzzy logic

Definition at line 255 of file qgsvectorlayer.cpp.

void QgsVectorLayer::setEditForm ( QString  ui)

set edit form

Definition at line 2609 of file qgsvectorlayer.cpp.

void QgsVectorLayer::setEditFormInit ( QString  function)

set python function for edit form initialization

Definition at line 2632 of file qgsvectorlayer.cpp.

void QgsVectorLayer::setEditorLayout ( EditorLayout  editorLayout)

set the active layout for the attribute editor for this layer

Definition at line 2589 of file qgsvectorlayer.cpp.

void QgsVectorLayer::setEditorWidgetV2 ( int  attrIdx,
const QString &  widgetType 
)

Set the editor widget type for a field.

QGIS ships the following widget types, additional types may be available depending on plugins.

Parameters
attrIdxIndex of the field
widgetTypeType id of the editor widget to use

Definition at line 2594 of file qgsvectorlayer.cpp.

void QgsVectorLayer::setEditorWidgetV2Config ( int  attrIdx,
const QgsEditorWidgetConfig config 
)

Set the editor widget config for a field.

Python: Will accept a map.

Example:

1 layer.setEditorWidgetV2Config( 1, { 'Layer': 'otherlayerid_1234', 'Key': 'Keyfield', 'Value': 'ValueField' } )
Parameters
attrIdxIndex of the field
configThe config to set for this field
See also
setEditorWidgetV2() for a list of widgets and choose the widget to see the available options.

Definition at line 2599 of file qgsvectorlayer.cpp.

void QgsVectorLayer::setEditType ( int  idx,
EditType  edit 
)

Get edit type.

Deprecated:
Use setEditorWidgetV2() instead

Definition at line 2572 of file qgsvectorlayer.cpp.

void QgsVectorLayer::setExcludeAttributesWFS ( const QSet< QString > &  att)
inline

Definition at line 1199 of file qgsvectorlayer.h.

void QgsVectorLayer::setExcludeAttributesWMS ( const QSet< QString > &  att)
inline

Definition at line 1196 of file qgsvectorlayer.h.

void QgsVectorLayer::setExtent ( const QgsRectangle rect)
protectedvirtual

Set the extent.

Reimplemented from QgsMapLayer.

Definition at line 808 of file qgsvectorlayer.cpp.

void QgsVectorLayer::setFeatureBlendMode ( const QPainter::CompositionMode &  blendMode)

Write blend mode for features.

Definition at line 3038 of file qgsvectorlayer.cpp.

void QgsVectorLayer::setFeatureFormSuppress ( QgsVectorLayer::FeatureFormSuppress  s)
inline

Set type of feature form pop-up suppression after feature creation (overrides app setting)

Note
added in 2.1

Definition at line 1328 of file qgsvectorlayer.h.

void QgsVectorLayer::setFieldEditable ( int  idx,
bool  editable 
)

set edit widget editable

Definition at line 2686 of file qgsvectorlayer.cpp.

void QgsVectorLayer::setLabelOnTop ( int  idx,
bool  onTop 
)

label widget on top

Definition at line 2693 of file qgsvectorlayer.cpp.

void QgsVectorLayer::setLayerTransparency ( int  layerTransparency)

Write transparency for layer.

Definition at line 3051 of file qgsvectorlayer.cpp.

void QgsVectorLayer::setProviderEncoding ( const QString &  encoding)

Sets the textencoding of the data provider.

Definition at line 579 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::setReadOnly ( bool  readonly = true)

Make layer read-only (editing disabled) or not.

Returns
false if the layer is in editing yet

Definition at line 2549 of file qgsvectorlayer.cpp.

void QgsVectorLayer::setRendererV2 ( QgsFeatureRendererV2 r)

Set renderer V2.

Definition at line 2705 of file qgsvectorlayer.cpp.

void QgsVectorLayer::setSelectedFeatures ( const QgsFeatureIds ids)

Change selection to the new set of features.

Dismisses the current selection. Will emit the selectionChanged( QgsFeatureIds, QgsFeatureIds, bool ) signal with the clearAndSelect flag set.

Parameters
idsThe ids which will be the new selection

Definition at line 2289 of file qgsvectorlayer.cpp.

void QgsVectorLayer::setSimplifyMethod ( const QgsVectorSimplifyMethod simplifyMethod)
inline

Set the simplification settings for fast rendering of features.

Note
added in 2.2

Definition at line 1457 of file qgsvectorlayer.h.

bool QgsVectorLayer::setSubsetString ( QString  subset)
virtual

Set the string (typically sql) used to define a subset of the layer.

Parameters
subsetThe subset string. This may be the where clause of a sql statement or other defintion string specific to the underlying dataprovider and data store.
Returns
true, when setting the subset string was successful, false otherwise

Definition at line 906 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::simplifyDrawingCanbeApplied ( const QgsRenderContext renderContext,
QgsVectorSimplifyMethod::SimplifyHint  simplifyHint 
) const

Returns whether the VectorLayer can apply the specified simplification hint.

Note
Do not use in 3rd party code - may be removed in future version!
added in 2.2

Definition at line 926 of file qgsvectorlayer.cpp.

const QgsVectorSimplifyMethod& QgsVectorLayer::simplifyMethod ( ) const
inline

Returns the simplification settings for fast rendering of features.

Note
added in 2.2

Definition at line 1461 of file qgsvectorlayer.h.

bool QgsVectorLayer::snapPoint ( QgsPoint point,
double  tolerance 
)

Snaps a point to the closest vertex if there is one within the snapping tolerance.

Parameters
pointThe point which is set to the position of a vertex if there is one within the snapping tolerance. If there is no point within this tolerance, point is left unchanged.
toleranceThe snapping tolerance
Returns
true if the point has been snapped, false if no vertex within search tolerance

Definition at line 2356 of file qgsvectorlayer.cpp.

int QgsVectorLayer::snapWithContext ( const QgsPoint startPoint,
double  snappingTolerance,
QMultiMap< double, QgsSnappingResult > &  snappingResults,
QgsSnapper::SnappingType  snap_to 
)

Snaps to segment or vertex within given tolerance.

Parameters
startPointpoint to snap (in layer coordinates)
snappingTolerancedistance tolerance for snapping
snappingResultssnapping results. Key is the distance between startPoint and snapping target
snap_toto segment / to vertex
Returns
0 in case of success

Definition at line 2381 of file qgsvectorlayer.cpp.

int QgsVectorLayer::splitFeatures ( const QList< QgsPoint > &  splitLine,
bool  topologicalEditing = false 
)

Splits features cut by the given line.

Parameters
splitLineline that splits the layer features
topologicalEditingtrue if topological editing is enabled
Returns
0 in case of success, 4 if there is a selection but no feature split

Definition at line 1115 of file qgsvectorlayer.cpp.

int QgsVectorLayer::splitParts ( const QList< QgsPoint > &  splitLine,
bool  topologicalEditing = false 
)

Splits parts cut by the given line.

Parameters
splitLineline that splits the layer features
topologicalEditingtrue if topological editing is enabled
Returns
0 in case of success, 4 if there is a selection but no feature split

Definition at line 1106 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::startEditing ( )

Make layer editable.

Definition at line 1206 of file qgsvectorlayer.cpp.

QString QgsVectorLayer::storageType ( ) const

Returns the permanent storage type for this layer as a friendly name.

Definition at line 218 of file qgsvectorlayer.cpp.

QString QgsVectorLayer::subsetString ( )
virtual

Get the string (typically sql) used to define a subset of the layer.

Returns
The subset string or QString::null if not implemented by the provider

Definition at line 896 of file qgsvectorlayer.cpp.

int QgsVectorLayer::translateFeature ( QgsFeatureId  featureId,
double  dx,
double  dy 
)

Translates feature by dx, dy.

Parameters
featureIdid of the feature to translate
dxtranslation of x-coordinate
dytranslation of y-coordinate
Returns
0 in case of success

Definition at line 1097 of file qgsvectorlayer.cpp.

void QgsVectorLayer::uniqueValues ( int  index,
QList< QVariant > &  uniqueValues,
int  limit = -1 
)

Returns unique values for column.

Parameters
indexcolumn index for attribute
uniqueValuesout: result list
limitmaximum number of values to return (-1 if unlimited)

Definition at line 2825 of file qgsvectorlayer.cpp.

void QgsVectorLayer::updatedFields ( )
signal

Is emitted, whenever the fields available from this layer have been changed.

This can be due to manually adding attributes or due to a join.

void QgsVectorLayer::updateExtents ( )
virtualslot

Update the extents for the layer.

This is necessary if features are added/deleted or the layer has been subsetted.

Definition at line 803 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::updateFeature ( QgsFeature f)

Updates an existing feature.

This method needs to query the datasource on every call. Consider using changeAttributeValue() or changeGeometry() instead.

Parameters
fFeature to update
Returns
True in case of success and False in case of error

Definition at line 964 of file qgsvectorlayer.cpp.

void QgsVectorLayer::updateFields ( )

Assembles mUpdatedFields considering provider fields, joined fields and added fields.

Definition at line 2792 of file qgsvectorlayer.cpp.

QMap< QString, QVariant > QgsVectorLayer::valueMap ( int  idx)

Access value map.

Deprecated:
Use editorWidgetV2Config() instead

Definition at line 2637 of file qgsvectorlayer.cpp.

QgsVectorLayer::ValueRelationData QgsVectorLayer::valueRelation ( int  idx)

Access value relation widget data.

Definition at line 3589 of file qgsvectorlayer.cpp.

const QList< QgsVectorJoinInfo > & QgsVectorLayer::vectorJoins ( ) const

Definition at line 2771 of file qgsvectorlayer.cpp.

QSize QgsVectorLayer::widgetSize ( int  idx)

Access widget size for photo and webview widget.

Deprecated:
Use setEditorWidgetV2Config() instead

Definition at line 2657 of file qgsvectorlayer.cpp.

QGis::WkbType QgsVectorLayer::wkbType ( ) const

Returns the WKBType or WKBUnknown in case of error.

Definition at line 651 of file qgsvectorlayer.cpp.

void QgsVectorLayer::writeCustomSymbology ( QDomElement &  element,
QDomDocument &  doc,
QString &  errorMessage 
) const
signal

Signal emitted whenever the symbology (QML-file) for this layer is being written.

If there is custom style information you want to save to the file, you can connect to this signal and update the element accordingly.

Parameters
elementThe XML element where you can add additional style information to.
docThe XML document that you can use to create new XML nodes.
errorMessageWrite error messages into this string.
bool QgsVectorLayer::writeSld ( QDomNode &  node,
QDomDocument &  doc,
QString &  errorMessage 
) const

Definition at line 1995 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::writeSymbology ( QDomNode &  node,
QDomDocument &  doc,
QString &  errorMessage 
) const
virtual

Write the symbology for the layer into the docment provided.

Parameters
nodethe node that will have the style element added to it.
docthe document that will have the QDomNode added.
errorMessagereference to string that will be updated with any error messages
Returns
true in case of success.

Implements QgsMapLayer.

Definition at line 1768 of file qgsvectorlayer.cpp.

bool QgsVectorLayer::writeXml ( QDomNode &  layer_node,
QDomDocument &  doc 
)
virtual

write vector layer specific state to project file Dom node.

Note
Called by QgsMapLayer::writeXML().

Reimplemented from QgsMapLayer.

Definition at line 1441 of file qgsvectorlayer.cpp.

Friends And Related Function Documentation

friend class QgsVectorLayerEditBuffer
friend

Definition at line 1795 of file qgsvectorlayer.h.

friend class QgsVectorLayerFeatureSource
friend

Definition at line 1818 of file qgsvectorlayer.h.


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