QGIS API Documentation  3.9.0-Master (224899f119)
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"
38 #include "qgseditformconfig.h"
40 #include "qgsaggregatecalculator.h"
41 #include "qgsfeatureiterator.h"
44 #include "qgsexpressioncontext.h"
45 
46 class QPainter;
47 class QImage;
48 
50 class QgsActionManager;
52 class QgsCurve;
54 class QgsDiagramRenderer;
57 class QgsFeatureRenderer;
58 class QgsGeometry;
59 class QgsGeometryVertexIndex;
60 class QgsMapToPixel;
61 class QgsRectangle;
62 class QgsRectangle;
63 class QgsRelation;
64 class QgsRelationManager;
67 class QgsSymbol;
73 class QgsPoint;
74 class QgsFeedback;
76 class QgsAuxiliaryLayer;
77 class QgsGeometryOptions;
79 
80 typedef QList<int> QgsAttributeList;
81 typedef QSet<int> QgsAttributeIds;
82 
83 
366 {
367  Q_OBJECT
368 
369  Q_PROPERTY( QString subsetString READ subsetString WRITE setSubsetString NOTIFY subsetStringChanged )
370  Q_PROPERTY( QString displayExpression READ displayExpression WRITE setDisplayExpression NOTIFY displayExpressionChanged )
371  Q_PROPERTY( QString mapTipTemplate READ mapTipTemplate WRITE setMapTipTemplate NOTIFY mapTipTemplateChanged )
372  Q_PROPERTY( QgsEditFormConfig editFormConfig READ editFormConfig WRITE setEditFormConfig NOTIFY editFormConfigChanged )
373  Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged )
374  Q_PROPERTY( double opacity READ opacity WRITE setOpacity NOTIFY opacityChanged )
375 
376  public:
377 
380  {
381  Success = 0,
382  EmptyGeometry = 1,
383  EditFailed = 2,
384  FetchFeatureFailed = 3,
385  InvalidLayer = 4,
386  };
387 
390  {
395  };
396 
402  {
403 
407  explicit LayerOptions( bool loadDefaultStyle = true,
408  bool readExtentFromXml = false )
409  : loadDefaultStyle( loadDefaultStyle )
410  , readExtentFromXml( readExtentFromXml )
411  {}
412 
417  explicit LayerOptions( const QgsCoordinateTransformContext &transformContext,
418  bool loadDefaultStyle = true,
419  bool readExtentFromXml = false
420  )
421  : loadDefaultStyle( loadDefaultStyle )
422  , readExtentFromXml( readExtentFromXml )
423  , transformContext( transformContext )
424  {}
425 
427  bool loadDefaultStyle = true;
428 
433  bool readExtentFromXml = false;
434 
440 
453 
466 
467  };
468 
482  explicit QgsVectorLayer( const QString &path = QString(), const QString &baseName = QString(),
483  const QString &providerLib = "ogr", const QgsVectorLayer::LayerOptions &options = QgsVectorLayer::LayerOptions() );
484 
485  ~QgsVectorLayer() override;
486 
488  QgsVectorLayer( const QgsVectorLayer &rhs ) = delete;
490  QgsVectorLayer &operator=( QgsVectorLayer const &rhs ) = delete;
491 
500  QgsVectorLayer *clone() const override SIP_FACTORY;
501 
506  QString storageType() const;
507 
511  QString capabilitiesString() const;
512 
516  QString dataComment() const;
517 
525  QString displayField() const;
526 
534  void setDisplayExpression( const QString &displayExpression );
535 
542  QString displayExpression() const;
543 
544  QgsVectorDataProvider *dataProvider() FINAL;
545  const QgsVectorDataProvider *dataProvider() const FINAL SIP_SKIP;
546 
548  void setProviderEncoding( const QString &encoding );
549 
551  void setCoordinateSystem();
552 
558  bool addJoin( const QgsVectorLayerJoinInfo &joinInfo );
559 
564  bool removeJoin( const QString &joinLayerId );
565 
570  QgsVectorLayerJoinBuffer *joinBuffer() { return mJoinBuffer; }
571  const QList<QgsVectorLayerJoinInfo> vectorJoins() const;
572 
581  bool setDependencies( const QSet<QgsMapLayerDependency> &layers ) FINAL;
582 
590  QSet<QgsMapLayerDependency> dependencies() const FINAL;
591 
602  int addExpressionField( const QString &exp, const QgsField &fld );
603 
611  void removeExpressionField( int index );
612 
622  QString expressionField( int index ) const;
623 
633  void updateExpressionField( int index, const QString &exp );
634 
641  QgsActionManager *actions() { return mActions; }
642 
648  const QgsActionManager *actions() const SIP_SKIP { return mActions; }
649 
655  int selectedFeatureCount() const;
656 
666  void selectByRect( QgsRectangle &rect, SelectBehavior behavior = SetSelection );
667 
677  void selectByExpression( const QString &expression, SelectBehavior behavior = SetSelection );
678 
689  void selectByIds( const QgsFeatureIds &ids, SelectBehavior behavior = SetSelection );
690 
702  void modifySelection( const QgsFeatureIds &selectIds, const QgsFeatureIds &deselectIds );
703 
705  void invertSelection();
706 
708  void selectAll();
709 
717  void invertSelectionInRectangle( QgsRectangle &rect );
718 
731  QgsFeatureList selectedFeatures() const;
732 
748  QgsFeatureIterator getSelectedFeatures( QgsFeatureRequest request = QgsFeatureRequest() ) const;
749 
757  const QgsFeatureIds &selectedFeatureIds() const;
758 
760  QgsRectangle boundingBoxOfSelected() const;
761 
769  bool labelsEnabled() const;
770 
780  void setLabelsEnabled( bool enabled );
781 
787  bool diagramsEnabled() const;
788 
790  void setDiagramRenderer( QgsDiagramRenderer *r SIP_TRANSFER );
791  const QgsDiagramRenderer *diagramRenderer() const { return mDiagramRenderer; }
792 
793  void setDiagramLayerSettings( const QgsDiagramLayerSettings &s );
794  const QgsDiagramLayerSettings *diagramLayerSettings() const { return mDiagramLayerSettings; }
795 
797  QgsFeatureRenderer *renderer() { return mRenderer; }
798 
803  const QgsFeatureRenderer *renderer() const SIP_SKIP { return mRenderer; }
804 
809  void setRenderer( QgsFeatureRenderer *r SIP_TRANSFER );
810 
812  QgsWkbTypes::GeometryType geometryType() const;
813 
815  QgsWkbTypes::Type wkbType() const FINAL;
816 
817  QgsCoordinateReferenceSystem sourceCrs() const FINAL;
818  QString sourceName() const FINAL;
819 
824  bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context ) FINAL;
825 
830  bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const FINAL;
831 
832  QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const FINAL;
833  QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const FINAL;
834 
839  void resolveReferences( QgsProject *project ) FINAL;
840 
849  virtual void saveStyleToDatabase( const QString &name, const QString &description,
850  bool useAsDefault, const QString &uiFileContent,
851  QString &msgError SIP_OUT );
852 
862  virtual int listStylesInDatabase( QStringList &ids SIP_OUT, QStringList &names SIP_OUT,
863  QStringList &descriptions SIP_OUT, QString &msgError SIP_OUT );
864 
868  virtual QString getStyleFromDatabase( const QString &styleId, QString &msgError SIP_OUT );
869 
877  virtual bool deleteStyleFromDatabase( const QString &styleId, QString &msgError SIP_OUT );
878 
886  virtual QString loadNamedStyle( const QString &theURI, bool &resultFlag SIP_OUT, bool loadFromLocalDb,
887  QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories );
888 
893  QString loadNamedStyle( const QString &theURI, bool &resultFlag SIP_OUT,
894  QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) FINAL;
895 
909  bool loadAuxiliaryLayer( const QgsAuxiliaryStorage &storage, const QString &key = QString() );
910 
920  void setAuxiliaryLayer( QgsAuxiliaryLayer *layer SIP_TRANSFER = nullptr );
921 
927  QgsAuxiliaryLayer *auxiliaryLayer();
928 
934  const QgsAuxiliaryLayer *auxiliaryLayer() const SIP_SKIP;
935 
944  bool readSymbology( const QDomNode &layerNode, QString &errorMessage,
945  QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) FINAL;
946 
955  bool readStyle( const QDomNode &node, QString &errorMessage,
956  QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) FINAL;
957 
967  bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
968  const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const FINAL;
969 
979  bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
980  const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const FINAL;
981 
990  bool writeSld( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsStringMap &props = QgsStringMap() ) const;
991 
992  bool readSld( const QDomNode &node, QString &errorMessage ) FINAL;
993 
999  long featureCount( const QString &legendKey ) const;
1000 
1007  QgsFeatureIds symbolFeatureIds( const QString &legendKey ) const;
1008 
1019  FeatureAvailability hasFeatures() const FINAL;
1020 
1032  Q_DECL_DEPRECATED void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, bool loadDefaultStyleFlag = false ) SIP_DEPRECATED;
1033 
1046  void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, bool loadDefaultStyleFlag = false ) override;
1047 
1048  QString loadDefaultStyle( bool &resultFlag SIP_OUT ) FINAL;
1049 
1062  QgsVectorLayerFeatureCounter *countSymbolFeatures();
1063 
1071  virtual bool setSubsetString( const QString &subset );
1072 
1077  virtual QString subsetString() const;
1078 
1084  QgsFeatureIterator getFeatures( const QgsFeatureRequest &request = QgsFeatureRequest() ) const FINAL;
1085 
1089  inline QgsFeatureIterator getFeatures( const QString &expression )
1090  {
1091  return getFeatures( QgsFeatureRequest( expression ) );
1092  }
1093 
1098  inline QgsFeature getFeature( QgsFeatureId fid ) const
1099  {
1100  QgsFeature feature;
1101  getFeatures( QgsFeatureRequest( fid ) ).nextFeature( feature );
1102  return feature;
1103  }
1104 
1109  QgsGeometry getGeometry( QgsFeatureId fid ) const;
1110 
1115  {
1116  return getFeatures( QgsFeatureRequest( fids ) );
1117  }
1118 
1122  inline QgsFeatureIterator getFeatures( const QgsRectangle &rectangle )
1123  {
1124  return getFeatures( QgsFeatureRequest( rectangle ) );
1125  }
1126 
1127  bool addFeature( QgsFeature &feature, QgsFeatureSink::Flags flags = nullptr ) FINAL;
1128 
1154  bool updateFeature( QgsFeature &feature, bool skipDefaultValues = false );
1155 
1167  bool insertVertex( double x, double y, QgsFeatureId atFeatureId, int beforeVertex );
1168 
1180  bool insertVertex( const QgsPoint &point, QgsFeatureId atFeatureId, int beforeVertex );
1181 
1192  bool moveVertex( double x, double y, QgsFeatureId atFeatureId, int atVertex );
1193 
1204  bool moveVertex( const QgsPoint &p, QgsFeatureId atFeatureId, int atVertex ) SIP_PYNAME( moveVertexV2 );
1205 
1216  EditResult deleteVertex( QgsFeatureId featureId, int vertex );
1217 
1222  bool deleteSelectedFeatures( int *deletedCount = nullptr );
1223 
1242  QgsGeometry::OperationResult addRing( const QVector<QgsPointXY> &ring, QgsFeatureId *featureId = nullptr );
1243 
1262  QgsGeometry::OperationResult addRing( QgsCurve *ring SIP_TRANSFER, QgsFeatureId *featureId = nullptr ) SIP_PYNAME( addCurvedRing );
1263 
1281  QgsGeometry::OperationResult addPart( const QList<QgsPointXY> &ring );
1282 
1300  QgsGeometry::OperationResult addPart( const QgsPointSequence &ring ) SIP_PYNAME( addPartV2 );
1301 
1309  QgsGeometry::OperationResult addPart( QgsCurve *ring SIP_TRANSFER ) SIP_PYNAME( addCurvedPart );
1310 
1322  int translateFeature( QgsFeatureId featureId, double dx, double dy );
1323 
1341  QgsGeometry::OperationResult splitParts( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false );
1342 
1360  QgsGeometry::OperationResult splitFeatures( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false );
1361 
1372  int addTopologicalPoints( const QgsGeometry &geom );
1373 
1386  int addTopologicalPoints( const QgsPointXY &p );
1387 
1401  int addTopologicalPoints( const QgsPoint &p );
1402 
1409  const QgsAbstractVectorLayerLabeling *labeling() const SIP_SKIP { return mLabeling; }
1410 
1417  QgsAbstractVectorLayerLabeling *labeling() { return mLabeling; }
1418 
1423  void setLabeling( QgsAbstractVectorLayerLabeling *labeling SIP_TRANSFER );
1424 
1426  bool isEditable() const FINAL;
1427 
1429  bool isSpatial() const FINAL;
1430 
1432  virtual bool isModified() const;
1433 
1440  bool isAuxiliaryField( int index, int &srcIndex ) const;
1441 
1443  void reload() FINAL;
1444 
1449  QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) FINAL SIP_FACTORY;
1450 
1451  QgsRectangle extent() const FINAL;
1452  QgsRectangle sourceExtent() const FINAL;
1453 
1460  QgsFields fields() const FINAL;
1461 
1465  inline QgsAttributeList attributeList() const { return mFields.allAttributesList(); }
1466 
1470  QgsAttributeList primaryKeyAttributes() const;
1471 
1477  long featureCount() const FINAL;
1478 
1483  bool setReadOnly( bool readonly = true );
1484 
1505  bool changeGeometry( QgsFeatureId fid, QgsGeometry &geometry, bool skipDefaultValue = false );
1506 
1537  bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant(), bool skipDefaultValues = false );
1538 
1574  bool changeAttributeValues( QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues = QgsAttributeMap(), bool skipDefaultValues = false );
1575 
1585  bool addAttribute( const QgsField &field );
1586 
1592  void setFieldAlias( int index, const QString &aliasString );
1593 
1599  void removeFieldAlias( int index );
1600 
1611  bool renameAttribute( int index, const QString &newName );
1612 
1619  QString attributeAlias( int index ) const;
1620 
1622  QString attributeDisplayName( int index ) const;
1623 
1625  QgsStringMap attributeAliases() const;
1626 
1630  QSet<QString> excludeAttributesWms() const { return mExcludeAttributesWMS; }
1631 
1635  void setExcludeAttributesWms( const QSet<QString> &att ) { mExcludeAttributesWMS = att; }
1636 
1640  QSet<QString> excludeAttributesWfs() const { return mExcludeAttributesWFS; }
1641 
1645  void setExcludeAttributesWfs( const QSet<QString> &att ) { mExcludeAttributesWFS = att; }
1646 
1655  virtual bool deleteAttribute( int attr );
1656 
1664  bool deleteAttributes( const QList<int> &attrs );
1665 
1666  bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = nullptr ) FINAL;
1667 
1676  bool deleteFeature( QgsFeatureId fid );
1677 
1690  bool deleteFeatures( const QgsFeatureIds &fids );
1691 
1712  bool commitChanges();
1713 
1719  QStringList commitErrors() const;
1720 
1730  bool rollBack( bool deleteBuffer = true );
1731 
1738  QList<QgsRelation> referencingRelations( int idx ) const;
1739 
1741  QgsVectorLayerEditBuffer *editBuffer() { return mEditBuffer; }
1742 
1747  const QgsVectorLayerEditBuffer *editBuffer() const SIP_SKIP { return mEditBuffer; }
1748 
1753  void beginEditCommand( const QString &text );
1754 
1756  void endEditCommand();
1757 
1759  void destroyEditCommand();
1760 
1763  {
1766  NoMarker
1767  };
1768 
1773  Q_DECL_DEPRECATED static void drawVertexMarker( double x, double y, QPainter &p, QgsVectorLayer::VertexMarkerType type, int vertexSize );
1774 
1783  void updateFields();
1784 
1799  QVariant defaultValue( int index, const QgsFeature &feature = QgsFeature(),
1800  QgsExpressionContext *context = nullptr ) const;
1801 
1813  void setDefaultValueDefinition( int index, const QgsDefaultValue &definition );
1814 
1825  QgsDefaultValue defaultValueDefinition( int index ) const;
1826 
1834  QgsFieldConstraints::Constraints fieldConstraints( int fieldIndex ) const;
1835 
1841  QMap< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrength> fieldConstraintsAndStrength( int fieldIndex ) const;
1842 
1852 
1860  void removeFieldConstraint( int index, QgsFieldConstraints::Constraint constraint );
1861 
1869  QString constraintExpression( int index ) const;
1870 
1878  QString constraintDescription( int index ) const;
1879 
1888  void setConstraintExpression( int index, const QString &expression, const QString &description = QString() );
1889 
1893  void setEditorWidgetSetup( int index, const QgsEditorWidgetSetup &setup );
1894 
1901  QgsEditorWidgetSetup editorWidgetSetup( int index ) const;
1902 
1914  QSet<QVariant> uniqueValues( int fieldIndex, int limit = -1 ) const FINAL;
1915 
1929  QStringList uniqueStringsMatching( int index, const QString &substring, int limit = -1,
1930  QgsFeedback *feedback = nullptr ) const;
1931 
1940  QVariant minimumValue( int index ) const FINAL;
1941 
1950  QVariant maximumValue( int index ) const FINAL;
1951 
1964  QVariant aggregate( QgsAggregateCalculator::Aggregate aggregate,
1965  const QString &fieldOrExpression,
1966  const QgsAggregateCalculator::AggregateParameters &parameters = QgsAggregateCalculator::AggregateParameters(),
1967  QgsExpressionContext *context = nullptr,
1968  bool *ok = nullptr,
1969  QgsFeatureIds *fids = nullptr ) const;
1970 
1972  void setFeatureBlendMode( QPainter::CompositionMode blendMode );
1974  QPainter::CompositionMode featureBlendMode() const;
1975 
1983  void setOpacity( double opacity );
1984 
1992  double opacity() const;
1993 
1994  QString htmlMetadata() const FINAL;
1995 
2000  void setSimplifyMethod( const QgsVectorSimplifyMethod &simplifyMethod ) { mSimplifyMethod = simplifyMethod; }
2001 
2006  inline const QgsVectorSimplifyMethod &simplifyMethod() const { return mSimplifyMethod; }
2007 
2013  bool simplifyDrawingCanbeApplied( const QgsRenderContext &renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint ) const;
2014 
2022  QgsConditionalLayerStyles *conditionalStyles() const;
2023 
2028  QgsAttributeTableConfig attributeTableConfig() const;
2029 
2034  void setAttributeTableConfig( const QgsAttributeTableConfig &attributeTableConfig );
2035 
2043  QString mapTipTemplate() const;
2044 
2052  void setMapTipTemplate( const QString &mapTipTemplate );
2053 
2054  QgsExpressionContext createExpressionContext() const FINAL;
2055 
2056  QgsExpressionContextScope *createExpressionContextScope() const FINAL SIP_FACTORY;
2057 
2065  QgsEditFormConfig editFormConfig() const;
2066 
2073  void setEditFormConfig( const QgsEditFormConfig &editFormConfig );
2074 
2082  void setReadExtentFromXml( bool readExtentFromXml );
2083 
2091  bool readExtentFromXml() const;
2092 
2098  bool isEditCommandActive() const { return mEditCommandActive; }
2099 
2105  QgsGeometryOptions *geometryOptions() const;
2106 
2125  bool allowCommit() const SIP_SKIP;
2126 
2145  void setAllowCommit( bool allowCommit ) SIP_SKIP;
2146 
2152  QgsStoredExpressionManager *storedExpressionManager() { return mStoredExpressionManager; }
2153 
2154  public slots:
2155 
2163  void select( QgsFeatureId featureId );
2164 
2172  void select( const QgsFeatureIds &featureIds );
2173 
2181  void deselect( QgsFeatureId featureId );
2182 
2190  void deselect( const QgsFeatureIds &featureIds );
2191 
2197  void removeSelection();
2198 
2205  virtual void updateExtents( bool force = false );
2206 
2221  bool startEditing();
2222 
2228  virtual void setTransformContext( const QgsCoordinateTransformContext &transformContext ) override;
2229 
2230  bool accept( QgsStyleEntityVisitorInterface *visitor ) const override;
2231 
2232  signals:
2233 
2241  void selectionChanged( const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect );
2242 
2244  void layerModified();
2245 
2251  void allowCommitChanged();
2252 
2254  void beforeModifiedCheck() const;
2255 
2257  void beforeEditingStarted();
2258 
2260  void editingStarted();
2261 
2263  void editingStopped();
2264 
2266  void beforeCommitChanges();
2267 
2269  void beforeRollBack();
2270 
2275  void afterRollBack();
2276 
2285  void attributeAdded( int idx );
2286 
2293  void beforeAddingExpressionField( const QString &fieldName );
2294 
2303  void attributeDeleted( int idx );
2304 
2311  void beforeRemovingExpressionField( int idx );
2312 
2318  void featureAdded( QgsFeatureId fid );
2319 
2328  void featureDeleted( QgsFeatureId fid );
2329 
2339  void featuresDeleted( const QgsFeatureIds &fids );
2340 
2345  void updatedFields();
2346 
2351  void subsetStringChanged();
2352 
2361  void attributeValueChanged( QgsFeatureId fid, int idx, const QVariant &value );
2362 
2370  void geometryChanged( QgsFeatureId fid, const QgsGeometry &geometry );
2371 
2373  void committedAttributesDeleted( const QString &layerId, const QgsAttributeList &deletedAttributes );
2375  void committedAttributesAdded( const QString &layerId, const QList<QgsField> &addedAttributes );
2377  void committedFeaturesAdded( const QString &layerId, const QgsFeatureList &addedFeatures );
2379  void committedFeaturesRemoved( const QString &layerId, const QgsFeatureIds &deletedFeatureIds );
2381  void committedAttributeValuesChanges( const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues );
2383  void committedGeometriesChanges( const QString &layerId, const QgsGeometryMap &changedGeometries );
2384 
2386  void labelingFontNotFound( QgsVectorLayer *layer, const QString &fontfamily );
2387 
2389  void featureBlendModeChanged( QPainter::CompositionMode blendMode );
2390 
2398  void opacityChanged( double opacity );
2399 
2405  void editCommandStarted( const QString &text );
2406 
2412  void editCommandEnded();
2413 
2419  void editCommandDestroyed();
2420 
2430  void readCustomSymbology( const QDomElement &element, QString &errorMessage );
2431 
2441  void writeCustomSymbology( QDomElement &element, QDomDocument &doc, QString &errorMessage ) const;
2442 
2448  void mapTipTemplateChanged();
2449 
2455  void displayExpressionChanged();
2456 
2460  void raiseError( const QString &msg );
2461 
2467  void editFormConfigChanged();
2468 
2475  void readOnlyChanged();
2476 
2482  void symbolFeatureCountMapChanged();
2483 
2484  protected:
2486  void setExtent( const QgsRectangle &rect ) FINAL;
2487 
2488  private slots:
2489  void invalidateSymbolCountedFlag();
2490  void onFeatureCounterCompleted();
2491  void onFeatureCounterTerminated();
2492  void onJoinedFieldsChanged();
2493  void onFeatureDeleted( QgsFeatureId fid );
2494  void onRelationsLoaded();
2495  void onSymbolsCounted();
2496  void onDirtyTransaction( const QString &sql, const QString &name );
2497  void emitDataChanged();
2498 
2499  private:
2500  void updateDefaultValues( QgsFeatureId fid, QgsFeature feature = QgsFeature() );
2501 
2505  bool isReadOnly() const FINAL;
2506 
2512  bool setDataProvider( QString const &provider, const QgsDataProvider::ProviderOptions &options );
2513 
2515  void readSldLabeling( const QDomNode &node );
2516 
2518  QgsAbstractVectorLayerLabeling *readLabelingFromCustomProperties();
2519 
2520 #ifdef SIP_RUN
2521  QgsVectorLayer( const QgsVectorLayer &rhs );
2522 #endif
2523 
2524  private: // Private attributes
2525  QgsConditionalLayerStyles *mConditionalStyles = nullptr;
2526 
2528  QgsVectorDataProvider *mDataProvider = nullptr;
2529 
2531  QString mDisplayExpression;
2532 
2533  QString mMapTipTemplate;
2534 
2536  QgsActionManager *mActions = nullptr;
2537 
2539  bool mReadOnly = false;
2540 
2546  QgsFeatureIds mSelectedFeatureIds;
2547 
2549  QgsFields mFields;
2550 
2552  QgsStringMap mAttributeAliasMap;
2553 
2555  QMap<QString, QgsDefaultValue> mDefaultExpressionMap;
2556 
2558  QSet<int> mDefaultValueOnUpdateFields;
2559 
2561  QMap< QString, QgsFieldConstraints::Constraints > mFieldConstraints;
2562 
2564  QMap< QPair< QString, QgsFieldConstraints::Constraint >, QgsFieldConstraints::ConstraintStrength > mFieldConstraintStrength;
2565 
2567  QMap< QString, QPair< QString, QString > > mFieldConstraintExpressions;
2568 
2569  QMap< QString, QgsEditorWidgetSetup > mFieldWidgetSetups;
2570 
2572  QgsEditFormConfig mEditFormConfig;
2573 
2575  QSet<QString> mExcludeAttributesWMS;
2576 
2578  QSet<QString> mExcludeAttributesWFS;
2579 
2582 
2584  QgsFeatureRenderer *mRenderer = nullptr;
2585 
2587  QgsVectorSimplifyMethod mSimplifyMethod;
2588 
2590  QgsAbstractVectorLayerLabeling *mLabeling = nullptr;
2591 
2593  bool mLabelsEnabled = false;
2594 
2596  bool mLabelFontNotFoundNotified = false;
2597 
2599  QPainter::CompositionMode mFeatureBlendMode = QPainter::CompositionMode_SourceOver;
2600 
2602  double mLayerOpacity = 1.0;
2603 
2605  bool mVertexMarkerOnlyForSelection = false;
2606 
2607  QStringList mCommitErrors;
2608 
2610  QgsVectorLayerEditBuffer *mEditBuffer = nullptr;
2613 
2614  //stores information about joined layers
2615  QgsVectorLayerJoinBuffer *mJoinBuffer = nullptr;
2616 
2618  QgsExpressionFieldBuffer *mExpressionFieldBuffer = nullptr;
2619 
2620  //diagram rendering object. 0 if diagram drawing is disabled
2621  QgsDiagramRenderer *mDiagramRenderer = nullptr;
2622 
2623  //stores infos about diagram placement (placement type, priority, position distance)
2624  QgsDiagramLayerSettings *mDiagramLayerSettings = nullptr;
2625 
2626  mutable bool mValidExtent = false;
2627  mutable bool mLazyExtent = true;
2628 
2630  std::unique_ptr<QgsAuxiliaryLayer> mAuxiliaryLayer;
2631 
2633  QString mAuxiliaryLayerKey;
2634 
2635  // Features in renderer classes counted
2636  bool mSymbolFeatureCounted = false;
2637 
2638  // Feature counts for each renderer legend key
2639  QHash<QString, long> mSymbolFeatureCountMap;
2640  QHash<QString, QgsFeatureIds> mSymbolFeatureIdMap;
2641 
2643  bool mEditCommandActive = false;
2644 
2645  bool mReadExtentFromXml;
2646  QgsRectangle mXmlExtent;
2647 
2648  QgsFeatureIds mDeletedFids;
2649 
2650  QgsAttributeTableConfig mAttributeTableConfig;
2651 
2652  mutable QMutex mFeatureSourceConstructorMutex;
2653 
2654  QgsVectorLayerFeatureCounter *mFeatureCounter = nullptr;
2655 
2656  std::unique_ptr<QgsGeometryOptions> mGeometryOptions;
2657 
2658  bool mAllowCommit = true;
2659 
2661  QgsStoredExpressionManager *mStoredExpressionManager = nullptr;
2662 
2664 
2666  bool mDataChangedFired = false;
2667 };
2668 
2669 
2670 
2671 // clazy:excludeall=qstring-allocations
2672 
2673 #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
A rectangle specified with double values.
Definition: qgsrectangle.h:41
Base class for all map layer types.
Definition: qgsmaplayer.h:79
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.
The QgsGeometryOptions class contains options to automatically adjust geometries to constraints on a ...
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:61
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:121
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:597
OperationResult
Success or failure of a geometry operation.
Definition: qgsgeometry.h:133
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:44
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.
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
This class wraps a request for features to a vector layer (or directly its vector data provider)...
Reads and writes project states.
Definition: qgsproject.h:90
Storage and management of actions associated with a layer.
QgsAttributeList attributeList() const
Returns list of attribute indexes.
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:48
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.
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
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...
const QgsFeatureRenderer * renderer() const
Returns const renderer.
QSet< int > QgsAttributeIds
QList< int > QgsAttributeList
Definition: qgsfield.h:27
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