QGIS API Documentation  3.13.0-Master (9729a43df7)
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 
388 {
389  Q_OBJECT
390 
391  Q_PROPERTY( QString subsetString READ subsetString WRITE setSubsetString NOTIFY subsetStringChanged )
392  Q_PROPERTY( QString displayExpression READ displayExpression WRITE setDisplayExpression NOTIFY displayExpressionChanged )
393  Q_PROPERTY( QString mapTipTemplate READ mapTipTemplate WRITE setMapTipTemplate NOTIFY mapTipTemplateChanged )
394  Q_PROPERTY( QgsEditFormConfig editFormConfig READ editFormConfig WRITE setEditFormConfig NOTIFY editFormConfigChanged )
395  Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged )
396  Q_PROPERTY( double opacity READ opacity WRITE setOpacity NOTIFY opacityChanged )
397 
398  public:
399 
402  {
403  Success = 0,
404  EmptyGeometry = 1,
405  EditFailed = 2,
406  FetchFeatureFailed = 3,
407  InvalidLayer = 4,
408  };
409  Q_ENUM( EditResult )
410 
411 
413  {
418  };
419  Q_ENUM( SelectBehavior )
420 
421 
426  {
427 
431  explicit LayerOptions( bool loadDefaultStyle = true,
432  bool readExtentFromXml = false )
433  : loadDefaultStyle( loadDefaultStyle )
434  , readExtentFromXml( readExtentFromXml )
435  {}
436 
441  explicit LayerOptions( const QgsCoordinateTransformContext &transformContext,
442  bool loadDefaultStyle = true,
443  bool readExtentFromXml = false
444  )
445  : loadDefaultStyle( loadDefaultStyle )
446  , readExtentFromXml( readExtentFromXml )
447  , transformContext( transformContext )
448  {}
449 
451  bool loadDefaultStyle = true;
452 
457  bool readExtentFromXml = false;
458 
464 
477 
490 
504  bool skipCrsValidation = false;
505 
506  };
507 
512  struct CORE_EXPORT DeleteContext
513  {
514 
518  explicit DeleteContext( bool cascade = false, QgsProject *project = nullptr ): cascade( cascade ), project( project ) {}
519 
520  QList<QgsVectorLayer *> handledLayers() const;
521  QgsFeatureIds handledFeatures( QgsVectorLayer *layer ) const;
522 
523  QMap<QgsVectorLayer *, QgsFeatureIds> mHandledFeatures SIP_SKIP;
524  bool cascade;
526  };
527 
541  explicit QgsVectorLayer( const QString &path = QString(), const QString &baseName = QString(),
542  const QString &providerLib = "ogr", const QgsVectorLayer::LayerOptions &options = QgsVectorLayer::LayerOptions() );
543 
544  ~QgsVectorLayer() override;
545 
547  QgsVectorLayer( const QgsVectorLayer &rhs ) = delete;
549  QgsVectorLayer &operator=( QgsVectorLayer const &rhs ) = delete;
550 
559  QgsVectorLayer *clone() const override SIP_FACTORY;
560 
565  QString storageType() const;
566 
570  QString capabilitiesString() const;
571 
575  QString dataComment() const;
576 
584  QString displayField() const;
585 
593  void setDisplayExpression( const QString &displayExpression );
594 
601  QString displayExpression() const;
602 
603  QgsVectorDataProvider *dataProvider() FINAL;
604  const QgsVectorDataProvider *dataProvider() const FINAL SIP_SKIP;
605 
609  QgsMapLayerTemporalProperties *temporalProperties() override;
610 
621  void setProviderEncoding( const QString &encoding );
622 
624  void setCoordinateSystem();
625 
631  bool addJoin( const QgsVectorLayerJoinInfo &joinInfo );
632 
637  bool removeJoin( const QString &joinLayerId );
638 
643  QgsVectorLayerJoinBuffer *joinBuffer() { return mJoinBuffer; }
644 
649  const QgsVectorLayerJoinBuffer *joinBuffer() const { return mJoinBuffer; } SIP_SKIP;
650 
651  const QList<QgsVectorLayerJoinInfo> vectorJoins() const;
652 
661  bool setDependencies( const QSet<QgsMapLayerDependency> &layers ) FINAL;
662 
670  QSet<QgsMapLayerDependency> dependencies() const FINAL;
671 
682  int addExpressionField( const QString &exp, const QgsField &fld );
683 
691  void removeExpressionField( int index );
692 
702  QString expressionField( int index ) const;
703 
713  void updateExpressionField( int index, const QString &exp );
714 
721  QgsActionManager *actions() { return mActions; }
722 
728  const QgsActionManager *actions() const SIP_SKIP { return mActions; }
729 
734  QgsVectorLayerServerProperties *serverProperties() const { return mServerProperties.get(); }
735 
741  int selectedFeatureCount() const;
742 
752  Q_INVOKABLE void selectByRect( QgsRectangle &rect, QgsVectorLayer::SelectBehavior behavior = QgsVectorLayer::SetSelection );
753 
763  Q_INVOKABLE void selectByExpression( const QString &expression, QgsVectorLayer::SelectBehavior behavior = QgsVectorLayer::SetSelection );
764 
775  Q_INVOKABLE void selectByIds( const QgsFeatureIds &ids, QgsVectorLayer::SelectBehavior behavior = QgsVectorLayer::SetSelection );
776 
788  Q_INVOKABLE void modifySelection( const QgsFeatureIds &selectIds, const QgsFeatureIds &deselectIds );
789 
791  Q_INVOKABLE void invertSelection();
792 
794  Q_INVOKABLE void selectAll();
795 
803  Q_INVOKABLE void invertSelectionInRectangle( QgsRectangle &rect );
804 
817  Q_INVOKABLE QgsFeatureList selectedFeatures() const;
818 
834  QgsFeatureIterator getSelectedFeatures( QgsFeatureRequest request = QgsFeatureRequest() ) const;
835 
843  Q_INVOKABLE const QgsFeatureIds &selectedFeatureIds() const;
844 
846  Q_INVOKABLE QgsRectangle boundingBoxOfSelected() const;
847 
855  bool labelsEnabled() const;
856 
866  void setLabelsEnabled( bool enabled );
867 
873  bool diagramsEnabled() const;
874 
876  void setDiagramRenderer( QgsDiagramRenderer *r SIP_TRANSFER );
877  const QgsDiagramRenderer *diagramRenderer() const { return mDiagramRenderer; }
878 
879  void setDiagramLayerSettings( const QgsDiagramLayerSettings &s );
880  const QgsDiagramLayerSettings *diagramLayerSettings() const { return mDiagramLayerSettings; }
881 
883  QgsFeatureRenderer *renderer() { return mRenderer; }
884 
889  const QgsFeatureRenderer *renderer() const SIP_SKIP { return mRenderer; }
890 
895  void setRenderer( QgsFeatureRenderer *r SIP_TRANSFER );
896 
898  Q_INVOKABLE QgsWkbTypes::GeometryType geometryType() const;
899 
901  Q_INVOKABLE QgsWkbTypes::Type wkbType() const FINAL;
902 
903  QgsCoordinateReferenceSystem sourceCrs() const FINAL;
904  QString sourceName() const FINAL;
905 
910  bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context ) FINAL;
911 
916  bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const FINAL;
917 
918  QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const FINAL;
919  QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const FINAL;
920 
925  void resolveReferences( QgsProject *project ) FINAL;
926 
935  virtual void saveStyleToDatabase( const QString &name, const QString &description,
936  bool useAsDefault, const QString &uiFileContent,
937  QString &msgError SIP_OUT );
938 
948  virtual int listStylesInDatabase( QStringList &ids SIP_OUT, QStringList &names SIP_OUT,
949  QStringList &descriptions SIP_OUT, QString &msgError SIP_OUT );
950 
954  virtual QString getStyleFromDatabase( const QString &styleId, QString &msgError SIP_OUT );
955 
963  virtual bool deleteStyleFromDatabase( const QString &styleId, QString &msgError SIP_OUT );
964 
972  virtual QString loadNamedStyle( const QString &theURI, bool &resultFlag SIP_OUT, bool loadFromLocalDb,
973  QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories );
974 
979  QString loadNamedStyle( const QString &theURI, bool &resultFlag SIP_OUT,
980  QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) FINAL;
981 
995  bool loadAuxiliaryLayer( const QgsAuxiliaryStorage &storage, const QString &key = QString() );
996 
1006  void setAuxiliaryLayer( QgsAuxiliaryLayer *layer SIP_TRANSFER = nullptr );
1007 
1013  QgsAuxiliaryLayer *auxiliaryLayer();
1014 
1020  const QgsAuxiliaryLayer *auxiliaryLayer() const SIP_SKIP;
1021 
1030  bool readSymbology( const QDomNode &layerNode, QString &errorMessage,
1031  QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) FINAL;
1032 
1041  bool readStyle( const QDomNode &node, QString &errorMessage,
1042  QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) FINAL;
1043 
1053  bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
1054  const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const FINAL;
1055 
1065  bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
1066  const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const FINAL;
1067 
1076  bool writeSld( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsStringMap &props = QgsStringMap() ) const;
1077 
1078  bool readSld( const QDomNode &node, QString &errorMessage ) FINAL;
1079 
1085  long featureCount( const QString &legendKey ) const;
1086 
1093  QgsFeatureIds symbolFeatureIds( const QString &legendKey ) const;
1094 
1105  FeatureAvailability hasFeatures() const FINAL;
1106 
1118  Q_DECL_DEPRECATED void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, bool loadDefaultStyleFlag = false ) SIP_DEPRECATED;
1119 
1132  void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, bool loadDefaultStyleFlag = false ) override;
1133 
1134  QString loadDefaultStyle( bool &resultFlag SIP_OUT ) FINAL;
1135 
1149  QgsVectorLayerFeatureCounter *countSymbolFeatures( bool storeSymbolFids = false );
1150 
1158  virtual bool setSubsetString( const QString &subset );
1159 
1164  virtual QString subsetString() const;
1165 
1171  QgsFeatureIterator getFeatures( const QgsFeatureRequest &request = QgsFeatureRequest() ) const FINAL;
1172 
1176  inline QgsFeatureIterator getFeatures( const QString &expression )
1177  {
1178  return getFeatures( QgsFeatureRequest( expression ) );
1179  }
1180 
1185  inline QgsFeature getFeature( QgsFeatureId fid ) const
1186  {
1187  QgsFeature feature;
1188  getFeatures( QgsFeatureRequest( fid ) ).nextFeature( feature );
1189  return feature;
1190  }
1191 
1196  QgsGeometry getGeometry( QgsFeatureId fid ) const;
1197 
1202  {
1203  return getFeatures( QgsFeatureRequest( fids ) );
1204  }
1205 
1209  inline QgsFeatureIterator getFeatures( const QgsRectangle &rectangle )
1210  {
1211  return getFeatures( QgsFeatureRequest( rectangle ) );
1212  }
1213 
1214  bool addFeature( QgsFeature &feature, QgsFeatureSink::Flags flags = nullptr ) FINAL;
1215 
1241  bool updateFeature( QgsFeature &feature, bool skipDefaultValues = false );
1242 
1254  bool insertVertex( double x, double y, QgsFeatureId atFeatureId, int beforeVertex );
1255 
1267  bool insertVertex( const QgsPoint &point, QgsFeatureId atFeatureId, int beforeVertex );
1268 
1279  bool moveVertex( double x, double y, QgsFeatureId atFeatureId, int atVertex );
1280 
1291  bool moveVertex( const QgsPoint &p, QgsFeatureId atFeatureId, int atVertex ) SIP_PYNAME( moveVertexV2 );
1292 
1303  EditResult deleteVertex( QgsFeatureId featureId, int vertex );
1304 
1312  Q_INVOKABLE bool deleteSelectedFeatures( int *deletedCount = nullptr, DeleteContext *context = nullptr );
1313 
1333  Q_DECL_DEPRECATED QgsGeometry::OperationResult addRing( const QVector<QgsPointXY> &ring, QgsFeatureId *featureId = nullptr ) SIP_DEPRECATED;
1334 
1335 
1354  Q_INVOKABLE QgsGeometry::OperationResult addRing( const QgsPointSequence &ring, QgsFeatureId *featureId = nullptr );
1355 
1374  Q_INVOKABLE QgsGeometry::OperationResult addRing( QgsCurve *ring SIP_TRANSFER, QgsFeatureId *featureId = nullptr ) SIP_PYNAME( addCurvedRing );
1375 
1394  Q_DECL_DEPRECATED QgsGeometry::OperationResult addPart( const QList<QgsPointXY> &ring ) SIP_DEPRECATED;
1395 
1414  Q_DECL_DEPRECATED QgsGeometry::OperationResult addPart( const QVector<QgsPointXY> &ring ) SIP_PYNAME( addPartV2 ) SIP_DEPRECATED;
1415 
1433  Q_INVOKABLE QgsGeometry::OperationResult addPart( const QgsPointSequence &ring ) SIP_PYNAME( addPartV2 );
1434 
1442  Q_INVOKABLE QgsGeometry::OperationResult addPart( QgsCurve *ring SIP_TRANSFER ) SIP_PYNAME( addCurvedPart );
1443 
1455  Q_INVOKABLE int translateFeature( QgsFeatureId featureId, double dx, double dy );
1456 
1475  Q_DECL_DEPRECATED QgsGeometry::OperationResult splitParts( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false ) SIP_DEPRECATED;
1476 
1494  Q_INVOKABLE QgsGeometry::OperationResult splitParts( const QgsPointSequence &splitLine, bool topologicalEditing = false );
1495 
1514  Q_DECL_DEPRECATED QgsGeometry::OperationResult splitFeatures( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false ) SIP_DEPRECATED;
1515 
1533  Q_INVOKABLE QgsGeometry::OperationResult splitFeatures( const QgsPointSequence &splitLine, bool topologicalEditing = false );
1534 
1545  int addTopologicalPoints( const QgsGeometry &geom );
1546 
1560  Q_DECL_DEPRECATED int addTopologicalPoints( const QgsPointXY &p ) SIP_DEPRECATED;
1561 
1575  int addTopologicalPoints( const QgsPoint &p );
1576 
1583  const QgsAbstractVectorLayerLabeling *labeling() const SIP_SKIP { return mLabeling; }
1584 
1591  QgsAbstractVectorLayerLabeling *labeling() { return mLabeling; }
1592 
1597  void setLabeling( QgsAbstractVectorLayerLabeling *labeling SIP_TRANSFER );
1598 
1600  bool isEditable() const FINAL;
1601 
1603  bool isSpatial() const FINAL;
1604 
1606  virtual bool isModified() const;
1607 
1614  bool isAuxiliaryField( int index, int &srcIndex ) const;
1615 
1617  void reload() FINAL;
1618 
1623  QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) FINAL SIP_FACTORY;
1624 
1625  QgsRectangle extent() const FINAL;
1626  QgsRectangle sourceExtent() const FINAL;
1627 
1634  QgsFields fields() const FINAL;
1635 
1639  inline QgsAttributeList attributeList() const { return mFields.allAttributesList(); }
1640 
1644  QgsAttributeList primaryKeyAttributes() const;
1645 
1651  long featureCount() const FINAL;
1652 
1657  bool setReadOnly( bool readonly = true );
1658 
1679  bool changeGeometry( QgsFeatureId fid, QgsGeometry &geometry, bool skipDefaultValue = false );
1680 
1711  bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant(), bool skipDefaultValues = false );
1712 
1748  bool changeAttributeValues( QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues = QgsAttributeMap(), bool skipDefaultValues = false );
1749 
1759  bool addAttribute( const QgsField &field );
1760 
1766  void setFieldAlias( int index, const QString &aliasString );
1767 
1773  void removeFieldAlias( int index );
1774 
1785  bool renameAttribute( int index, const QString &newName );
1786 
1793  QString attributeAlias( int index ) const;
1794 
1796  QString attributeDisplayName( int index ) const;
1797 
1799  QgsStringMap attributeAliases() const;
1800 
1804  QSet<QString> excludeAttributesWms() const { return mExcludeAttributesWMS; }
1805 
1809  void setExcludeAttributesWms( const QSet<QString> &att ) { mExcludeAttributesWMS = att; }
1810 
1814  QSet<QString> excludeAttributesWfs() const { return mExcludeAttributesWFS; }
1815 
1819  void setExcludeAttributesWfs( const QSet<QString> &att ) { mExcludeAttributesWFS = att; }
1820 
1829  virtual bool deleteAttribute( int attr );
1830 
1838  bool deleteAttributes( const QList<int> &attrs );
1839 
1840  bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = nullptr ) FINAL;
1841 
1852  bool deleteFeature( QgsFeatureId fid, DeleteContext *context = nullptr );
1853 
1867  bool deleteFeatures( const QgsFeatureIds &fids, DeleteContext *context = nullptr );
1868 
1889  Q_INVOKABLE bool commitChanges();
1890 
1896  QStringList commitErrors() const;
1897 
1907  Q_INVOKABLE bool rollBack( bool deleteBuffer = true );
1908 
1915  QList<QgsRelation> referencingRelations( int idx ) const;
1916 
1923  QList<QgsWeakRelation> weakRelations( ) const SIP_SKIP;
1924 
1925 
1927  Q_INVOKABLE QgsVectorLayerEditBuffer *editBuffer() { return mEditBuffer; }
1928 
1933  const QgsVectorLayerEditBuffer *editBuffer() const SIP_SKIP { return mEditBuffer; }
1934 
1939  void beginEditCommand( const QString &text );
1940 
1942  void endEditCommand();
1943 
1945  void destroyEditCommand();
1946 
1949  {
1952  NoMarker
1953  };
1954 
1959  Q_DECL_DEPRECATED static void drawVertexMarker( double x, double y, QPainter &p, QgsVectorLayer::VertexMarkerType type, int vertexSize );
1960 
1969  void updateFields();
1970 
1985  QVariant defaultValue( int index, const QgsFeature &feature = QgsFeature(),
1986  QgsExpressionContext *context = nullptr ) const;
1987 
1999  void setDefaultValueDefinition( int index, const QgsDefaultValue &definition );
2000 
2011  QgsDefaultValue defaultValueDefinition( int index ) const;
2012 
2020  QgsFieldConstraints::Constraints fieldConstraints( int fieldIndex ) const;
2021 
2027  QMap< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrength> fieldConstraintsAndStrength( int fieldIndex ) const;
2028 
2038 
2046  void removeFieldConstraint( int index, QgsFieldConstraints::Constraint constraint );
2047 
2055  QString constraintExpression( int index ) const;
2056 
2064  QString constraintDescription( int index ) const;
2065 
2074  void setConstraintExpression( int index, const QString &expression, const QString &description = QString() );
2075 
2079  void setEditorWidgetSetup( int index, const QgsEditorWidgetSetup &setup );
2080 
2087  QgsEditorWidgetSetup editorWidgetSetup( int index ) const;
2088 
2100  QSet<QVariant> uniqueValues( int fieldIndex, int limit = -1 ) const FINAL;
2101 
2115  QStringList uniqueStringsMatching( int index, const QString &substring, int limit = -1,
2116  QgsFeedback *feedback = nullptr ) const;
2117 
2126  QVariant minimumValue( int index ) const FINAL;
2127 
2136  QVariant maximumValue( int index ) const FINAL;
2137 
2150  QVariant aggregate( QgsAggregateCalculator::Aggregate aggregate,
2151  const QString &fieldOrExpression,
2152  const QgsAggregateCalculator::AggregateParameters &parameters = QgsAggregateCalculator::AggregateParameters(),
2153  QgsExpressionContext *context = nullptr,
2154  bool *ok = nullptr,
2155  QgsFeatureIds *fids = nullptr ) const;
2156 
2158  void setFeatureBlendMode( QPainter::CompositionMode blendMode );
2160  QPainter::CompositionMode featureBlendMode() const;
2161 
2169  void setOpacity( double opacity );
2170 
2178  double opacity() const;
2179 
2180  QString htmlMetadata() const FINAL;
2181 
2186  void setSimplifyMethod( const QgsVectorSimplifyMethod &simplifyMethod ) { mSimplifyMethod = simplifyMethod; }
2187 
2192  inline const QgsVectorSimplifyMethod &simplifyMethod() const { return mSimplifyMethod; }
2193 
2199  bool simplifyDrawingCanbeApplied( const QgsRenderContext &renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint ) const;
2200 
2208  QgsConditionalLayerStyles *conditionalStyles() const;
2209 
2214  QgsAttributeTableConfig attributeTableConfig() const;
2215 
2220  void setAttributeTableConfig( const QgsAttributeTableConfig &attributeTableConfig );
2221 
2229  QString mapTipTemplate() const;
2230 
2238  void setMapTipTemplate( const QString &mapTipTemplate );
2239 
2240  QgsExpressionContext createExpressionContext() const FINAL;
2241 
2242  QgsExpressionContextScope *createExpressionContextScope() const FINAL SIP_FACTORY;
2243 
2251  QgsEditFormConfig editFormConfig() const;
2252 
2259  void setEditFormConfig( const QgsEditFormConfig &editFormConfig );
2260 
2268  void setReadExtentFromXml( bool readExtentFromXml );
2269 
2277  bool readExtentFromXml() const;
2278 
2284  bool isEditCommandActive() const { return mEditCommandActive; }
2285 
2291  QgsGeometryOptions *geometryOptions() const;
2292 
2311  bool allowCommit() const SIP_SKIP;
2312 
2331  void setAllowCommit( bool allowCommit ) SIP_SKIP;
2332 
2338  QgsStoredExpressionManager *storedExpressionManager() { return mStoredExpressionManager; }
2339 
2340  public slots:
2341 
2349  void select( QgsFeatureId featureId );
2350 
2358  Q_INVOKABLE void select( const QgsFeatureIds &featureIds );
2359 
2367  void deselect( QgsFeatureId featureId );
2368 
2376  Q_INVOKABLE void deselect( const QgsFeatureIds &featureIds );
2377 
2384  Q_INVOKABLE void removeSelection();
2385 
2396  void reselect();
2397 
2404  virtual void updateExtents( bool force = false );
2405 
2420  Q_INVOKABLE bool startEditing();
2421 
2427  virtual void setTransformContext( const QgsCoordinateTransformContext &transformContext ) override;
2428 
2429  SpatialIndexPresence hasSpatialIndex() const override;
2430 
2431  bool accept( QgsStyleEntityVisitorInterface *visitor ) const override;
2432 
2433  signals:
2434 
2442  void selectionChanged( const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect );
2443 
2445  void layerModified();
2446 
2452  void allowCommitChanged();
2453 
2455  void beforeModifiedCheck() const;
2456 
2458  void beforeEditingStarted();
2459 
2461  void editingStarted();
2462 
2464  void editingStopped();
2465 
2467  void beforeCommitChanges();
2468 
2470  void beforeRollBack();
2471 
2476  void afterRollBack();
2477 
2486  void attributeAdded( int idx );
2487 
2494  void beforeAddingExpressionField( const QString &fieldName );
2495 
2504  void attributeDeleted( int idx );
2505 
2512  void beforeRemovingExpressionField( int idx );
2513 
2519  void featureAdded( QgsFeatureId fid );
2520 
2529  void featureDeleted( QgsFeatureId fid );
2530 
2540  void featuresDeleted( const QgsFeatureIds &fids );
2541 
2546  void updatedFields();
2547 
2552  void subsetStringChanged();
2553 
2562  void attributeValueChanged( QgsFeatureId fid, int idx, const QVariant &value );
2563 
2571  void geometryChanged( QgsFeatureId fid, const QgsGeometry &geometry );
2572 
2574  void committedAttributesDeleted( const QString &layerId, const QgsAttributeList &deletedAttributes );
2576  void committedAttributesAdded( const QString &layerId, const QList<QgsField> &addedAttributes );
2578  void committedFeaturesAdded( const QString &layerId, const QgsFeatureList &addedFeatures );
2580  void committedFeaturesRemoved( const QString &layerId, const QgsFeatureIds &deletedFeatureIds );
2582  void committedAttributeValuesChanges( const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues );
2584  void committedGeometriesChanges( const QString &layerId, const QgsGeometryMap &changedGeometries );
2585 
2587  void labelingFontNotFound( QgsVectorLayer *layer, const QString &fontfamily );
2588 
2590  void featureBlendModeChanged( QPainter::CompositionMode blendMode );
2591 
2599  void opacityChanged( double opacity );
2600 
2606  void editCommandStarted( const QString &text );
2607 
2613  void editCommandEnded();
2614 
2620  void editCommandDestroyed();
2621 
2631  void readCustomSymbology( const QDomElement &element, QString &errorMessage );
2632 
2642  void writeCustomSymbology( QDomElement &element, QDomDocument &doc, QString &errorMessage ) const;
2643 
2649  void mapTipTemplateChanged();
2650 
2656  void displayExpressionChanged();
2657 
2661  void raiseError( const QString &msg );
2662 
2668  void editFormConfigChanged();
2669 
2676  void readOnlyChanged();
2677 
2683  void symbolFeatureCountMapChanged();
2684 
2685  protected:
2687  void setExtent( const QgsRectangle &rect ) FINAL;
2688 
2689  private slots:
2690  void invalidateSymbolCountedFlag();
2691  void onFeatureCounterCompleted();
2692  void onFeatureCounterTerminated();
2693  void onJoinedFieldsChanged();
2694  void onFeatureDeleted( QgsFeatureId fid );
2695  void onRelationsLoaded();
2696  void onSymbolsCounted();
2697  void onDirtyTransaction( const QString &sql, const QString &name );
2698  void emitDataChanged();
2699 
2700  private:
2701  void updateDefaultValues( QgsFeatureId fid, QgsFeature feature = QgsFeature() );
2702 
2706  bool isReadOnly() const FINAL;
2707 
2713  bool setDataProvider( QString const &provider, const QgsDataProvider::ProviderOptions &options );
2714 
2716  void readSldLabeling( const QDomNode &node );
2717 
2719  bool readSldTextSymbolizer( const QDomNode &node, QgsPalLayerSettings &settings ) const;
2720 
2722  QgsAbstractVectorLayerLabeling *readLabelingFromCustomProperties();
2723 
2724  bool deleteFeatureCascade( QgsFeatureId fid, DeleteContext *context = nullptr );
2725 
2726 #ifdef SIP_RUN
2727  QgsVectorLayer( const QgsVectorLayer &rhs );
2728 #endif
2729  QVariant minimumOrMaximumValue( int index, bool minimum ) const;
2731 
2732  private: // Private attributes
2733  QgsConditionalLayerStyles *mConditionalStyles = nullptr;
2734 
2736  QgsVectorDataProvider *mDataProvider = nullptr;
2737 
2739  QgsVectorLayerTemporalProperties *mTemporalProperties = nullptr;
2740 
2742  QString mDisplayExpression;
2743 
2744  QString mMapTipTemplate;
2745 
2747  QgsActionManager *mActions = nullptr;
2748 
2750  bool mReadOnly = false;
2751 
2757  QgsFeatureIds mSelectedFeatureIds;
2758 
2762  QgsFeatureIds mPreviousSelectedFeatureIds;
2763 
2765  QgsFields mFields;
2766 
2768  QgsStringMap mAttributeAliasMap;
2769 
2771  QMap<QString, QgsDefaultValue> mDefaultExpressionMap;
2772 
2774  QSet<int> mDefaultValueOnUpdateFields;
2775 
2777  QMap< QString, QgsFieldConstraints::Constraints > mFieldConstraints;
2778 
2780  QMap< QPair< QString, QgsFieldConstraints::Constraint >, QgsFieldConstraints::ConstraintStrength > mFieldConstraintStrength;
2781 
2783  QMap< QString, QPair< QString, QString > > mFieldConstraintExpressions;
2784 
2785  QMap< QString, QgsEditorWidgetSetup > mFieldWidgetSetups;
2786 
2788  QgsEditFormConfig mEditFormConfig;
2789 
2791  QSet<QString> mExcludeAttributesWMS;
2792 
2794  QSet<QString> mExcludeAttributesWFS;
2795 
2798 
2800  QgsFeatureRenderer *mRenderer = nullptr;
2801 
2803  QgsVectorSimplifyMethod mSimplifyMethod;
2804 
2806  QgsAbstractVectorLayerLabeling *mLabeling = nullptr;
2807 
2809  bool mLabelsEnabled = false;
2810 
2812  bool mLabelFontNotFoundNotified = false;
2813 
2815  QPainter::CompositionMode mFeatureBlendMode = QPainter::CompositionMode_SourceOver;
2816 
2818  double mLayerOpacity = 1.0;
2819 
2821  bool mVertexMarkerOnlyForSelection = false;
2822 
2823  QStringList mCommitErrors;
2824 
2826  QgsVectorLayerEditBuffer *mEditBuffer = nullptr;
2829 
2830  //stores information about joined layers
2831  QgsVectorLayerJoinBuffer *mJoinBuffer = nullptr;
2832 
2834  std::unique_ptr< QgsVectorLayerServerProperties > mServerProperties;
2835 
2837  QgsExpressionFieldBuffer *mExpressionFieldBuffer = nullptr;
2838 
2839  //diagram rendering object. 0 if diagram drawing is disabled
2840  QgsDiagramRenderer *mDiagramRenderer = nullptr;
2841 
2842  //stores infos about diagram placement (placement type, priority, position distance)
2843  QgsDiagramLayerSettings *mDiagramLayerSettings = nullptr;
2844 
2845  mutable bool mValidExtent = false;
2846  mutable bool mLazyExtent = true;
2847 
2849  std::unique_ptr<QgsAuxiliaryLayer> mAuxiliaryLayer;
2850 
2852  QString mAuxiliaryLayerKey;
2853 
2854  // Features in renderer classes counted
2855  bool mSymbolFeatureCounted = false;
2856 
2857  // Feature counts for each renderer legend key
2858  QHash<QString, long> mSymbolFeatureCountMap;
2859  QHash<QString, QgsFeatureIds> mSymbolFeatureIdMap;
2860 
2862  bool mEditCommandActive = false;
2863 
2864  bool mReadExtentFromXml;
2865  QgsRectangle mXmlExtent;
2866 
2867  QgsFeatureIds mDeletedFids;
2868 
2869  QgsAttributeTableConfig mAttributeTableConfig;
2870 
2871  mutable QMutex mFeatureSourceConstructorMutex;
2872 
2873  QgsVectorLayerFeatureCounter *mFeatureCounter = nullptr;
2874 
2875  std::unique_ptr<QgsGeometryOptions> mGeometryOptions;
2876 
2877  bool mAllowCommit = true;
2878 
2880  QgsStoredExpressionManager *mStoredExpressionManager = nullptr;
2881 
2883 
2885  bool mDataChangedFired = false;
2886 
2887  QList<QgsWeakRelation> mWeakRelations;
2888 };
2889 
2890 
2891 
2892 // clazy:excludeall=qstring-allocations
2893 
2894 #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:566
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:81
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeatureid.h:34
void setExcludeAttributesWms(const QSet< QString > &att)
A set of attributes that are not advertised in WMS requests with QGIS server.
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
QSet< QString > excludeAttributesWms() const
A set of attributes that are not advertised in WMS requests with QGIS server.
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.
QSet< QString > excludeAttributesWfs() const
A set of attributes that are not advertised in WFS requests with QGIS server.
Setting options for loading vector layers.
Class allowing to manage the auxiliary storage for a vector layer.
QList< QgsFeature > QgsFeatureList
Definition: qgsfeature.h:571
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
Definition: qgsfeatureid.h:25
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:42
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:122
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.
QMap< QString, QString > QgsStringMap
Definition: qgis.h:704
OperationResult
Success or failure of a geometry operation.
Definition: qgsgeometry.h:134
Manages joined fields for a vector layer.
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
void setExcludeAttributesWfs(const QSet< QString > &att)
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:68
#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:92
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.
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:139
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:223
Context for cascade delete features.
QMap< QgsFeatureId, QgsAttributeMap > QgsChangedAttributesMap
Definition: qgsfeature.h:557
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...
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.
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