QGIS API Documentation  3.15.0-Master (a49cb7c9f3)
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
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:567
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:572
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:44
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:714
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:558
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