QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgsvectorlayer.h
Go to the documentation of this file.
1 
2 /***************************************************************************
3  -------------------
4  begin : Oct 29, 2003
5  copyright : (C) 2003 by Gary E.Sherman
6  email : sherman at mrcc.com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSVECTORLAYER_H
19 #define QGSVECTORLAYER_H
20 
21 
22 #include "qgis_core.h"
23 #include <QMap>
24 #include <QSet>
25 #include <QList>
26 #include <QStringList>
27 #include <QFont>
28 #include <QMutex>
29 
30 #include "qgis.h"
31 #include "qgsmaplayer.h"
32 #include "qgsfeature.h"
33 #include "qgsfeaturerequest.h"
34 #include "qgsfeaturesource.h"
35 #include "qgsfields.h"
36 #include "qgsvectordataprovider.h"
39 #include "qgseditformconfig.h"
41 #include "qgsaggregatecalculator.h"
42 #include "qgsfeatureiterator.h"
45 #include "qgsexpressioncontext.h"
46 
47 class QPainter;
48 class QImage;
49 
51 class QgsActionManager;
53 class QgsCurve;
55 class QgsDiagramRenderer;
58 class QgsFeatureRenderer;
59 class QgsGeometry;
60 class QgsGeometryVertexIndex;
61 class QgsMapToPixel;
62 class QgsRectangle;
63 class QgsRectangle;
64 class QgsRelation;
65 class QgsWeakRelation;
66 class QgsRelationManager;
69 class QgsSymbol;
76 class QgsPoint;
77 class QgsFeedback;
79 class QgsAuxiliaryLayer;
80 class QgsGeometryOptions;
83 
84 typedef QList<int> QgsAttributeList;
85 typedef QSet<int> QgsAttributeIds;
86 
87 // TODO QGIS4: Remove virtual from non-inherited methods (like isModified)
88 
386 {
387  Q_OBJECT
388 
389  Q_PROPERTY( QString subsetString READ subsetString WRITE setSubsetString NOTIFY subsetStringChanged )
390  Q_PROPERTY( QString displayExpression READ displayExpression WRITE setDisplayExpression NOTIFY displayExpressionChanged )
391  Q_PROPERTY( QString mapTipTemplate READ mapTipTemplate WRITE setMapTipTemplate NOTIFY mapTipTemplateChanged )
392  Q_PROPERTY( QgsEditFormConfig editFormConfig READ editFormConfig WRITE setEditFormConfig NOTIFY editFormConfigChanged )
393  Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged )
394  Q_PROPERTY( double opacity READ opacity WRITE setOpacity NOTIFY opacityChanged )
395 
396  public:
397 
400  {
401  Success = 0,
402  EmptyGeometry = 1,
403  EditFailed = 2,
404  FetchFeatureFailed = 3,
405  InvalidLayer = 4,
406  };
407  Q_ENUM( EditResult )
408 
409 
411  {
416  };
417  Q_ENUM( SelectBehavior )
418 
419 
424  {
425 
429  explicit LayerOptions( bool loadDefaultStyle = true,
430  bool readExtentFromXml = false )
431  : loadDefaultStyle( loadDefaultStyle )
432  , readExtentFromXml( readExtentFromXml )
433  {}
434 
439  explicit LayerOptions( const QgsCoordinateTransformContext &transformContext,
440  bool loadDefaultStyle = true,
441  bool readExtentFromXml = false
442  )
443  : loadDefaultStyle( loadDefaultStyle )
444  , readExtentFromXml( readExtentFromXml )
445  , transformContext( transformContext )
446  {}
447 
449  bool loadDefaultStyle = true;
450 
455  bool readExtentFromXml = false;
456 
462 
475 
488 
502  bool skipCrsValidation = false;
503 
504  };
505 
510  struct CORE_EXPORT DeleteContext
511  {
512 
516  explicit DeleteContext( bool cascade = false, QgsProject *project = nullptr ): cascade( cascade ), project( project ) {}
517 
518  QList<QgsVectorLayer *> handledLayers() const;
519  QgsFeatureIds handledFeatures( QgsVectorLayer *layer ) const;
520 
521  QMap<QgsVectorLayer *, QgsFeatureIds> mHandledFeatures SIP_SKIP;
522  bool cascade;
524  };
525 
539  explicit QgsVectorLayer( const QString &path = QString(), const QString &baseName = QString(),
540  const QString &providerLib = "ogr", const QgsVectorLayer::LayerOptions &options = QgsVectorLayer::LayerOptions() );
541 
542  ~QgsVectorLayer() override;
543 
545  QgsVectorLayer( const QgsVectorLayer &rhs ) = delete;
547  QgsVectorLayer &operator=( QgsVectorLayer const &rhs ) = delete;
548 
557  QgsVectorLayer *clone() const override SIP_FACTORY;
558 
563  QString storageType() const;
564 
568  QString capabilitiesString() const;
569 
573  QString dataComment() const;
574 
582  QString displayField() const;
583 
591  void setDisplayExpression( const QString &displayExpression );
592 
599  QString displayExpression() const;
600 
601  QgsVectorDataProvider *dataProvider() FINAL;
602  const QgsVectorDataProvider *dataProvider() const FINAL SIP_SKIP;
603 
607  QgsMapLayerTemporalProperties *temporalProperties() override;
608 
619  void setProviderEncoding( const QString &encoding );
620 
622  void setCoordinateSystem();
623 
629  bool addJoin( const QgsVectorLayerJoinInfo &joinInfo );
630 
635  bool removeJoin( const QString &joinLayerId );
636 
641  QgsVectorLayerJoinBuffer *joinBuffer() { return mJoinBuffer; }
642 
647  const QgsVectorLayerJoinBuffer *joinBuffer() const { return mJoinBuffer; } SIP_SKIP;
648 
649  const QList<QgsVectorLayerJoinInfo> vectorJoins() const;
650 
659  bool setDependencies( const QSet<QgsMapLayerDependency> &layers ) FINAL;
660 
668  QSet<QgsMapLayerDependency> dependencies() const FINAL;
669 
680  int addExpressionField( const QString &exp, const QgsField &fld );
681 
689  void removeExpressionField( int index );
690 
700  QString expressionField( int index ) const;
701 
711  void updateExpressionField( int index, const QString &exp );
712 
719  QgsActionManager *actions() { return mActions; }
720 
726  const QgsActionManager *actions() const SIP_SKIP { return mActions; }
727 
732  QgsVectorLayerServerProperties *serverProperties() const { return mServerProperties.get(); }
733 
739  int selectedFeatureCount() const;
740 
750  Q_INVOKABLE void selectByRect( QgsRectangle &rect, QgsVectorLayer::SelectBehavior behavior = QgsVectorLayer::SetSelection );
751 
761  Q_INVOKABLE void selectByExpression( const QString &expression, QgsVectorLayer::SelectBehavior behavior = QgsVectorLayer::SetSelection );
762 
773  Q_INVOKABLE void selectByIds( const QgsFeatureIds &ids, QgsVectorLayer::SelectBehavior behavior = QgsVectorLayer::SetSelection );
774 
786  Q_INVOKABLE void modifySelection( const QgsFeatureIds &selectIds, const QgsFeatureIds &deselectIds );
787 
789  Q_INVOKABLE void invertSelection();
790 
792  Q_INVOKABLE void selectAll();
793 
801  Q_INVOKABLE void invertSelectionInRectangle( QgsRectangle &rect );
802 
815  Q_INVOKABLE QgsFeatureList selectedFeatures() const;
816 
832  QgsFeatureIterator getSelectedFeatures( QgsFeatureRequest request = QgsFeatureRequest() ) const;
833 
841  Q_INVOKABLE const QgsFeatureIds &selectedFeatureIds() const;
842 
844  Q_INVOKABLE QgsRectangle boundingBoxOfSelected() const;
845 
853  bool labelsEnabled() const;
854 
864  void setLabelsEnabled( bool enabled );
865 
871  bool diagramsEnabled() const;
872 
874  void setDiagramRenderer( QgsDiagramRenderer *r SIP_TRANSFER );
875  const QgsDiagramRenderer *diagramRenderer() const { return mDiagramRenderer; }
876 
877  void setDiagramLayerSettings( const QgsDiagramLayerSettings &s );
878  const QgsDiagramLayerSettings *diagramLayerSettings() const { return mDiagramLayerSettings; }
879 
881  QgsFeatureRenderer *renderer() { return mRenderer; }
882 
887  const QgsFeatureRenderer *renderer() const SIP_SKIP { return mRenderer; }
888 
893  void setRenderer( QgsFeatureRenderer *r SIP_TRANSFER );
894 
896  Q_INVOKABLE QgsWkbTypes::GeometryType geometryType() const;
897 
899  Q_INVOKABLE QgsWkbTypes::Type wkbType() const FINAL;
900 
901  QgsCoordinateReferenceSystem sourceCrs() const FINAL;
902  QString sourceName() const FINAL;
903 
908  bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context ) FINAL;
909 
914  bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const FINAL;
915 
916  QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const FINAL;
917  QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const FINAL;
918 
923  void resolveReferences( QgsProject *project ) FINAL;
924 
933  virtual void saveStyleToDatabase( const QString &name, const QString &description,
934  bool useAsDefault, const QString &uiFileContent,
935  QString &msgError SIP_OUT );
936 
946  virtual int listStylesInDatabase( QStringList &ids SIP_OUT, QStringList &names SIP_OUT,
947  QStringList &descriptions SIP_OUT, QString &msgError SIP_OUT );
948 
952  virtual QString getStyleFromDatabase( const QString &styleId, QString &msgError SIP_OUT );
953 
961  virtual bool deleteStyleFromDatabase( const QString &styleId, QString &msgError SIP_OUT );
962 
970  virtual QString loadNamedStyle( const QString &theURI, bool &resultFlag SIP_OUT, bool loadFromLocalDb,
971  QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories );
972 
977  QString loadNamedStyle( const QString &theURI, bool &resultFlag SIP_OUT,
978  QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) FINAL;
979 
993  bool loadAuxiliaryLayer( const QgsAuxiliaryStorage &storage, const QString &key = QString() );
994 
1004  void setAuxiliaryLayer( QgsAuxiliaryLayer *layer SIP_TRANSFER = nullptr );
1005 
1011  QgsAuxiliaryLayer *auxiliaryLayer();
1012 
1018  const QgsAuxiliaryLayer *auxiliaryLayer() const SIP_SKIP;
1019 
1028  bool readSymbology( const QDomNode &layerNode, QString &errorMessage,
1029  QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) FINAL;
1030 
1039  bool readStyle( const QDomNode &node, QString &errorMessage,
1040  QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) FINAL;
1041 
1051  bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
1052  const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const FINAL;
1053 
1063  bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
1064  const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const FINAL;
1065 
1074  bool writeSld( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsStringMap &props = QgsStringMap() ) const;
1075 
1076  bool readSld( const QDomNode &node, QString &errorMessage ) FINAL;
1077 
1083  long featureCount( const QString &legendKey ) const;
1084 
1091  QgsFeatureIds symbolFeatureIds( const QString &legendKey ) const;
1092 
1103  FeatureAvailability hasFeatures() const FINAL;
1104 
1116  Q_DECL_DEPRECATED void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, bool loadDefaultStyleFlag = false ) SIP_DEPRECATED;
1117 
1130  void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, bool loadDefaultStyleFlag = false ) override;
1131 
1132  QString loadDefaultStyle( bool &resultFlag SIP_OUT ) FINAL;
1133 
1147  QgsVectorLayerFeatureCounter *countSymbolFeatures( bool storeSymbolFids = false );
1148 
1156  virtual bool setSubsetString( const QString &subset );
1157 
1162  virtual QString subsetString() const;
1163 
1169  QgsFeatureIterator getFeatures( const QgsFeatureRequest &request = QgsFeatureRequest() ) const FINAL;
1170 
1174  inline QgsFeatureIterator getFeatures( const QString &expression )
1175  {
1176  return getFeatures( QgsFeatureRequest( expression ) );
1177  }
1178 
1183  inline QgsFeature getFeature( QgsFeatureId fid ) const
1184  {
1185  QgsFeature feature;
1186  getFeatures( QgsFeatureRequest( fid ) ).nextFeature( feature );
1187  return feature;
1188  }
1189 
1194  QgsGeometry getGeometry( QgsFeatureId fid ) const;
1195 
1200  {
1201  return getFeatures( QgsFeatureRequest( fids ) );
1202  }
1203 
1207  inline QgsFeatureIterator getFeatures( const QgsRectangle &rectangle )
1208  {
1209  return getFeatures( QgsFeatureRequest( rectangle ) );
1210  }
1211 
1212  bool addFeature( QgsFeature &feature, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() ) FINAL;
1213 
1239  bool updateFeature( QgsFeature &feature, bool skipDefaultValues = false );
1240 
1252  bool insertVertex( double x, double y, QgsFeatureId atFeatureId, int beforeVertex );
1253 
1265  bool insertVertex( const QgsPoint &point, QgsFeatureId atFeatureId, int beforeVertex );
1266 
1277  bool moveVertex( double x, double y, QgsFeatureId atFeatureId, int atVertex );
1278 
1289  bool moveVertex( const QgsPoint &p, QgsFeatureId atFeatureId, int atVertex ) SIP_PYNAME( moveVertexV2 );
1290 
1301  EditResult deleteVertex( QgsFeatureId featureId, int vertex );
1302 
1310  Q_INVOKABLE bool deleteSelectedFeatures( int *deletedCount = nullptr, DeleteContext *context = nullptr );
1311 
1332  Q_DECL_DEPRECATED QgsGeometry::OperationResult addRing( const QVector<QgsPointXY> &ring, QgsFeatureId *featureId = nullptr ) SIP_DEPRECATED;
1333 
1334 
1354  Q_INVOKABLE QgsGeometry::OperationResult addRing( const QgsPointSequence &ring, QgsFeatureId *featureId = nullptr );
1355 
1376  Q_INVOKABLE QgsGeometry::OperationResult addRing( QgsCurve *ring SIP_TRANSFER, QgsFeatureId *featureId = nullptr ) SIP_PYNAME( addCurvedRing );
1377 
1397  Q_DECL_DEPRECATED QgsGeometry::OperationResult addPart( const QList<QgsPointXY> &ring ) SIP_DEPRECATED;
1398 
1419  Q_DECL_DEPRECATED QgsGeometry::OperationResult addPart( const QVector<QgsPointXY> &ring ) SIP_PYNAME( addPartV2 ) SIP_DEPRECATED;
1420 
1440  Q_INVOKABLE QgsGeometry::OperationResult addPart( const QgsPointSequence &ring ) SIP_PYNAME( addPartV2 );
1441 
1449  Q_INVOKABLE QgsGeometry::OperationResult addPart( QgsCurve *ring SIP_TRANSFER ) SIP_PYNAME( addCurvedPart );
1450 
1462  Q_INVOKABLE int translateFeature( QgsFeatureId featureId, double dx, double dy );
1463 
1484  Q_DECL_DEPRECATED QgsGeometry::OperationResult splitParts( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false ) SIP_DEPRECATED;
1485 
1505  Q_INVOKABLE QgsGeometry::OperationResult splitParts( const QgsPointSequence &splitLine, bool topologicalEditing = false );
1506 
1527  Q_DECL_DEPRECATED QgsGeometry::OperationResult splitFeatures( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false ) SIP_DEPRECATED;
1528 
1548  Q_INVOKABLE QgsGeometry::OperationResult splitFeatures( const QgsPointSequence &splitLine, bool topologicalEditing = false );
1549 
1560  int addTopologicalPoints( const QgsGeometry &geom );
1561 
1575  Q_DECL_DEPRECATED int addTopologicalPoints( const QgsPointXY &p ) SIP_DEPRECATED;
1576 
1590  int addTopologicalPoints( const QgsPoint &p );
1591 
1598  const QgsAbstractVectorLayerLabeling *labeling() const SIP_SKIP { return mLabeling; }
1599 
1606  QgsAbstractVectorLayerLabeling *labeling() { return mLabeling; }
1607 
1612  void setLabeling( QgsAbstractVectorLayerLabeling *labeling SIP_TRANSFER );
1613 
1615  bool isEditable() const FINAL;
1616 
1618  bool isSpatial() const FINAL;
1619 
1621  virtual bool isModified() const;
1622 
1629  bool isAuxiliaryField( int index, int &srcIndex ) const;
1630 
1632  void reload() FINAL;
1633 
1638  QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) FINAL SIP_FACTORY;
1639 
1640  QgsRectangle extent() const FINAL;
1641  QgsRectangle sourceExtent() const FINAL;
1642 
1649  QgsFields fields() const FINAL;
1650 
1654  inline QgsAttributeList attributeList() const { return mFields.allAttributesList(); }
1655 
1659  QgsAttributeList primaryKeyAttributes() const;
1660 
1666  long featureCount() const FINAL;
1667 
1672  bool setReadOnly( bool readonly = true );
1673 
1694  bool changeGeometry( QgsFeatureId fid, QgsGeometry &geometry, bool skipDefaultValue = false );
1695 
1726  bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant(), bool skipDefaultValues = false );
1727 
1763  bool changeAttributeValues( QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues = QgsAttributeMap(), bool skipDefaultValues = false );
1764 
1774  bool addAttribute( const QgsField &field );
1775 
1781  void setFieldAlias( int index, const QString &aliasString );
1782 
1788  void removeFieldAlias( int index );
1789 
1800  bool renameAttribute( int index, const QString &newName );
1801 
1808  QString attributeAlias( int index ) const;
1809 
1811  QString attributeDisplayName( int index ) const;
1812 
1814  QgsStringMap attributeAliases() const;
1815 
1819  QSet<QString> excludeAttributesWms() const { return mExcludeAttributesWMS; }
1820 
1824  void setExcludeAttributesWms( const QSet<QString> &att ) { mExcludeAttributesWMS = att; }
1825 
1829  QSet<QString> excludeAttributesWfs() const { return mExcludeAttributesWFS; }
1830 
1834  void setExcludeAttributesWfs( const QSet<QString> &att ) { mExcludeAttributesWFS = att; }
1835 
1844  virtual bool deleteAttribute( int attr );
1845 
1853  bool deleteAttributes( const QList<int> &attrs );
1854 
1855  bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() ) FINAL;
1856 
1867  bool deleteFeature( QgsFeatureId fid, DeleteContext *context = nullptr );
1868 
1882  bool deleteFeatures( const QgsFeatureIds &fids, DeleteContext *context = nullptr );
1883 
1904  Q_INVOKABLE bool commitChanges();
1905 
1911  QStringList commitErrors() const;
1912 
1922  Q_INVOKABLE bool rollBack( bool deleteBuffer = true );
1923 
1930  QList<QgsRelation> referencingRelations( int idx ) const;
1931 
1938  QList<QgsWeakRelation> weakRelations( ) const SIP_SKIP;
1939 
1940 
1942  Q_INVOKABLE QgsVectorLayerEditBuffer *editBuffer() { return mEditBuffer; }
1943 
1948  const QgsVectorLayerEditBuffer *editBuffer() const SIP_SKIP { return mEditBuffer; }
1949 
1954  void beginEditCommand( const QString &text );
1955 
1957  void endEditCommand();
1958 
1960  void destroyEditCommand();
1961 
1964  {
1967  NoMarker
1968  };
1969 
1974  Q_DECL_DEPRECATED static void drawVertexMarker( double x, double y, QPainter &p, QgsVectorLayer::VertexMarkerType type, int vertexSize );
1975 
1984  void updateFields();
1985 
2000  QVariant defaultValue( int index, const QgsFeature &feature = QgsFeature(),
2001  QgsExpressionContext *context = nullptr ) const;
2002 
2014  void setDefaultValueDefinition( int index, const QgsDefaultValue &definition );
2015 
2026  QgsDefaultValue defaultValueDefinition( int index ) const;
2027 
2035  QgsFieldConstraints::Constraints fieldConstraints( int fieldIndex ) const;
2036 
2042  QMap< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrength> fieldConstraintsAndStrength( int fieldIndex ) const;
2043 
2053 
2061  void removeFieldConstraint( int index, QgsFieldConstraints::Constraint constraint );
2062 
2070  QString constraintExpression( int index ) const;
2071 
2079  QString constraintDescription( int index ) const;
2080 
2089  void setConstraintExpression( int index, const QString &expression, const QString &description = QString() );
2090 
2094  void setEditorWidgetSetup( int index, const QgsEditorWidgetSetup &setup );
2095 
2102  QgsEditorWidgetSetup editorWidgetSetup( int index ) const;
2103 
2115  QSet<QVariant> uniqueValues( int fieldIndex, int limit = -1 ) const FINAL;
2116 
2130  QStringList uniqueStringsMatching( int index, const QString &substring, int limit = -1,
2131  QgsFeedback *feedback = nullptr ) const;
2132 
2141  QVariant minimumValue( int index ) const FINAL;
2142 
2151  QVariant maximumValue( int index ) const FINAL;
2152 
2165  QVariant aggregate( QgsAggregateCalculator::Aggregate aggregate,
2166  const QString &fieldOrExpression,
2167  const QgsAggregateCalculator::AggregateParameters &parameters = QgsAggregateCalculator::AggregateParameters(),
2168  QgsExpressionContext *context = nullptr,
2169  bool *ok = nullptr,
2170  QgsFeatureIds *fids = nullptr ) const;
2171 
2173  void setFeatureBlendMode( QPainter::CompositionMode blendMode );
2175  QPainter::CompositionMode featureBlendMode() const;
2176 
2184  void setOpacity( double opacity );
2185 
2193  double opacity() const;
2194 
2195  QString htmlMetadata() const FINAL;
2196 
2201  void setSimplifyMethod( const QgsVectorSimplifyMethod &simplifyMethod ) { mSimplifyMethod = simplifyMethod; }
2202 
2207  inline const QgsVectorSimplifyMethod &simplifyMethod() const { return mSimplifyMethod; }
2208 
2214  bool simplifyDrawingCanbeApplied( const QgsRenderContext &renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint ) const;
2215 
2223  QgsConditionalLayerStyles *conditionalStyles() const;
2224 
2229  QgsAttributeTableConfig attributeTableConfig() const;
2230 
2235  void setAttributeTableConfig( const QgsAttributeTableConfig &attributeTableConfig );
2236 
2244  QString mapTipTemplate() const;
2245 
2253  void setMapTipTemplate( const QString &mapTipTemplate );
2254 
2255  QgsExpressionContext createExpressionContext() const FINAL;
2256 
2257  QgsExpressionContextScope *createExpressionContextScope() const FINAL SIP_FACTORY;
2258 
2266  QgsEditFormConfig editFormConfig() const;
2267 
2274  void setEditFormConfig( const QgsEditFormConfig &editFormConfig );
2275 
2283  void setReadExtentFromXml( bool readExtentFromXml );
2284 
2292  bool readExtentFromXml() const;
2293 
2299  bool isEditCommandActive() const { return mEditCommandActive; }
2300 
2306  QgsGeometryOptions *geometryOptions() const;
2307 
2325  bool allowCommit() const SIP_SKIP;
2326 
2344  void setAllowCommit( bool allowCommit ) SIP_SKIP;
2345 
2351  QgsStoredExpressionManager *storedExpressionManager() { return mStoredExpressionManager; }
2352 
2353  public slots:
2354 
2362  void select( QgsFeatureId featureId );
2363 
2371  Q_INVOKABLE void select( const QgsFeatureIds &featureIds );
2372 
2380  void deselect( QgsFeatureId featureId );
2381 
2389  Q_INVOKABLE void deselect( const QgsFeatureIds &featureIds );
2390 
2397  Q_INVOKABLE void removeSelection();
2398 
2409  void reselect();
2410 
2417  virtual void updateExtents( bool force = false );
2418 
2433  Q_INVOKABLE bool startEditing();
2434 
2440  virtual void setTransformContext( const QgsCoordinateTransformContext &transformContext ) override;
2441 
2442  SpatialIndexPresence hasSpatialIndex() const override;
2443 
2444  bool accept( QgsStyleEntityVisitorInterface *visitor ) const override;
2445 
2446  signals:
2447 
2455  void selectionChanged( const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect );
2456 
2458  void layerModified();
2459 
2465  void allowCommitChanged();
2466 
2468  void beforeModifiedCheck() const;
2469 
2471  void beforeEditingStarted();
2472 
2474  void editingStarted();
2475 
2477  void editingStopped();
2478 
2480  void beforeCommitChanges();
2481 
2483  void beforeRollBack();
2484 
2489  void afterRollBack();
2490 
2499  void attributeAdded( int idx );
2500 
2507  void beforeAddingExpressionField( const QString &fieldName );
2508 
2517  void attributeDeleted( int idx );
2518 
2525  void beforeRemovingExpressionField( int idx );
2526 
2532  void featureAdded( QgsFeatureId fid );
2533 
2542  void featureDeleted( QgsFeatureId fid );
2543 
2553  void featuresDeleted( const QgsFeatureIds &fids );
2554 
2559  void updatedFields();
2560 
2565  void subsetStringChanged();
2566 
2575  void attributeValueChanged( QgsFeatureId fid, int idx, const QVariant &value );
2576 
2584  void geometryChanged( QgsFeatureId fid, const QgsGeometry &geometry );
2585 
2587  void committedAttributesDeleted( const QString &layerId, const QgsAttributeList &deletedAttributes );
2589  void committedAttributesAdded( const QString &layerId, const QList<QgsField> &addedAttributes );
2591  void committedFeaturesAdded( const QString &layerId, const QgsFeatureList &addedFeatures );
2593  void committedFeaturesRemoved( const QString &layerId, const QgsFeatureIds &deletedFeatureIds );
2595  void committedAttributeValuesChanges( const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues );
2597  void committedGeometriesChanges( const QString &layerId, const QgsGeometryMap &changedGeometries );
2598 
2600  void labelingFontNotFound( QgsVectorLayer *layer, const QString &fontfamily );
2601 
2603  void featureBlendModeChanged( QPainter::CompositionMode blendMode );
2604 
2612  void opacityChanged( double opacity );
2613 
2619  void editCommandStarted( const QString &text );
2620 
2626  void editCommandEnded();
2627 
2633  void editCommandDestroyed();
2634 
2644  void readCustomSymbology( const QDomElement &element, QString &errorMessage );
2645 
2655  void writeCustomSymbology( QDomElement &element, QDomDocument &doc, QString &errorMessage ) const;
2656 
2662  void mapTipTemplateChanged();
2663 
2669  void displayExpressionChanged();
2670 
2674  void raiseError( const QString &msg );
2675 
2681  void editFormConfigChanged();
2682 
2689  void readOnlyChanged();
2690 
2696  void symbolFeatureCountMapChanged();
2697 
2698  protected:
2700  void setExtent( const QgsRectangle &rect ) FINAL;
2701 
2702  private slots:
2703  void invalidateSymbolCountedFlag();
2704  void onFeatureCounterCompleted();
2705  void onFeatureCounterTerminated();
2706  void onJoinedFieldsChanged();
2707  void onFeatureDeleted( QgsFeatureId fid );
2708  void onRelationsLoaded();
2709  void onSymbolsCounted();
2710  void onDirtyTransaction( const QString &sql, const QString &name );
2711  void emitDataChanged();
2712 
2713  private:
2714  void updateDefaultValues( QgsFeatureId fid, QgsFeature feature = QgsFeature() );
2715 
2719  bool isReadOnly() const FINAL;
2720 
2726  bool setDataProvider( QString const &provider, const QgsDataProvider::ProviderOptions &options );
2727 
2729  void readSldLabeling( const QDomNode &node );
2730 
2732  bool readSldTextSymbolizer( const QDomNode &node, QgsPalLayerSettings &settings ) const;
2733 
2735  QgsAbstractVectorLayerLabeling *readLabelingFromCustomProperties();
2736 
2737  bool deleteFeatureCascade( QgsFeatureId fid, DeleteContext *context = nullptr );
2738 
2739 #ifdef SIP_RUN
2740  QgsVectorLayer( const QgsVectorLayer &rhs );
2741 #endif
2742  QVariant minimumOrMaximumValue( int index, bool minimum ) const;
2744 
2745  private: // Private attributes
2746  QgsConditionalLayerStyles *mConditionalStyles = nullptr;
2747 
2749  QgsVectorDataProvider *mDataProvider = nullptr;
2750 
2752  QgsVectorLayerTemporalProperties *mTemporalProperties = nullptr;
2753 
2755  QString mDisplayExpression;
2756 
2757  QString mMapTipTemplate;
2758 
2760  QgsActionManager *mActions = nullptr;
2761 
2763  bool mReadOnly = false;
2764 
2770  QgsFeatureIds mSelectedFeatureIds;
2771 
2775  QgsFeatureIds mPreviousSelectedFeatureIds;
2776 
2778  QgsFields mFields;
2779 
2781  QgsStringMap mAttributeAliasMap;
2782 
2784  QMap<QString, QgsDefaultValue> mDefaultExpressionMap;
2785 
2787  QSet<int> mDefaultValueOnUpdateFields;
2788 
2790  QMap< QString, QgsFieldConstraints::Constraints > mFieldConstraints;
2791 
2793  QMap< QPair< QString, QgsFieldConstraints::Constraint >, QgsFieldConstraints::ConstraintStrength > mFieldConstraintStrength;
2794 
2796  QMap< QString, QPair< QString, QString > > mFieldConstraintExpressions;
2797 
2798  QMap< QString, QgsEditorWidgetSetup > mFieldWidgetSetups;
2799 
2801  QgsEditFormConfig mEditFormConfig;
2802 
2804  QSet<QString> mExcludeAttributesWMS;
2805 
2807  QSet<QString> mExcludeAttributesWFS;
2808 
2811 
2813  QgsFeatureRenderer *mRenderer = nullptr;
2814 
2816  QgsVectorSimplifyMethod mSimplifyMethod;
2817 
2819  QgsAbstractVectorLayerLabeling *mLabeling = nullptr;
2820 
2822  bool mLabelsEnabled = false;
2823 
2825  bool mLabelFontNotFoundNotified = false;
2826 
2828  QPainter::CompositionMode mFeatureBlendMode = QPainter::CompositionMode_SourceOver;
2829 
2831  double mLayerOpacity = 1.0;
2832 
2834  bool mVertexMarkerOnlyForSelection = false;
2835 
2836  QStringList mCommitErrors;
2837 
2839  QgsVectorLayerEditBuffer *mEditBuffer = nullptr;
2842 
2843  //stores information about joined layers
2844  QgsVectorLayerJoinBuffer *mJoinBuffer = nullptr;
2845 
2847  std::unique_ptr< QgsVectorLayerServerProperties > mServerProperties;
2848 
2850  QgsExpressionFieldBuffer *mExpressionFieldBuffer = nullptr;
2851 
2852  //diagram rendering object. 0 if diagram drawing is disabled
2853  QgsDiagramRenderer *mDiagramRenderer = nullptr;
2854 
2855  //stores infos about diagram placement (placement type, priority, position distance)
2856  QgsDiagramLayerSettings *mDiagramLayerSettings = nullptr;
2857 
2858  mutable bool mValidExtent = false;
2859  mutable bool mLazyExtent = true;
2860 
2862  std::unique_ptr<QgsAuxiliaryLayer> mAuxiliaryLayer;
2863 
2865  QString mAuxiliaryLayerKey;
2866 
2867  // Features in renderer classes counted
2868  bool mSymbolFeatureCounted = false;
2869 
2870  // Feature counts for each renderer legend key
2871  QHash<QString, long> mSymbolFeatureCountMap;
2872  QHash<QString, QgsFeatureIds> mSymbolFeatureIdMap;
2873 
2875  bool mEditCommandActive = false;
2876 
2877  bool mReadExtentFromXml;
2878  QgsRectangle mXmlExtent;
2879 
2880  QgsFeatureIds mDeletedFids;
2881 
2882  QgsAttributeTableConfig mAttributeTableConfig;
2883 
2884  mutable QMutex mFeatureSourceConstructorMutex;
2885 
2886  QgsVectorLayerFeatureCounter *mFeatureCounter = nullptr;
2887 
2888  std::unique_ptr<QgsGeometryOptions> mGeometryOptions;
2889 
2890  bool mAllowCommit = true;
2891 
2893  QgsStoredExpressionManager *mStoredExpressionManager = nullptr;
2894 
2896 
2898  bool mDataChangedFired = false;
2899 
2900  QList<QgsWeakRelation> mWeakRelations;
2901 };
2902 
2903 
2904 
2905 // clazy:excludeall=qstring-allocations
2906 
2907 #endif
QgsCurve
Abstract base class for curved geometry type.
Definition: qgscurve.h:35
QgsVectorLayerFeatureCounter
Definition: qgsvectorlayerfeaturecounter.h:33
QgsVectorLayer::VertexMarkerType
VertexMarkerType
Editing vertex markers.
Definition: qgsvectorlayer.h:1963
QgsExpressionContext
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Definition: qgsexpressioncontext.h:369
SIP_PYNAME
#define SIP_PYNAME(name)
Definition: qgis_sip.h:81
qgsfields.h
QgsVectorSimplifyMethod
Definition: qgsvectorsimplifymethod.h:29
QgsAggregateCalculator
Utility class for calculating aggregates for a field (or expression) over the features from a vector ...
Definition: qgsaggregatecalculator.h:44
QgsRelationManager
Definition: qgsrelationmanager.h:34
QgsCoordinateTransformContext
Definition: qgscoordinatetransformcontext.h:57
qgsfeaturerequest.h
QgsDefaultValue
The QgsDefaultValue class provides a container for managing client side default values for fields.
Definition: qgsdefaultvalue.h:48
QgsReadWriteContext
Definition: qgsreadwritecontext.h:34
QgsDataProvider
Definition: qgsdataprovider.h:41
QgsAuxiliaryLayer
Definition: qgsauxiliarystorage.h:60
QgsEditorWidgetSetup
Definition: qgseditorwidgetsetup.h:28
QgsPoint
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:37
QgsVectorLayer::LayerOptions::LayerOptions
LayerOptions(bool loadDefaultStyle=true, bool readExtentFromXml=false)
Constructor for LayerOptions.
Definition: qgsvectorlayer.h:429
QgsVectorLayer::DeleteContext::cascade
bool cascade
Definition: qgsvectorlayer.h:522
QgsPalLayerSettings
Definition: qgspallabeling.h:205
QgsVectorLayer::RemoveFromSelection
@ RemoveFromSelection
Remove from current selection.
Definition: qgsvectorlayer.h:415
SIP_OUT
#define SIP_OUT
Definition: qgis_sip.h:58
QgsVectorSimplifyMethod::SimplifyHint
SimplifyHint
Simplification flags for fast rendering of features.
Definition: qgsvectorsimplifymethod.h:50
QgsVectorLayer::DeleteContext
Context for cascade delete features.
Definition: qgsvectorlayer.h:510
qgsfeatureiterator.h
QgsFields
Definition: qgsfields.h:44
QgsVectorLayerServerProperties
Definition: qgsvectorlayerserverproperties.h:38
QgsVectorLayer::getFeatures
QgsFeatureIterator getFeatures(const QgsRectangle &rectangle)
Queries the layer for the features which intersect the specified rectangle.
Definition: qgsvectorlayer.h:1207
qgsfeature.h
QgsFeatureSource
Definition: qgsfeaturesource.h:37
qgis.h
QgsGeometryOptions
Definition: qgsgeometryoptions.h:35
QgsRenderContext
Definition: qgsrendercontext.h:57
QgsStyleEntityVisitorInterface
Definition: qgsstyleentityvisitor.h:33
QgsSingleSymbolRenderer
Definition: qgssinglesymbolrenderer.h:29
QgsWkbTypes::Type
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:68
QgsExpressionContextScopeGenerator
Definition: qgsexpressioncontextscopegenerator.h:28
QgsChangedAttributesMap
QMap< QgsFeatureId, QgsAttributeMap > QgsChangedAttributesMap
Definition: qgsfeature.h:558
QgsSymbol
Definition: qgssymbol.h:63
QgsVectorLayer::diagramRenderer
const QgsDiagramRenderer * diagramRenderer() const
Definition: qgsvectorlayer.h:875
QgsFieldConstraints::Constraint
Constraint
Constraints which may be present on a field.
Definition: qgsfieldconstraints.h:43
QgsConditionalLayerStyles
The QgsConditionalLayerStyles class holds conditional style information for a layer....
Definition: qgsconditionalstyle.h:38
FINAL
#define FINAL
Definition: qgis_sip.h:223
QgsAttributeList
QList< int > QgsAttributeList
Definition: qgsfield.h:26
QgsRectangle
Definition: qgsrectangle.h:41
QgsEditorWidgetWrapper
Definition: qgseditorwidgetwrapper.h:47
QgsProject
Definition: qgsproject.h:92
QgsVectorLayer::LayerOptions::fallbackCrs
QgsCoordinateReferenceSystem fallbackCrs
Fallback layer coordinate reference system.
Definition: qgsvectorlayer.h:487
QgsMapLayerRenderer
Definition: qgsmaplayerrenderer.h:50
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
qgsaggregatecalculator.h
SIP_DEPRECATED
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
QgsVectorLayer::DeleteContext::DeleteContext
DeleteContext(bool cascade=false, QgsProject *project=nullptr)
Constructor for DeleteContext.
Definition: qgsvectorlayer.h:516
QgsAttributeTableConfig
Definition: qgsattributetableconfig.h:36
QgsFeatureRequest
Definition: qgsfeaturerequest.h:75
qgsexpressioncontext.h
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
QgsVectorLayer::labeling
QgsAbstractVectorLayerLabeling * labeling()
Access to labeling configuration.
Definition: qgsvectorlayer.h:1606
QgsVectorLayer::AddToSelection
@ AddToSelection
Add selection to current selection.
Definition: qgsvectorlayer.h:413
QgsVectorLayer::LayerOptions::LayerOptions
LayerOptions(const QgsCoordinateTransformContext &transformContext, bool loadDefaultStyle=true, bool readExtentFromXml=false)
Constructor for LayerOptions.
Definition: qgsvectorlayer.h:439
QgsWkbTypes::Unknown
@ Unknown
Definition: qgswkbtypes.h:70
QgsFeedback
Definition: qgsfeedback.h:43
QgsAbstractGeometrySimplifier
Definition: qgsgeometrysimplifier.h:32
qgsmaplayer.h
QgsVectorLayerJoinBuffer
Definition: qgsvectorlayerjoinbuffer.h:36
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
qgsfeaturesource.h
qgsvectordataprovider.h
QgsFeatureList
QList< QgsFeature > QgsFeatureList
Definition: qgsfeature.h:572
QgsAttributeMap
QMap< int, QVariant > QgsAttributeMap
Definition: qgsattributes.h:38
QgsDiagramLayerSettings
Stores the settings for rendering of all diagrams for a layer.
Definition: qgsdiagramrenderer.h:60
qgsvectorsimplifymethod.h
QgsVectorLayerTemporalProperties
Definition: qgsvectorlayertemporalproperties.h:70
QgsDiagramRenderer
Evaluates and returns the diagram settings relating to a diagram for a specific feature.
Definition: qgsdiagramrenderer.h:683
QgsMapLayerTemporalProperties
Definition: qgsmaplayertemporalproperties.h:42
QgsVectorLayerJoinInfo
Definition: qgsvectorlayerjoininfo.h:33
QgsExpressionFieldBuffer
Definition: qgsexpressionfieldbuffer.h:35
QgsFieldConstraints::ConstraintStrengthHard
@ ConstraintStrengthHard
Constraint must be honored before feature can be accepted.
Definition: qgsfieldconstraints.h:67
QgsVectorLayer::SelectBehavior
SelectBehavior
Selection behavior.
Definition: qgsvectorlayer.h:410
QgsFeatureIds
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeatureid.h:34
QgsEditFormConfig
Definition: qgseditformconfig.h:37
QgsCoordinateReferenceSystem
Definition: qgscoordinatereferencesystem.h:206
QgsAbstractVectorLayerLabeling
Definition: qgsvectorlayerlabeling.h:41
QgsExpressionContextScope
Single scope for storing variables and functions for use within a QgsExpressionContext....
Definition: qgsexpressioncontext.h:111
QgsVectorLayer::simplifyMethod
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings for fast rendering of features.
Definition: qgsvectorlayer.h:2207
qgsexpressioncontextgenerator.h
QgsAttributeIds
QSet< int > QgsAttributeIds
Definition: qgsvectorlayer.h:85
QgsPointXY
Definition: qgspointxy.h:43
qgseditformconfig.h
QgsVectorLayer::SetSelection
@ SetSelection
Set selection, removing any existing selection.
Definition: qgsvectorlayer.h:412
QgsVectorLayer::LayerOptions
Setting options for loading vector layers.
Definition: qgsvectorlayer.h:423
QgsVectorLayer::diagramLayerSettings
const QgsDiagramLayerSettings * diagramLayerSettings() const
Definition: qgsvectorlayer.h:878
QgsVectorLayer::serverProperties
QgsVectorLayerServerProperties * serverProperties() const
Returns QGIS Server Properties of the vector layer.
Definition: qgsvectorlayer.h:732
QgsStringMap
QMap< QString, QString > QgsStringMap
Definition: qgis.h:714
QgsVectorLayer::DeleteContext::project
QgsProject * project
Definition: qgsvectorlayer.h:523
QgsFeatureRenderer
Definition: qgsrenderer.h:102
QgsWkbTypes::GeometryType
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:139
QgsVectorLayerEditPassthrough
Definition: qgsvectorlayereditpassthrough.h:35
QgsVectorLayer::IntersectSelection
@ IntersectSelection
Modify current selection to include only select features which match.
Definition: qgsvectorlayer.h:414
QgsPointSequence
QVector< QgsPoint > QgsPointSequence
Definition: qgsabstractgeometry.h:44
QgsGeometry
Definition: qgsgeometry.h:122
QgsVectorLayer::setExcludeAttributesWfs
void setExcludeAttributesWfs(const QSet< QString > &att)
A set of attributes that are not advertised in WFS requests with QGIS server.
Definition: qgsvectorlayer.h:1834
QgsMapToPixel
Definition: qgsmaptopixel.h:37
QgsVectorLayerEditBuffer
Definition: qgsvectorlayereditbuffer.h:36
QgsVectorLayer
Definition: qgsvectorlayer.h:385
QgsMapLayer
Definition: qgsmaplayer.h:81
QgsVectorLayer::setExcludeAttributesWms
void setExcludeAttributesWms(const QSet< QString > &att)
A set of attributes that are not advertised in WMS requests with QGIS server.
Definition: qgsvectorlayer.h:1824
QgsVectorLayerFeatureSource
Definition: qgsvectorlayerfeatureiterator.h:51
qgsattributetableconfig.h
QgsVectorLayer::renderer
const QgsFeatureRenderer * renderer() const
Returns const renderer.
Definition: qgsvectorlayer.h:887
QgsStoredExpressionManager
Definition: qgsstoredexpressionmanager.h:93
QgsVectorLayer::SemiTransparentCircle
@ SemiTransparentCircle
Definition: qgsvectorlayer.h:1965
QgsRelation
Definition: qgsrelation.h:41
QgsAuxiliaryStorage
Class providing some utility methods to manage auxiliary storage.
Definition: qgsauxiliarystorage.h:259
QgsVectorLayer::Cross
@ Cross
Definition: qgsvectorlayer.h:1966
QgsGeometryMap
QMap< QgsFeatureId, QgsGeometry > QgsGeometryMap
Definition: qgsfeature.h:567
QgsVectorDataProvider
Definition: qgsvectordataprovider.h:58
qgsexpressioncontextscopegenerator.h
QgsFeature
Definition: qgsfeature.h:55
QgsVectorLayer::editBuffer
const QgsVectorLayerEditBuffer * editBuffer() const
Buffer with uncommitted editing operations.
Definition: qgsvectorlayer.h:1948
QgsActionManager
Definition: qgsactionmanager.h:51
QgsVectorLayer::getFeature
QgsFeature getFeature(QgsFeatureId fid) const
Queries the layer for the feature with the given id.
Definition: qgsvectorlayer.h:1183
QgsVectorLayer::EditResult
EditResult
Result of an edit operation.
Definition: qgsvectorlayer.h:399
QgsFieldConstraints::ConstraintStrength
ConstraintStrength
Strength of constraints.
Definition: qgsfieldconstraints.h:64
QgsVectorLayer::getFeatures
QgsFeatureIterator getFeatures(const QgsFeatureIds &fids)
Queries the layer for the features with the given ids.
Definition: qgsvectorlayer.h:1199
QgsFeatureIterator
Definition: qgsfeatureiterator.h:263
QgsVectorLayer::joinBuffer
const QgsVectorLayerJoinBuffer * joinBuffer() const
Returns a const pointer on join buffer object.
Definition: qgsvectorlayer.h:647
QgsExpressionContextGenerator
Definition: qgsexpressioncontextgenerator.h:36
QgsWeakRelation
The QgsWeakRelation class represent a QgsRelation with possibly unresolved layers or unmatched fields...
Definition: qgsweakrelation.h:38
QgsFeatureSink
Definition: qgsfeaturesink.h:33
QgsVectorLayer::excludeAttributesWfs
QSet< QString > excludeAttributesWfs() const
A set of attributes that are not advertised in WFS requests with QGIS server.
Definition: qgsvectorlayer.h:1829
qgsvectorlayerserverproperties.h
QgsAttributeList
QList< int > QgsAttributeList
Definition: qgsvectorlayer.h:82
QgsFeatureId
qint64 QgsFeatureId
Definition: qgsfeatureid.h:25
QgsVectorLayer::actions
const QgsActionManager * actions() const
Returns all layer actions defined on this layer.
Definition: qgsvectorlayer.h:726
QgsVectorLayer::renderer
QgsFeatureRenderer * renderer()
Returns renderer.
Definition: qgsvectorlayer.h:881
QgsField
Definition: qgsfield.h:49