QGIS API Documentation  3.17.0-Master (7a14973234)
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 
387 {
388  Q_OBJECT
389 
390  Q_PROPERTY( QString subsetString READ subsetString WRITE setSubsetString NOTIFY subsetStringChanged )
391  Q_PROPERTY( QString displayExpression READ displayExpression WRITE setDisplayExpression NOTIFY displayExpressionChanged )
392  Q_PROPERTY( QString mapTipTemplate READ mapTipTemplate WRITE setMapTipTemplate NOTIFY mapTipTemplateChanged )
393  Q_PROPERTY( QgsEditFormConfig editFormConfig READ editFormConfig WRITE setEditFormConfig NOTIFY editFormConfigChanged )
394  Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged )
395  Q_PROPERTY( double opacity READ opacity WRITE setOpacity NOTIFY opacityChanged )
396 
397  public:
398 
401  {
402  Success = 0,
403  EmptyGeometry = 1,
404  EditFailed = 2,
405  FetchFeatureFailed = 3,
406  InvalidLayer = 4,
407  };
408  Q_ENUM( EditResult )
409 
410 
412  {
417  };
418  Q_ENUM( SelectBehavior )
419 
420 
425  {
426 
430  explicit LayerOptions( bool loadDefaultStyle = true,
431  bool readExtentFromXml = false )
432  : loadDefaultStyle( loadDefaultStyle )
433  , readExtentFromXml( readExtentFromXml )
434  {}
435 
440  explicit LayerOptions( const QgsCoordinateTransformContext &transformContext,
441  bool loadDefaultStyle = true,
442  bool readExtentFromXml = false
443  )
444  : loadDefaultStyle( loadDefaultStyle )
445  , readExtentFromXml( readExtentFromXml )
446  , transformContext( transformContext )
447  {}
448 
450  bool loadDefaultStyle = true;
451 
456  bool readExtentFromXml = false;
457 
463 
476 
489 
503  bool skipCrsValidation = false;
504 
505  };
506 
511  struct CORE_EXPORT DeleteContext
512  {
513 
517  explicit DeleteContext( bool cascade = false, QgsProject *project = nullptr ): cascade( cascade ), project( project ) {}
518 
525  QList<QgsVectorLayer *> handledLayers( bool includeAuxiliaryLayers = true ) const;
526 
530  QgsFeatureIds handledFeatures( QgsVectorLayer *layer ) const;
531 
532  QMap<QgsVectorLayer *, QgsFeatureIds> mHandledFeatures SIP_SKIP;
533  bool cascade;
535  };
536 
550  explicit QgsVectorLayer( const QString &path = QString(), const QString &baseName = QString(),
551  const QString &providerLib = "ogr", const QgsVectorLayer::LayerOptions &options = QgsVectorLayer::LayerOptions() );
552 
553  ~QgsVectorLayer() override;
554 
556  QgsVectorLayer( const QgsVectorLayer &rhs ) = delete;
558  QgsVectorLayer &operator=( QgsVectorLayer const &rhs ) = delete;
559 
568  QgsVectorLayer *clone() const override SIP_FACTORY;
569 
574  QString storageType() const;
575 
579  QString capabilitiesString() const;
580 
584  QString dataComment() const;
585 
593  QString displayField() const;
594 
602  void setDisplayExpression( const QString &displayExpression );
603 
610  QString displayExpression() const;
611 
612  QgsVectorDataProvider *dataProvider() FINAL;
613  const QgsVectorDataProvider *dataProvider() const FINAL SIP_SKIP;
614 
618  QgsMapLayerTemporalProperties *temporalProperties() override;
619 
630  void setProviderEncoding( const QString &encoding );
631 
633  void setCoordinateSystem();
634 
640  bool addJoin( const QgsVectorLayerJoinInfo &joinInfo );
641 
646  bool removeJoin( const QString &joinLayerId );
647 
652  QgsVectorLayerJoinBuffer *joinBuffer() { return mJoinBuffer; }
653 
658  const QgsVectorLayerJoinBuffer *joinBuffer() const { return mJoinBuffer; } SIP_SKIP;
659 
660  const QList<QgsVectorLayerJoinInfo> vectorJoins() const;
661 
670  bool setDependencies( const QSet<QgsMapLayerDependency> &layers ) FINAL;
671 
679  QSet<QgsMapLayerDependency> dependencies() const FINAL;
680 
691  int addExpressionField( const QString &exp, const QgsField &fld );
692 
700  void removeExpressionField( int index );
701 
711  QString expressionField( int index ) const;
712 
722  void updateExpressionField( int index, const QString &exp );
723 
730  QgsActionManager *actions() { return mActions; }
731 
737  const QgsActionManager *actions() const SIP_SKIP { return mActions; }
738 
743  QgsVectorLayerServerProperties *serverProperties() const { return mServerProperties.get(); }
744 
750  int selectedFeatureCount() const;
751 
761  Q_INVOKABLE void selectByRect( QgsRectangle &rect, QgsVectorLayer::SelectBehavior behavior = QgsVectorLayer::SetSelection );
762 
772  Q_INVOKABLE void selectByExpression( const QString &expression, QgsVectorLayer::SelectBehavior behavior = QgsVectorLayer::SetSelection );
773 
784  Q_INVOKABLE void selectByIds( const QgsFeatureIds &ids, QgsVectorLayer::SelectBehavior behavior = QgsVectorLayer::SetSelection );
785 
797  Q_INVOKABLE void modifySelection( const QgsFeatureIds &selectIds, const QgsFeatureIds &deselectIds );
798 
800  Q_INVOKABLE void invertSelection();
801 
803  Q_INVOKABLE void selectAll();
804 
812  Q_INVOKABLE void invertSelectionInRectangle( QgsRectangle &rect );
813 
826  Q_INVOKABLE QgsFeatureList selectedFeatures() const;
827 
843  QgsFeatureIterator getSelectedFeatures( QgsFeatureRequest request = QgsFeatureRequest() ) const;
844 
852  Q_INVOKABLE const QgsFeatureIds &selectedFeatureIds() const;
853 
855  Q_INVOKABLE QgsRectangle boundingBoxOfSelected() const;
856 
864  bool labelsEnabled() const;
865 
875  void setLabelsEnabled( bool enabled );
876 
882  bool diagramsEnabled() const;
883 
885  void setDiagramRenderer( QgsDiagramRenderer *r SIP_TRANSFER );
886  const QgsDiagramRenderer *diagramRenderer() const { return mDiagramRenderer; }
887 
888  void setDiagramLayerSettings( const QgsDiagramLayerSettings &s );
889  const QgsDiagramLayerSettings *diagramLayerSettings() const { return mDiagramLayerSettings; }
890 
892  QgsFeatureRenderer *renderer() { return mRenderer; }
893 
898  const QgsFeatureRenderer *renderer() const SIP_SKIP { return mRenderer; }
899 
904  void setRenderer( QgsFeatureRenderer *r SIP_TRANSFER );
905 
907  Q_INVOKABLE QgsWkbTypes::GeometryType geometryType() const;
908 
910  Q_INVOKABLE QgsWkbTypes::Type wkbType() const FINAL;
911 
912  QgsCoordinateReferenceSystem sourceCrs() const FINAL;
913  QString sourceName() const FINAL;
914 
919  bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context ) FINAL;
920 
925  bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const FINAL;
926 
927  QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const FINAL;
928  QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const FINAL;
929 
934  void resolveReferences( QgsProject *project ) FINAL;
935 
944  virtual void saveStyleToDatabase( const QString &name, const QString &description,
945  bool useAsDefault, const QString &uiFileContent,
946  QString &msgError SIP_OUT );
947 
957  virtual int listStylesInDatabase( QStringList &ids SIP_OUT, QStringList &names SIP_OUT,
958  QStringList &descriptions SIP_OUT, QString &msgError SIP_OUT );
959 
963  virtual QString getStyleFromDatabase( const QString &styleId, QString &msgError SIP_OUT );
964 
972  virtual bool deleteStyleFromDatabase( const QString &styleId, QString &msgError SIP_OUT );
973 
981  virtual QString loadNamedStyle( const QString &theURI, bool &resultFlag SIP_OUT, bool loadFromLocalDb,
982  QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories );
983 
988  QString loadNamedStyle( const QString &theURI, bool &resultFlag SIP_OUT,
989  QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) FINAL;
990 
1004  bool loadAuxiliaryLayer( const QgsAuxiliaryStorage &storage, const QString &key = QString() );
1005 
1015  void setAuxiliaryLayer( QgsAuxiliaryLayer *layer SIP_TRANSFER = nullptr );
1016 
1022  QgsAuxiliaryLayer *auxiliaryLayer();
1023 
1029  const QgsAuxiliaryLayer *auxiliaryLayer() const SIP_SKIP;
1030 
1039  bool readSymbology( const QDomNode &layerNode, QString &errorMessage,
1040  QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) FINAL;
1041 
1050  bool readStyle( const QDomNode &node, QString &errorMessage,
1051  QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) FINAL;
1052 
1062  bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
1063  const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const FINAL;
1064 
1074  bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
1075  const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const FINAL;
1076 
1085  bool writeSld( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsStringMap &props = QgsStringMap() ) const;
1086 
1087  bool readSld( const QDomNode &node, QString &errorMessage ) FINAL;
1088 
1094  long featureCount( const QString &legendKey ) const;
1095 
1102  QgsFeatureIds symbolFeatureIds( const QString &legendKey ) const;
1103 
1114  FeatureAvailability hasFeatures() const FINAL;
1115 
1127  Q_DECL_DEPRECATED void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, bool loadDefaultStyleFlag = false ) SIP_DEPRECATED;
1128 
1141  void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, bool loadDefaultStyleFlag = false ) override;
1142 
1143  QString loadDefaultStyle( bool &resultFlag SIP_OUT ) FINAL;
1144 
1158  QgsVectorLayerFeatureCounter *countSymbolFeatures( bool storeSymbolFids = false );
1159 
1167  virtual bool setSubsetString( const QString &subset );
1168 
1173  virtual QString subsetString() const;
1174 
1180  QgsFeatureIterator getFeatures( const QgsFeatureRequest &request = QgsFeatureRequest() ) const FINAL;
1181 
1185  inline QgsFeatureIterator getFeatures( const QString &expression )
1186  {
1187  return getFeatures( QgsFeatureRequest( expression ) );
1188  }
1189 
1194  inline QgsFeature getFeature( QgsFeatureId fid ) const
1195  {
1196  QgsFeature feature;
1197  getFeatures( QgsFeatureRequest( fid ) ).nextFeature( feature );
1198  return feature;
1199  }
1200 
1205  QgsGeometry getGeometry( QgsFeatureId fid ) const;
1206 
1211  {
1212  return getFeatures( QgsFeatureRequest( fids ) );
1213  }
1214 
1218  inline QgsFeatureIterator getFeatures( const QgsRectangle &rectangle )
1219  {
1220  return getFeatures( QgsFeatureRequest( rectangle ) );
1221  }
1222 
1223  bool addFeature( QgsFeature &feature, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() ) FINAL;
1224 
1250  bool updateFeature( QgsFeature &feature, bool skipDefaultValues = false );
1251 
1263  bool insertVertex( double x, double y, QgsFeatureId atFeatureId, int beforeVertex );
1264 
1276  bool insertVertex( const QgsPoint &point, QgsFeatureId atFeatureId, int beforeVertex );
1277 
1288  bool moveVertex( double x, double y, QgsFeatureId atFeatureId, int atVertex );
1289 
1300  bool moveVertex( const QgsPoint &p, QgsFeatureId atFeatureId, int atVertex ) SIP_PYNAME( moveVertexV2 );
1301 
1312  EditResult deleteVertex( QgsFeatureId featureId, int vertex );
1313 
1321  Q_INVOKABLE bool deleteSelectedFeatures( int *deletedCount = nullptr, DeleteContext *context = nullptr );
1322 
1343  Q_DECL_DEPRECATED QgsGeometry::OperationResult addRing( const QVector<QgsPointXY> &ring, QgsFeatureId *featureId = nullptr ) SIP_DEPRECATED;
1344 
1345 
1365  Q_INVOKABLE QgsGeometry::OperationResult addRing( const QgsPointSequence &ring, QgsFeatureId *featureId = nullptr );
1366 
1387  Q_INVOKABLE QgsGeometry::OperationResult addRing( QgsCurve *ring SIP_TRANSFER, QgsFeatureId *featureId = nullptr ) SIP_PYNAME( addCurvedRing );
1388 
1408  Q_DECL_DEPRECATED QgsGeometry::OperationResult addPart( const QList<QgsPointXY> &ring ) SIP_DEPRECATED;
1409 
1430  Q_DECL_DEPRECATED QgsGeometry::OperationResult addPart( const QVector<QgsPointXY> &ring ) SIP_PYNAME( addPartV2 ) SIP_DEPRECATED;
1431 
1451  Q_INVOKABLE QgsGeometry::OperationResult addPart( const QgsPointSequence &ring ) SIP_PYNAME( addPartV2 );
1452 
1460  Q_INVOKABLE QgsGeometry::OperationResult addPart( QgsCurve *ring SIP_TRANSFER ) SIP_PYNAME( addCurvedPart );
1461 
1473  Q_INVOKABLE int translateFeature( QgsFeatureId featureId, double dx, double dy );
1474 
1495  Q_DECL_DEPRECATED QgsGeometry::OperationResult splitParts( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false ) SIP_DEPRECATED;
1496 
1516  Q_INVOKABLE QgsGeometry::OperationResult splitParts( const QgsPointSequence &splitLine, bool topologicalEditing = false );
1517 
1538  Q_DECL_DEPRECATED QgsGeometry::OperationResult splitFeatures( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false ) SIP_DEPRECATED;
1539 
1559  Q_INVOKABLE QgsGeometry::OperationResult splitFeatures( const QgsPointSequence &splitLine, bool topologicalEditing = false );
1560 
1583  Q_INVOKABLE QgsGeometry::OperationResult splitFeatures( const QgsCurve *curve, QgsPointSequence &topologyTestPoints SIP_OUT, bool preserveCircular = false, bool topologicalEditing = false );
1584 
1595  int addTopologicalPoints( const QgsGeometry &geom );
1596 
1610  Q_DECL_DEPRECATED int addTopologicalPoints( const QgsPointXY &p ) SIP_DEPRECATED;
1611 
1625  int addTopologicalPoints( const QgsPoint &p );
1626 
1640  int addTopologicalPoints( const QgsPointSequence &ps );
1641 
1648  const QgsAbstractVectorLayerLabeling *labeling() const SIP_SKIP { return mLabeling; }
1649 
1656  QgsAbstractVectorLayerLabeling *labeling() { return mLabeling; }
1657 
1662  void setLabeling( QgsAbstractVectorLayerLabeling *labeling SIP_TRANSFER );
1663 
1665  bool isEditable() const FINAL;
1666 
1668  bool isSpatial() const FINAL;
1669 
1671  virtual bool isModified() const;
1672 
1679  bool isAuxiliaryField( int index, int &srcIndex ) const;
1680 
1682  void reload() FINAL;
1683 
1688  QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) FINAL SIP_FACTORY;
1689 
1690  QgsRectangle extent() const FINAL;
1691  QgsRectangle sourceExtent() const FINAL;
1692 
1699  QgsFields fields() const FINAL;
1700 
1704  inline QgsAttributeList attributeList() const { return mFields.allAttributesList(); }
1705 
1709  QgsAttributeList primaryKeyAttributes() const;
1710 
1716  long featureCount() const FINAL;
1717 
1722  bool setReadOnly( bool readonly = true );
1723 
1744  bool changeGeometry( QgsFeatureId fid, QgsGeometry &geometry, bool skipDefaultValue = false );
1745 
1776  bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant(), bool skipDefaultValues = false );
1777 
1813  bool changeAttributeValues( QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues = QgsAttributeMap(), bool skipDefaultValues = false );
1814 
1824  bool addAttribute( const QgsField &field );
1825 
1831  void setFieldAlias( int index, const QString &aliasString );
1832 
1838  void removeFieldAlias( int index );
1839 
1850  bool renameAttribute( int index, const QString &newName );
1851 
1858  QString attributeAlias( int index ) const;
1859 
1861  QString attributeDisplayName( int index ) const;
1862 
1864  QgsStringMap attributeAliases() const;
1865 
1870  Q_DECL_DEPRECATED QSet<QString> excludeAttributesWms() const SIP_DEPRECATED { return mExcludeAttributesWMS; }
1871 
1876  Q_DECL_DEPRECATED void setExcludeAttributesWms( const QSet<QString> &att ) SIP_DEPRECATED { mExcludeAttributesWMS = att; }
1877 
1882  Q_DECL_DEPRECATED QSet<QString> excludeAttributesWfs() const SIP_DEPRECATED { return mExcludeAttributesWFS; }
1883 
1888  Q_DECL_DEPRECATED void setExcludeAttributesWfs( const QSet<QString> &att ) SIP_DEPRECATED { mExcludeAttributesWFS = att; }
1889 
1898  virtual bool deleteAttribute( int attr );
1899 
1907  bool deleteAttributes( const QList<int> &attrs );
1908 
1909  bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() ) FINAL;
1910 
1921  bool deleteFeature( QgsFeatureId fid, DeleteContext *context = nullptr );
1922 
1936  bool deleteFeatures( const QgsFeatureIds &fids, DeleteContext *context = nullptr );
1937 
1961  Q_INVOKABLE bool commitChanges( bool stopEditing = true );
1962 
1968  QStringList commitErrors() const;
1969 
1979  Q_INVOKABLE bool rollBack( bool deleteBuffer = true );
1980 
1987  QList<QgsRelation> referencingRelations( int idx ) const;
1988 
1995  QList<QgsWeakRelation> weakRelations( ) const SIP_SKIP;
1996 
1997 
1999  Q_INVOKABLE QgsVectorLayerEditBuffer *editBuffer() { return mEditBuffer; }
2000 
2005  const QgsVectorLayerEditBuffer *editBuffer() const SIP_SKIP { return mEditBuffer; }
2006 
2011  void beginEditCommand( const QString &text );
2012 
2014  void endEditCommand();
2015 
2017  void destroyEditCommand();
2018 
2021  {
2024  NoMarker
2025  };
2026 
2031  Q_DECL_DEPRECATED static void drawVertexMarker( double x, double y, QPainter &p, QgsVectorLayer::VertexMarkerType type, int vertexSize );
2032 
2041  void updateFields();
2042 
2057  QVariant defaultValue( int index, const QgsFeature &feature = QgsFeature(),
2058  QgsExpressionContext *context = nullptr ) const;
2059 
2071  void setDefaultValueDefinition( int index, const QgsDefaultValue &definition );
2072 
2083  QgsDefaultValue defaultValueDefinition( int index ) const;
2084 
2092  QgsFieldConstraints::Constraints fieldConstraints( int fieldIndex ) const;
2093 
2099  QMap< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrength> fieldConstraintsAndStrength( int fieldIndex ) const;
2100 
2110 
2118  void removeFieldConstraint( int index, QgsFieldConstraints::Constraint constraint );
2119 
2127  QString constraintExpression( int index ) const;
2128 
2136  QString constraintDescription( int index ) const;
2137 
2146  void setConstraintExpression( int index, const QString &expression, const QString &description = QString() );
2147 
2153  void setFieldConfigurationFlags( int index, QgsField::ConfigurationFlags flags ) SIP_SKIP;
2154 
2159  void setFieldConfigurationFlag( int index, QgsField::ConfigurationFlag flag, bool active ) SIP_SKIP;
2160 
2166  QgsField::ConfigurationFlags fieldConfigurationFlags( int index ) const SIP_SKIP;
2167 
2171  void setEditorWidgetSetup( int index, const QgsEditorWidgetSetup &setup );
2172 
2179  QgsEditorWidgetSetup editorWidgetSetup( int index ) const;
2180 
2192  QSet<QVariant> uniqueValues( int fieldIndex, int limit = -1 ) const FINAL;
2193 
2207  QStringList uniqueStringsMatching( int index, const QString &substring, int limit = -1,
2208  QgsFeedback *feedback = nullptr ) const;
2209 
2218  QVariant minimumValue( int index ) const FINAL;
2219 
2228  QVariant maximumValue( int index ) const FINAL;
2229 
2242  QVariant aggregate( QgsAggregateCalculator::Aggregate aggregate,
2243  const QString &fieldOrExpression,
2244  const QgsAggregateCalculator::AggregateParameters &parameters = QgsAggregateCalculator::AggregateParameters(),
2245  QgsExpressionContext *context = nullptr,
2246  bool *ok = nullptr,
2247  QgsFeatureIds *fids = nullptr ) const;
2248 
2250  void setFeatureBlendMode( QPainter::CompositionMode blendMode );
2252  QPainter::CompositionMode featureBlendMode() const;
2253 
2261  void setOpacity( double opacity );
2262 
2270  double opacity() const;
2271 
2272  QString htmlMetadata() const FINAL;
2273 
2278  void setSimplifyMethod( const QgsVectorSimplifyMethod &simplifyMethod ) { mSimplifyMethod = simplifyMethod; }
2279 
2284  inline const QgsVectorSimplifyMethod &simplifyMethod() const { return mSimplifyMethod; }
2285 
2291  bool simplifyDrawingCanbeApplied( const QgsRenderContext &renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint ) const;
2292 
2300  QgsConditionalLayerStyles *conditionalStyles() const;
2301 
2306  QgsAttributeTableConfig attributeTableConfig() const;
2307 
2312  void setAttributeTableConfig( const QgsAttributeTableConfig &attributeTableConfig );
2313 
2321  QString mapTipTemplate() const;
2322 
2330  void setMapTipTemplate( const QString &mapTipTemplate );
2331 
2332  QgsExpressionContext createExpressionContext() const FINAL;
2333 
2334  QgsExpressionContextScope *createExpressionContextScope() const FINAL SIP_FACTORY;
2335 
2343  QgsEditFormConfig editFormConfig() const;
2344 
2351  void setEditFormConfig( const QgsEditFormConfig &editFormConfig );
2352 
2360  void setReadExtentFromXml( bool readExtentFromXml );
2361 
2369  bool readExtentFromXml() const;
2370 
2376  bool isEditCommandActive() const { return mEditCommandActive; }
2377 
2383  QgsGeometryOptions *geometryOptions() const;
2384 
2402  bool allowCommit() const SIP_SKIP;
2403 
2421  void setAllowCommit( bool allowCommit ) SIP_SKIP;
2422 
2428  QgsStoredExpressionManager *storedExpressionManager() { return mStoredExpressionManager; }
2429 
2430  public slots:
2431 
2439  void select( QgsFeatureId featureId );
2440 
2448  Q_INVOKABLE void select( const QgsFeatureIds &featureIds );
2449 
2457  void deselect( QgsFeatureId featureId );
2458 
2466  Q_INVOKABLE void deselect( const QgsFeatureIds &featureIds );
2467 
2474  Q_INVOKABLE void removeSelection();
2475 
2486  void reselect();
2487 
2494  virtual void updateExtents( bool force = false );
2495 
2510  Q_INVOKABLE bool startEditing();
2511 
2517  virtual void setTransformContext( const QgsCoordinateTransformContext &transformContext ) override;
2518 
2519  SpatialIndexPresence hasSpatialIndex() const override;
2520 
2521  bool accept( QgsStyleEntityVisitorInterface *visitor ) const override;
2522 
2523  signals:
2524 
2532  void selectionChanged( const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect );
2533 
2535  void layerModified();
2536 
2542  void allowCommitChanged();
2543 
2545  void beforeModifiedCheck() const;
2546 
2548  void beforeEditingStarted();
2549 
2551  void editingStarted();
2552 
2554  void editingStopped();
2555 
2561  void beforeCommitChanges( bool stopEditing );
2562 
2564  void beforeRollBack();
2565 
2570  void afterCommitChanges();
2571 
2576  void afterRollBack();
2577 
2586  void attributeAdded( int idx );
2587 
2594  void beforeAddingExpressionField( const QString &fieldName );
2595 
2604  void attributeDeleted( int idx );
2605 
2612  void beforeRemovingExpressionField( int idx );
2613 
2619  void featureAdded( QgsFeatureId fid );
2620 
2629  void featureDeleted( QgsFeatureId fid );
2630 
2640  void featuresDeleted( const QgsFeatureIds &fids );
2641 
2646  void updatedFields();
2647 
2652  void subsetStringChanged();
2653 
2662  void attributeValueChanged( QgsFeatureId fid, int idx, const QVariant &value );
2663 
2671  void geometryChanged( QgsFeatureId fid, const QgsGeometry &geometry );
2672 
2674  void committedAttributesDeleted( const QString &layerId, const QgsAttributeList &deletedAttributes );
2676  void committedAttributesAdded( const QString &layerId, const QList<QgsField> &addedAttributes );
2678  void committedFeaturesAdded( const QString &layerId, const QgsFeatureList &addedFeatures );
2680  void committedFeaturesRemoved( const QString &layerId, const QgsFeatureIds &deletedFeatureIds );
2682  void committedAttributeValuesChanges( const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues );
2684  void committedGeometriesChanges( const QString &layerId, const QgsGeometryMap &changedGeometries );
2685 
2687  void labelingFontNotFound( QgsVectorLayer *layer, const QString &fontfamily );
2688 
2690  void featureBlendModeChanged( QPainter::CompositionMode blendMode );
2691 
2699  void opacityChanged( double opacity );
2700 
2706  void editCommandStarted( const QString &text );
2707 
2713  void editCommandEnded();
2714 
2720  void editCommandDestroyed();
2721 
2731  void readCustomSymbology( const QDomElement &element, QString &errorMessage );
2732 
2742  void writeCustomSymbology( QDomElement &element, QDomDocument &doc, QString &errorMessage ) const;
2743 
2749  void mapTipTemplateChanged();
2750 
2756  void displayExpressionChanged();
2757 
2761  void raiseError( const QString &msg );
2762 
2768  void editFormConfigChanged();
2769 
2776  void readOnlyChanged();
2777 
2783  void symbolFeatureCountMapChanged();
2784 
2785  protected:
2787  void setExtent( const QgsRectangle &rect ) FINAL;
2788 
2789  private slots:
2790  void invalidateSymbolCountedFlag();
2791  void onFeatureCounterCompleted();
2792  void onFeatureCounterTerminated();
2793  void onJoinedFieldsChanged();
2794  void onFeatureDeleted( QgsFeatureId fid );
2795  void onRelationsLoaded();
2796  void onSymbolsCounted();
2797  void onDirtyTransaction( const QString &sql, const QString &name );
2798  void emitDataChanged();
2799  void onAfterCommitChangesDependency();
2800 
2801  private:
2802  void updateDefaultValues( QgsFeatureId fid, QgsFeature feature = QgsFeature() );
2803 
2807  bool isReadOnly() const FINAL;
2808 
2815  bool setDataProvider( QString const &provider, const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags() );
2816 
2818  void readSldLabeling( const QDomNode &node );
2819 
2821  bool readSldTextSymbolizer( const QDomNode &node, QgsPalLayerSettings &settings ) const;
2822 
2824  QgsAbstractVectorLayerLabeling *readLabelingFromCustomProperties();
2825 
2826  bool deleteFeatureCascade( QgsFeatureId fid, DeleteContext *context = nullptr );
2827 
2828 #ifdef SIP_RUN
2829  QgsVectorLayer( const QgsVectorLayer &rhs );
2830 #endif
2831  QVariant minimumOrMaximumValue( int index, bool minimum ) const;
2833 
2834  private: // Private attributes
2835  QgsConditionalLayerStyles *mConditionalStyles = nullptr;
2836 
2838  QgsVectorDataProvider *mDataProvider = nullptr;
2839 
2841  QgsVectorLayerTemporalProperties *mTemporalProperties = nullptr;
2842 
2844  QString mDisplayExpression;
2845 
2846  QString mMapTipTemplate;
2847 
2849  QgsActionManager *mActions = nullptr;
2850 
2852  bool mReadOnly = false;
2853 
2859  QgsFeatureIds mSelectedFeatureIds;
2860 
2864  QgsFeatureIds mPreviousSelectedFeatureIds;
2865 
2867  QgsFields mFields;
2868 
2870  QgsStringMap mAttributeAliasMap;
2871 
2873  QMap<QString, QgsDefaultValue> mDefaultExpressionMap;
2874 
2876  QSet<int> mDefaultValueOnUpdateFields;
2877 
2879  QMap< QString, QgsFieldConstraints::Constraints > mFieldConstraints;
2880 
2882  QMap< QPair< QString, QgsFieldConstraints::Constraint >, QgsFieldConstraints::ConstraintStrength > mFieldConstraintStrength;
2883 
2885  QMap< QString, QPair< QString, QString > > mFieldConstraintExpressions;
2886 
2887  QMap< QString, QgsField::ConfigurationFlags > mFieldConfigurationFlags;
2888  QMap< QString, QgsEditorWidgetSetup > mFieldWidgetSetups;
2889 
2891  QgsEditFormConfig mEditFormConfig;
2892 
2894  QSet<QString> mExcludeAttributesWMS;
2895 
2897  QSet<QString> mExcludeAttributesWFS;
2898 
2901 
2903  QgsFeatureRenderer *mRenderer = nullptr;
2904 
2906  QgsVectorSimplifyMethod mSimplifyMethod;
2907 
2909  QgsAbstractVectorLayerLabeling *mLabeling = nullptr;
2910 
2912  bool mLabelsEnabled = false;
2913 
2915  bool mLabelFontNotFoundNotified = false;
2916 
2918  QPainter::CompositionMode mFeatureBlendMode = QPainter::CompositionMode_SourceOver;
2919 
2921  double mLayerOpacity = 1.0;
2922 
2924  bool mVertexMarkerOnlyForSelection = false;
2925 
2926  QStringList mCommitErrors;
2927 
2929  QgsVectorLayerEditBuffer *mEditBuffer = nullptr;
2932 
2933  //stores information about joined layers
2934  QgsVectorLayerJoinBuffer *mJoinBuffer = nullptr;
2935 
2937  std::unique_ptr< QgsVectorLayerServerProperties > mServerProperties;
2938 
2940  QgsExpressionFieldBuffer *mExpressionFieldBuffer = nullptr;
2941 
2942  //diagram rendering object. 0 if diagram drawing is disabled
2943  QgsDiagramRenderer *mDiagramRenderer = nullptr;
2944 
2945  //stores infos about diagram placement (placement type, priority, position distance)
2946  QgsDiagramLayerSettings *mDiagramLayerSettings = nullptr;
2947 
2948  mutable bool mValidExtent = false;
2949  mutable bool mLazyExtent = true;
2950 
2952  std::unique_ptr<QgsAuxiliaryLayer> mAuxiliaryLayer;
2953 
2955  QString mAuxiliaryLayerKey;
2956 
2957  // Features in renderer classes counted
2958  bool mSymbolFeatureCounted = false;
2959 
2960  // Feature counts for each renderer legend key
2961  QHash<QString, long> mSymbolFeatureCountMap;
2962  QHash<QString, QgsFeatureIds> mSymbolFeatureIdMap;
2963 
2965  bool mEditCommandActive = false;
2966 
2967  bool mReadExtentFromXml;
2968  QgsRectangle mXmlExtent;
2969 
2970  QgsFeatureIds mDeletedFids;
2971 
2972  QgsAttributeTableConfig mAttributeTableConfig;
2973 
2974  mutable QMutex mFeatureSourceConstructorMutex;
2975 
2976  QgsVectorLayerFeatureCounter *mFeatureCounter = nullptr;
2977 
2978  std::unique_ptr<QgsGeometryOptions> mGeometryOptions;
2979 
2980  bool mAllowCommit = true;
2981 
2983  QgsStoredExpressionManager *mStoredExpressionManager = nullptr;
2984 
2986 
2988  bool mDataChangedFired = false;
2989 
2990  QList<QgsWeakRelation> mWeakRelations;
2991 
2992  bool mSetLegendFromStyle = false;
2993 };
2994 
2995 
2996 
2997 // clazy:excludeall=qstring-allocations
2998 
2999 #endif
QgsActionManager * actions()
Returns all layer actions defined on this layer.
The class is used as a container of context for various read/write operations on other objects...
Wrapper for iterator of features from vector data provider or vector layer.
QMap< QgsFeatureId, QgsGeometry > QgsGeometryMap
Definition: qgsfeature.h:578
DeleteContext(bool cascade=false, QgsProject *project=nullptr)
Constructor for DeleteContext.
A rectangle specified with double values.
Definition: qgsrectangle.h:41
Base class for all map layer types.
Definition: qgsmaplayer.h:82
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeatureid.h:37
Implementation of map layer temporal properties for vector layers.
The QgsGeometryOptions class contains options to automatically adjust geometries to constraints on a ...
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:63
FeatureAvailability
Possible return value for hasFeatures() to determine if a source is empty.
The QgsDefaultValue class provides a container for managing client side default values for fields...
Constraint
Constraints which may be present on a field.
Setting options for loading vector layers.
Class allowing to manage the auxiliary storage for a vector layer.
QList< QgsFeature > QgsFeatureList
Definition: qgsfeature.h:583
Manages an editor widget Widget and wrapper share the same parent.
Counts the features in a QgsVectorLayer in task.
LayerOptions(bool loadDefaultStyle=true, bool readExtentFromXml=false)
Constructor for LayerOptions.
A class to represent a 2D point.
Definition: qgspointxy.h:43
QgsFeature getFeature(QgsFeatureId fid) const
Queries the layer for the feature with the given id.
QgsStoredExpressionManager * storedExpressionManager()
Returns the manager of the stored expressions for this layer.
VertexMarkerType
Editing vertex markers.
An interface for objects which accept features via addFeature(s) methods.
QgsAbstractVectorLayerLabeling * labeling()
Access to labeling configuration.
Remove from current selection.
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features ...
Definition: qgsfeatureid.h:28
SimplifyHint
Simplification flags for fast rendering of features.
Class providing some utility methods to manage auxiliary storage.
Utility class for calculating aggregates for a field (or expression) over the features from a vector ...
Container of fields for a vector layer.
Definition: qgsfields.h:44
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:123
The QgsWeakRelation class represent a QgsRelation with possibly unresolved layers or unmatched fields...
bool isEditCommandActive() const
Tests if an edit command is active.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:55
An interface for classes which can visit style entity (e.g.
Q_DECL_DEPRECATED QSet< QString > excludeAttributesWms() const
A set of attributes that are not advertised in WMS requests with QGIS server.
QMap< QString, QString > QgsStringMap
Definition: qgis.h:758
OperationResult
Success or failure of a geometry operation.
Definition: qgsgeometry.h:135
Manages joined fields for a vector layer.
ConfigurationFlag
Configuration flags for fields These flags are meant to be user-configurable and are not describing a...
Definition: qgsfield.h:80
Base class for feedback objects to be used for cancellation of something running in a worker thread...
Definition: qgsfeedback.h:43
const QgsVectorLayerJoinBuffer * joinBuffer() const
Returns a const pointer on join buffer object.
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:37
Q_DECL_DEPRECATED QSet< QString > excludeAttributesWfs() const
A set of attributes that are not advertised in WFS requests with QGIS server.
Q_INVOKABLE QgsVectorLayerEditBuffer * editBuffer()
Buffer with uncommitted editing operations. Only valid after editing has been turned on...
LayerOptions(const QgsCoordinateTransformContext &transformContext, bool loadDefaultStyle=true, bool readExtentFromXml=false)
Constructor for LayerOptions.
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:69
#define SIP_SKIP
Definition: qgis_sip.h:126
Evaluates and returns the diagram settings relating to a diagram for a specific feature.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QgsFeatureIterator getFeatures(const QString &expression)
Queries the layer for features matching a given expression.
Defines left outer join from our vector layer to some other vector layer.
QMap< int, QVariant > QgsAttributeMap
Definition: qgsattributes.h:38
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsVectorLayerServerProperties * serverProperties() const
Returns QGIS Server Properties of the vector layer.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
Encapsulates a QGIS project, including sets of map layers and their styles, layouts, annotations, canvases, etc.
Definition: qgsproject.h:94
Storage and management of actions associated with a layer.
QgsAttributeList attributeList() const
Returns list of attribute indexes.
Manages QGIS Server properties for a vector layer.
QgsFeatureRenderer * renderer()
Returns renderer.
Abstract base class for curved geometry type.
Definition: qgscurve.h:35
#define SIP_FACTORY
Definition: qgis_sip.h:76
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:49
const QgsAbstractVectorLayerLabeling * labeling() const
Access to const labeling configuration.
Q_DECL_DEPRECATED void setExcludeAttributesWfs(const QSet< QString > &att)
A set of attributes that are not advertised in WFS requests with QGIS server.
Single scope for storing variables and functions for use within a QgsExpressionContext.
Contains information about the context in which a coordinate transform is executed.
Add selection to current selection.
#define SIP_DEPRECATED
Definition: qgis_sip.h:106
Point geometry type, with support for z-dimension and m-values.
Definition: qgspoint.h:37
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings for fast rendering of features.
const QgsDiagramRenderer * diagramRenderer() const
Abstract interface for generating an expression context.
Partial snapshot of vector layer&#39;s state (only the members necessary for access to features) ...
Set selection, removing any existing selection.
QgsFeatureIterator getFeatures(const QgsRectangle &rectangle)
Queries the layer for the features which intersect the specified rectangle.
Stores the settings for rendering of all diagrams for a layer.
QVector< QgsPoint > QgsPointSequence
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:140
Modify current selection to include only select features which match.
SelectBehavior
Selection behavior.
Base class for storage of map layer temporal properties.
This class contains information how to simplify geometries fetched from a vector layer.
Contains information about the context of a rendering operation.
Setting options for creating vector data providers.
Buffers information about expression fields for a vector layer.
#define FINAL
Definition: qgis_sip.h:228
Context for cascade delete features.
QMap< QgsFeatureId, QgsAttributeMap > QgsChangedAttributesMap
Definition: qgsfeature.h:569
Abstract interface for generating an expression context scope.
An interface for objects which provide features via a getFeatures method.
const QgsDiagramLayerSettings * diagramLayerSettings() const
ConstraintStrength
Strength of constraints.
Holder for the widget type and its configuration for a field.
This class manages a set of relations between layers.
#define SIP_OUT
Definition: qgis_sip.h:58
The QgsConditionalLayerStyles class holds conditional style information for a layer.
This class represents a coordinate reference system (CRS).
Abstract base class - its implementations define different approaches to the labeling of a vector lay...
Base class for utility classes that encapsulate information necessary for rendering of map layers...
Q_DECL_DEPRECATED void setExcludeAttributesWms(const QSet< QString > &att)
A set of attributes that are not advertised in WMS requests with QGIS server.
SpatialIndexPresence
Enumeration of spatial index presence states.
const QgsFeatureRenderer * renderer() const
Returns const renderer.
QSet< int > QgsAttributeIds
QList< int > QgsAttributeList
Definition: qgsfield.h:26
This is a container for configuration of the attribute table.
This is the base class for vector data providers.
QList< int > QgsAttributeList
QgsCoordinateReferenceSystem fallbackCrs
Fallback layer coordinate reference system.
const QgsActionManager * actions() const
Returns all layer actions defined on this layer.
Represents a vector layer which manages a vector based data sets.
const QgsVectorLayerEditBuffer * editBuffer() const
Buffer with uncommitted editing operations.
EditResult
Result of an edit operation.
QgsFeatureIterator getFeatures(const QgsFeatureIds &fids)
Queries the layer for the features with the given ids.
Constraint must be honored before feature can be accepted.
const QgsField & field
Definition: qgsfield.h:456
Manages stored expressions regarding creation, modification and storing in the project.
Abstract base class for simplify geometries using a specific algorithm.
#define SIP_PYNAME(name)
Definition: qgis_sip.h:81