QGIS API Documentation  3.8.0-Zanzibar (11aff65)
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_sip.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 
45 class QPainter;
46 class QImage;
47 
49 class QgsActionManager;
51 class QgsCurve;
53 class QgsDiagramRenderer;
56 class QgsFeatureRenderer;
57 class QgsGeometry;
58 class QgsGeometryVertexIndex;
59 class QgsMapToPixel;
60 class QgsRectangle;
61 class QgsRectangle;
62 class QgsRelation;
63 class QgsRelationManager;
65 class QgsSymbol;
71 class QgsPoint;
72 class QgsFeedback;
74 class QgsAuxiliaryLayer;
76 
77 typedef QList<int> QgsAttributeList;
78 typedef QSet<int> QgsAttributeIds;
79 
80 
363 {
364  Q_OBJECT
365 
366  Q_PROPERTY( QString subsetString READ subsetString WRITE setSubsetString NOTIFY subsetStringChanged )
367  Q_PROPERTY( QString displayExpression READ displayExpression WRITE setDisplayExpression NOTIFY displayExpressionChanged )
368  Q_PROPERTY( QString mapTipTemplate READ mapTipTemplate WRITE setMapTipTemplate NOTIFY mapTipTemplateChanged )
369  Q_PROPERTY( QgsEditFormConfig editFormConfig READ editFormConfig WRITE setEditFormConfig NOTIFY editFormConfigChanged )
370  Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged )
371  Q_PROPERTY( double opacity READ opacity WRITE setOpacity NOTIFY opacityChanged )
372 
373  public:
374 
377  {
378  Success = 0,
379  EmptyGeometry = 1,
380  EditFailed = 2,
381  FetchFeatureFailed = 3,
382  InvalidLayer = 4,
383  };
384 
387  {
392  };
393 
399  {
400 
404  explicit LayerOptions( bool loadDefaultStyle = true,
405  bool readExtentFromXml = false )
406  : loadDefaultStyle( loadDefaultStyle )
407  , readExtentFromXml( readExtentFromXml )
408  {}
409 
414  explicit LayerOptions( const QgsCoordinateTransformContext &transformContext,
415  bool loadDefaultStyle = true,
416  bool readExtentFromXml = false
417  )
418  : loadDefaultStyle( loadDefaultStyle )
419  , readExtentFromXml( readExtentFromXml )
420  , transformContext( transformContext )
421  {}
422 
424  bool loadDefaultStyle = true;
425 
430  bool readExtentFromXml = false;
431 
437 
450 
463 
464  };
465 
479  explicit QgsVectorLayer( const QString &path = QString(), const QString &baseName = QString(),
480  const QString &providerLib = "ogr", const QgsVectorLayer::LayerOptions &options = QgsVectorLayer::LayerOptions() );
481 
482  ~QgsVectorLayer() override;
483 
485  QgsVectorLayer( const QgsVectorLayer &rhs ) = delete;
487  QgsVectorLayer &operator=( QgsVectorLayer const &rhs ) = delete;
488 
497  QgsVectorLayer *clone() const override SIP_FACTORY;
498 
503  QString storageType() const;
504 
508  QString capabilitiesString() const;
509 
513  QString dataComment() const;
514 
522  QString displayField() const;
523 
531  void setDisplayExpression( const QString &displayExpression );
532 
539  QString displayExpression() const;
540 
541  QgsVectorDataProvider *dataProvider() FINAL;
542  const QgsVectorDataProvider *dataProvider() const FINAL SIP_SKIP;
543 
545  void setProviderEncoding( const QString &encoding );
546 
548  void setCoordinateSystem();
549 
555  bool addJoin( const QgsVectorLayerJoinInfo &joinInfo );
556 
561  bool removeJoin( const QString &joinLayerId );
562 
567  QgsVectorLayerJoinBuffer *joinBuffer() { return mJoinBuffer; }
568  const QList<QgsVectorLayerJoinInfo> vectorJoins() const;
569 
578  bool setDependencies( const QSet<QgsMapLayerDependency> &layers ) FINAL;
579 
587  QSet<QgsMapLayerDependency> dependencies() const FINAL;
588 
599  int addExpressionField( const QString &exp, const QgsField &fld );
600 
608  void removeExpressionField( int index );
609 
619  QString expressionField( int index ) const;
620 
630  void updateExpressionField( int index, const QString &exp );
631 
638  QgsActionManager *actions() { return mActions; }
639 
645  const QgsActionManager *actions() const SIP_SKIP { return mActions; }
646 
652  int selectedFeatureCount() const;
653 
663  void selectByRect( QgsRectangle &rect, SelectBehavior behavior = SetSelection );
664 
674  void selectByExpression( const QString &expression, SelectBehavior behavior = SetSelection );
675 
686  void selectByIds( const QgsFeatureIds &ids, SelectBehavior behavior = SetSelection );
687 
699  void modifySelection( const QgsFeatureIds &selectIds, const QgsFeatureIds &deselectIds );
700 
702  void invertSelection();
703 
705  void selectAll();
706 
714  void invertSelectionInRectangle( QgsRectangle &rect );
715 
728  QgsFeatureList selectedFeatures() const;
729 
745  QgsFeatureIterator getSelectedFeatures( QgsFeatureRequest request = QgsFeatureRequest() ) const;
746 
754  const QgsFeatureIds &selectedFeatureIds() const;
755 
757  QgsRectangle boundingBoxOfSelected() const;
758 
766  bool labelsEnabled() const;
767 
777  void setLabelsEnabled( bool enabled );
778 
784  bool diagramsEnabled() const;
785 
787  void setDiagramRenderer( QgsDiagramRenderer *r SIP_TRANSFER );
788  const QgsDiagramRenderer *diagramRenderer() const { return mDiagramRenderer; }
789 
790  void setDiagramLayerSettings( const QgsDiagramLayerSettings &s );
791  const QgsDiagramLayerSettings *diagramLayerSettings() const { return mDiagramLayerSettings; }
792 
794  QgsFeatureRenderer *renderer() { return mRenderer; }
795 
800  const QgsFeatureRenderer *renderer() const SIP_SKIP { return mRenderer; }
801 
806  void setRenderer( QgsFeatureRenderer *r SIP_TRANSFER );
807 
809  QgsWkbTypes::GeometryType geometryType() const;
810 
812  QgsWkbTypes::Type wkbType() const FINAL;
813 
814  QgsCoordinateReferenceSystem sourceCrs() const FINAL;
815  QString sourceName() const FINAL;
816 
821  bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context ) FINAL;
822 
827  bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const FINAL;
828 
829  QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const FINAL;
830  QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const FINAL;
831 
836  void resolveReferences( QgsProject *project ) FINAL;
837 
846  virtual void saveStyleToDatabase( const QString &name, const QString &description,
847  bool useAsDefault, const QString &uiFileContent,
848  QString &msgError SIP_OUT );
849 
859  virtual int listStylesInDatabase( QStringList &ids SIP_OUT, QStringList &names SIP_OUT,
860  QStringList &descriptions SIP_OUT, QString &msgError SIP_OUT );
861 
865  virtual QString getStyleFromDatabase( const QString &styleId, QString &msgError SIP_OUT );
866 
874  virtual bool deleteStyleFromDatabase( const QString &styleId, QString &msgError SIP_OUT );
875 
883  virtual QString loadNamedStyle( const QString &theURI, bool &resultFlag SIP_OUT, bool loadFromLocalDb,
884  QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories );
885 
890  QString loadNamedStyle( const QString &theURI, bool &resultFlag SIP_OUT,
891  QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) FINAL;
892 
906  bool loadAuxiliaryLayer( const QgsAuxiliaryStorage &storage, const QString &key = QString() );
907 
917  void setAuxiliaryLayer( QgsAuxiliaryLayer *layer SIP_TRANSFER = nullptr );
918 
924  QgsAuxiliaryLayer *auxiliaryLayer();
925 
931  const QgsAuxiliaryLayer *auxiliaryLayer() const SIP_SKIP;
932 
941  bool readSymbology( const QDomNode &layerNode, QString &errorMessage,
942  QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) FINAL;
943 
952  bool readStyle( const QDomNode &node, QString &errorMessage,
953  QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) FINAL;
954 
964  bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
965  const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const FINAL;
966 
976  bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
977  const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const FINAL;
978 
987  bool writeSld( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsStringMap &props = QgsStringMap() ) const;
988 
989  bool readSld( const QDomNode &node, QString &errorMessage ) FINAL;
990 
996  long featureCount( const QString &legendKey ) const;
997 
1008  FeatureAvailability hasFeatures() const FINAL;
1009 
1021  Q_DECL_DEPRECATED void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, bool loadDefaultStyleFlag = false ) SIP_DEPRECATED;
1022 
1035  void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, bool loadDefaultStyleFlag = false ) override;
1036 
1037  QString loadDefaultStyle( bool &resultFlag SIP_OUT ) FINAL;
1038 
1051  QgsVectorLayerFeatureCounter *countSymbolFeatures();
1052 
1060  virtual bool setSubsetString( const QString &subset );
1061 
1066  virtual QString subsetString() const;
1067 
1073  QgsFeatureIterator getFeatures( const QgsFeatureRequest &request = QgsFeatureRequest() ) const FINAL;
1074 
1078  inline QgsFeatureIterator getFeatures( const QString &expression )
1079  {
1080  return getFeatures( QgsFeatureRequest( expression ) );
1081  }
1082 
1087  inline QgsFeature getFeature( QgsFeatureId fid ) const
1088  {
1089  QgsFeature feature;
1090  getFeatures( QgsFeatureRequest( fid ) ).nextFeature( feature );
1091  return feature;
1092  }
1093 
1098  QgsGeometry getGeometry( QgsFeatureId fid ) const;
1099 
1104  {
1105  return getFeatures( QgsFeatureRequest( fids ) );
1106  }
1107 
1111  inline QgsFeatureIterator getFeatures( const QgsRectangle &rectangle )
1112  {
1113  return getFeatures( QgsFeatureRequest( rectangle ) );
1114  }
1115 
1116  bool addFeature( QgsFeature &feature, QgsFeatureSink::Flags flags = nullptr ) FINAL;
1117 
1143  bool updateFeature( QgsFeature &feature, bool skipDefaultValues = false );
1144 
1156  bool insertVertex( double x, double y, QgsFeatureId atFeatureId, int beforeVertex );
1157 
1169  bool insertVertex( const QgsPoint &point, QgsFeatureId atFeatureId, int beforeVertex );
1170 
1181  bool moveVertex( double x, double y, QgsFeatureId atFeatureId, int atVertex );
1182 
1193  bool moveVertex( const QgsPoint &p, QgsFeatureId atFeatureId, int atVertex ) SIP_PYNAME( moveVertexV2 );
1194 
1205  EditResult deleteVertex( QgsFeatureId featureId, int vertex );
1206 
1211  bool deleteSelectedFeatures( int *deletedCount = nullptr );
1212 
1231  QgsGeometry::OperationResult addRing( const QVector<QgsPointXY> &ring, QgsFeatureId *featureId = nullptr );
1232 
1251  QgsGeometry::OperationResult addRing( QgsCurve *ring SIP_TRANSFER, QgsFeatureId *featureId = nullptr ) SIP_PYNAME( addCurvedRing );
1252 
1270  QgsGeometry::OperationResult addPart( const QList<QgsPointXY> &ring );
1271 
1289  QgsGeometry::OperationResult addPart( const QgsPointSequence &ring ) SIP_PYNAME( addPartV2 );
1290 
1298  QgsGeometry::OperationResult addPart( QgsCurve *ring SIP_TRANSFER ) SIP_PYNAME( addCurvedPart );
1299 
1311  int translateFeature( QgsFeatureId featureId, double dx, double dy );
1312 
1330  QgsGeometry::OperationResult splitParts( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false );
1331 
1349  QgsGeometry::OperationResult splitFeatures( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false );
1350 
1361  int addTopologicalPoints( const QgsGeometry &geom );
1362 
1375  int addTopologicalPoints( const QgsPointXY &p );
1376 
1383  const QgsAbstractVectorLayerLabeling *labeling() const SIP_SKIP { return mLabeling; }
1384 
1391  QgsAbstractVectorLayerLabeling *labeling() { return mLabeling; }
1392 
1397  void setLabeling( QgsAbstractVectorLayerLabeling *labeling SIP_TRANSFER );
1398 
1400  bool isEditable() const FINAL;
1401 
1403  bool isSpatial() const FINAL;
1404 
1406  virtual bool isModified() const;
1407 
1414  bool isAuxiliaryField( int index, int &srcIndex ) const;
1415 
1417  void reload() FINAL;
1418 
1423  QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) FINAL SIP_FACTORY;
1424 
1425  QgsRectangle extent() const FINAL;
1426  QgsRectangle sourceExtent() const FINAL;
1427 
1434  QgsFields fields() const FINAL;
1435 
1439  inline QgsAttributeList attributeList() const { return mFields.allAttributesList(); }
1440 
1444  QgsAttributeList primaryKeyAttributes() const;
1445 
1451  long featureCount() const FINAL;
1452 
1457  bool setReadOnly( bool readonly = true );
1458 
1479  bool changeGeometry( QgsFeatureId fid, QgsGeometry &geometry, bool skipDefaultValue = false );
1480 
1511  bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant(), bool skipDefaultValues = false );
1512 
1548  bool changeAttributeValues( QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues = QgsAttributeMap(), bool skipDefaultValues = false );
1549 
1559  bool addAttribute( const QgsField &field );
1560 
1566  void setFieldAlias( int index, const QString &aliasString );
1567 
1573  void removeFieldAlias( int index );
1574 
1585  bool renameAttribute( int index, const QString &newName );
1586 
1593  QString attributeAlias( int index ) const;
1594 
1596  QString attributeDisplayName( int index ) const;
1597 
1599  QgsStringMap attributeAliases() const;
1600 
1604  QSet<QString> excludeAttributesWms() const { return mExcludeAttributesWMS; }
1605 
1609  void setExcludeAttributesWms( const QSet<QString> &att ) { mExcludeAttributesWMS = att; }
1610 
1614  QSet<QString> excludeAttributesWfs() const { return mExcludeAttributesWFS; }
1615 
1619  void setExcludeAttributesWfs( const QSet<QString> &att ) { mExcludeAttributesWFS = att; }
1620 
1629  virtual bool deleteAttribute( int attr );
1630 
1638  bool deleteAttributes( const QList<int> &attrs );
1639 
1640  bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = nullptr ) FINAL;
1641 
1650  bool deleteFeature( QgsFeatureId fid );
1651 
1664  bool deleteFeatures( const QgsFeatureIds &fids );
1665 
1686  bool commitChanges();
1687 
1693  QStringList commitErrors() const;
1694 
1704  bool rollBack( bool deleteBuffer = true );
1705 
1712  QList<QgsRelation> referencingRelations( int idx ) const;
1713 
1715  QgsVectorLayerEditBuffer *editBuffer() { return mEditBuffer; }
1716 
1721  const QgsVectorLayerEditBuffer *editBuffer() const SIP_SKIP { return mEditBuffer; }
1722 
1727  void beginEditCommand( const QString &text );
1728 
1730  void endEditCommand();
1731 
1733  void destroyEditCommand();
1734 
1737  {
1740  NoMarker
1741  };
1742 
1747  Q_DECL_DEPRECATED static void drawVertexMarker( double x, double y, QPainter &p, QgsVectorLayer::VertexMarkerType type, int vertexSize );
1748 
1757  void updateFields();
1758 
1773  QVariant defaultValue( int index, const QgsFeature &feature = QgsFeature(),
1774  QgsExpressionContext *context = nullptr ) const;
1775 
1787  void setDefaultValueDefinition( int index, const QgsDefaultValue &definition );
1788 
1799  QgsDefaultValue defaultValueDefinition( int index ) const;
1800 
1808  QgsFieldConstraints::Constraints fieldConstraints( int fieldIndex ) const;
1809 
1815  QMap< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrength> fieldConstraintsAndStrength( int fieldIndex ) const;
1816 
1826 
1834  void removeFieldConstraint( int index, QgsFieldConstraints::Constraint constraint );
1835 
1843  QString constraintExpression( int index ) const;
1844 
1852  QString constraintDescription( int index ) const;
1853 
1862  void setConstraintExpression( int index, const QString &expression, const QString &description = QString() );
1863 
1867  void setEditorWidgetSetup( int index, const QgsEditorWidgetSetup &setup );
1868 
1875  QgsEditorWidgetSetup editorWidgetSetup( int index ) const;
1876 
1888  QSet<QVariant> uniqueValues( int fieldIndex, int limit = -1 ) const FINAL;
1889 
1903  QStringList uniqueStringsMatching( int index, const QString &substring, int limit = -1,
1904  QgsFeedback *feedback = nullptr ) const;
1905 
1914  QVariant minimumValue( int index ) const FINAL;
1915 
1924  QVariant maximumValue( int index ) const FINAL;
1925 
1938  QVariant aggregate( QgsAggregateCalculator::Aggregate aggregate,
1939  const QString &fieldOrExpression,
1940  const QgsAggregateCalculator::AggregateParameters &parameters = QgsAggregateCalculator::AggregateParameters(),
1941  QgsExpressionContext *context = nullptr,
1942  bool *ok = nullptr,
1943  QgsFeatureIds *fids = nullptr ) const;
1944 
1946  void setFeatureBlendMode( QPainter::CompositionMode blendMode );
1948  QPainter::CompositionMode featureBlendMode() const;
1949 
1957  void setOpacity( double opacity );
1958 
1966  double opacity() const;
1967 
1968  QString htmlMetadata() const FINAL;
1969 
1974  void setSimplifyMethod( const QgsVectorSimplifyMethod &simplifyMethod ) { mSimplifyMethod = simplifyMethod; }
1975 
1980  inline const QgsVectorSimplifyMethod &simplifyMethod() const { return mSimplifyMethod; }
1981 
1987  bool simplifyDrawingCanbeApplied( const QgsRenderContext &renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint ) const;
1988 
1996  QgsConditionalLayerStyles *conditionalStyles() const;
1997 
2002  QgsAttributeTableConfig attributeTableConfig() const;
2003 
2008  void setAttributeTableConfig( const QgsAttributeTableConfig &attributeTableConfig );
2009 
2017  QString mapTipTemplate() const;
2018 
2026  void setMapTipTemplate( const QString &mapTipTemplate );
2027 
2028  QgsExpressionContext createExpressionContext() const FINAL;
2029 
2030  QgsExpressionContextScope *createExpressionContextScope() const FINAL SIP_FACTORY;
2031 
2039  QgsEditFormConfig editFormConfig() const;
2040 
2047  void setEditFormConfig( const QgsEditFormConfig &editFormConfig );
2048 
2056  void setReadExtentFromXml( bool readExtentFromXml );
2057 
2065  bool readExtentFromXml() const;
2066 
2072  bool isEditCommandActive() const { return mEditCommandActive; }
2073 
2079  QgsGeometryOptions *geometryOptions() const;
2080 
2099  bool allowCommit() const SIP_SKIP;
2100 
2119  void setAllowCommit( bool allowCommit ) SIP_SKIP;
2120 
2121 
2122  public slots:
2123 
2131  void select( QgsFeatureId featureId );
2132 
2140  void select( const QgsFeatureIds &featureIds );
2141 
2149  void deselect( QgsFeatureId featureId );
2150 
2158  void deselect( const QgsFeatureIds &featureIds );
2159 
2165  void removeSelection();
2166 
2173  virtual void updateExtents( bool force = false );
2174 
2189  bool startEditing();
2190 
2196  virtual void setTransformContext( const QgsCoordinateTransformContext &transformContext ) override;
2197 
2198  signals:
2199 
2207  void selectionChanged( const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect );
2208 
2210  void layerModified();
2211 
2217  void allowCommitChanged();
2218 
2220  void beforeModifiedCheck() const;
2221 
2223  void beforeEditingStarted();
2224 
2226  void editingStarted();
2227 
2229  void editingStopped();
2230 
2232  void beforeCommitChanges();
2233 
2235  void beforeRollBack();
2236 
2241  void afterRollBack();
2242 
2251  void attributeAdded( int idx );
2252 
2259  void beforeAddingExpressionField( const QString &fieldName );
2260 
2269  void attributeDeleted( int idx );
2270 
2277  void beforeRemovingExpressionField( int idx );
2278 
2284  void featureAdded( QgsFeatureId fid );
2285 
2294  void featureDeleted( QgsFeatureId fid );
2295 
2305  void featuresDeleted( const QgsFeatureIds &fids );
2306 
2311  void updatedFields();
2312 
2317  void subsetStringChanged();
2318 
2327  void attributeValueChanged( QgsFeatureId fid, int idx, const QVariant &value );
2328 
2336  void geometryChanged( QgsFeatureId fid, const QgsGeometry &geometry );
2337 
2339  void committedAttributesDeleted( const QString &layerId, const QgsAttributeList &deletedAttributes );
2341  void committedAttributesAdded( const QString &layerId, const QList<QgsField> &addedAttributes );
2343  void committedFeaturesAdded( const QString &layerId, const QgsFeatureList &addedFeatures );
2345  void committedFeaturesRemoved( const QString &layerId, const QgsFeatureIds &deletedFeatureIds );
2347  void committedAttributeValuesChanges( const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues );
2349  void committedGeometriesChanges( const QString &layerId, const QgsGeometryMap &changedGeometries );
2350 
2352  void labelingFontNotFound( QgsVectorLayer *layer, const QString &fontfamily );
2353 
2355  void featureBlendModeChanged( QPainter::CompositionMode blendMode );
2356 
2364  void opacityChanged( double opacity );
2365 
2371  void editCommandStarted( const QString &text );
2372 
2378  void editCommandEnded();
2379 
2385  void editCommandDestroyed();
2386 
2396  void readCustomSymbology( const QDomElement &element, QString &errorMessage );
2397 
2407  void writeCustomSymbology( QDomElement &element, QDomDocument &doc, QString &errorMessage ) const;
2408 
2414  void mapTipTemplateChanged();
2415 
2421  void displayExpressionChanged();
2422 
2426  void raiseError( const QString &msg );
2427 
2433  void editFormConfigChanged();
2434 
2441  void readOnlyChanged();
2442 
2448  void symbolFeatureCountMapChanged();
2449 
2450  protected:
2452  void setExtent( const QgsRectangle &rect ) FINAL;
2453 
2454  private slots:
2455  void invalidateSymbolCountedFlag();
2456  void onFeatureCounterCompleted();
2457  void onFeatureCounterTerminated();
2458  void onJoinedFieldsChanged();
2459  void onFeatureDeleted( QgsFeatureId fid );
2460  void onRelationsLoaded();
2461  void onSymbolsCounted();
2462  void onDirtyTransaction( const QString &sql, const QString &name );
2463 
2464  private:
2465  void updateDefaultValues( QgsFeatureId fid, QgsFeature feature = QgsFeature() );
2466 
2470  bool isReadOnly() const FINAL;
2471 
2477  bool setDataProvider( QString const &provider, const QgsDataProvider::ProviderOptions &options );
2478 
2480  void readSldLabeling( const QDomNode &node );
2481 
2483  QgsAbstractVectorLayerLabeling *readLabelingFromCustomProperties();
2484 
2485 #ifdef SIP_RUN
2486  QgsVectorLayer( const QgsVectorLayer &rhs );
2487 #endif
2488 
2489  private: // Private attributes
2490  QgsConditionalLayerStyles *mConditionalStyles = nullptr;
2491 
2493  QgsVectorDataProvider *mDataProvider = nullptr;
2494 
2496  QString mDisplayExpression;
2497 
2498  QString mMapTipTemplate;
2499 
2501  QgsActionManager *mActions = nullptr;
2502 
2504  bool mReadOnly = false;
2505 
2511  QgsFeatureIds mSelectedFeatureIds;
2512 
2514  QgsFields mFields;
2515 
2517  QgsStringMap mAttributeAliasMap;
2518 
2520  QMap<QString, QgsDefaultValue> mDefaultExpressionMap;
2521 
2523  QSet<int> mDefaultValueOnUpdateFields;
2524 
2526  QMap< QString, QgsFieldConstraints::Constraints > mFieldConstraints;
2527 
2529  QMap< QPair< QString, QgsFieldConstraints::Constraint >, QgsFieldConstraints::ConstraintStrength > mFieldConstraintStrength;
2530 
2532  QMap< QString, QPair< QString, QString > > mFieldConstraintExpressions;
2533 
2534  QMap< QString, QgsEditorWidgetSetup > mFieldWidgetSetups;
2535 
2537  QgsEditFormConfig mEditFormConfig;
2538 
2540  QSet<QString> mExcludeAttributesWMS;
2541 
2543  QSet<QString> mExcludeAttributesWFS;
2544 
2547 
2549  QgsFeatureRenderer *mRenderer = nullptr;
2550 
2552  QgsVectorSimplifyMethod mSimplifyMethod;
2553 
2555  QgsAbstractVectorLayerLabeling *mLabeling = nullptr;
2556 
2558  bool mLabelsEnabled = false;
2559 
2561  bool mLabelFontNotFoundNotified = false;
2562 
2564  QPainter::CompositionMode mFeatureBlendMode = QPainter::CompositionMode_SourceOver;
2565 
2567  double mLayerOpacity = 1.0;
2568 
2570  bool mVertexMarkerOnlyForSelection = false;
2571 
2572  QStringList mCommitErrors;
2573 
2575  QgsVectorLayerEditBuffer *mEditBuffer = nullptr;
2578 
2579  //stores information about joined layers
2580  QgsVectorLayerJoinBuffer *mJoinBuffer = nullptr;
2581 
2583  QgsExpressionFieldBuffer *mExpressionFieldBuffer = nullptr;
2584 
2585  //diagram rendering object. 0 if diagram drawing is disabled
2586  QgsDiagramRenderer *mDiagramRenderer = nullptr;
2587 
2588  //stores infos about diagram placement (placement type, priority, position distance)
2589  QgsDiagramLayerSettings *mDiagramLayerSettings = nullptr;
2590 
2591  mutable bool mValidExtent = false;
2592  mutable bool mLazyExtent = true;
2593 
2595  std::unique_ptr<QgsAuxiliaryLayer> mAuxiliaryLayer;
2596 
2598  QString mAuxiliaryLayerKey;
2599 
2600  // Features in renderer classes counted
2601  bool mSymbolFeatureCounted = false;
2602 
2603  // Feature counts for each renderer legend key
2604  QHash<QString, long> mSymbolFeatureCountMap;
2605 
2607  bool mEditCommandActive = false;
2608 
2609  bool mReadExtentFromXml;
2610  QgsRectangle mXmlExtent;
2611 
2612  QgsFeatureIds mDeletedFids;
2613 
2614  QgsAttributeTableConfig mAttributeTableConfig;
2615 
2616  mutable QMutex mFeatureSourceConstructorMutex;
2617 
2618  QgsVectorLayerFeatureCounter *mFeatureCounter = nullptr;
2619 
2620  std::unique_ptr<QgsGeometryOptions> mGeometryOptions;
2621 
2622  bool mAllowCommit = true;
2623 
2625 };
2626 
2627 
2628 
2629 // clazy:excludeall=qstring-allocations
2630 
2631 #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:78
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.
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:111
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
QMap< QString, QString > QgsStringMap
Definition: qgis.h:587
OperationResult
Success or failure of a geometry operation.
Definition: qgsgeometry.h:123
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:119
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:89
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:69
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:99
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:216
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:51
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.
Abstract base class for simplify geometries using a specific algorithm.
#define SIP_PYNAME(name)
Definition: qgis_sip.h:74