QGIS API Documentation  3.12.1-BucureČ™ti (121cc00ff0)
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;
82 
83 typedef QList<int> QgsAttributeList;
84 typedef QSet<int> QgsAttributeIds;
85 
86 
387 {
388  Q_OBJECT
389 
390  Q_PROPERTY( QString subsetString READ subsetString WRITE setSubsetString NOTIFY subsetStringChanged )
391  Q_PROPERTY( QString displayExpression READ displayExpression WRITE setDisplayExpression NOTIFY displayExpressionChanged )
392  Q_PROPERTY( QString mapTipTemplate READ mapTipTemplate WRITE setMapTipTemplate NOTIFY mapTipTemplateChanged )
393  Q_PROPERTY( QgsEditFormConfig editFormConfig READ editFormConfig WRITE setEditFormConfig NOTIFY editFormConfigChanged )
394  Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged )
395  Q_PROPERTY( double opacity READ opacity WRITE setOpacity NOTIFY opacityChanged )
396 
397  public:
398 
401  {
402  Success = 0,
403  EmptyGeometry = 1,
404  EditFailed = 2,
405  FetchFeatureFailed = 3,
406  InvalidLayer = 4,
407  };
408  Q_ENUM( EditResult )
409 
410 
412  {
417  };
418  Q_ENUM( SelectBehavior )
419 
420 
425  {
426 
430  explicit LayerOptions( bool loadDefaultStyle = true,
431  bool readExtentFromXml = false )
432  : loadDefaultStyle( loadDefaultStyle )
433  , readExtentFromXml( readExtentFromXml )
434  {}
435 
440  explicit LayerOptions( const QgsCoordinateTransformContext &transformContext,
441  bool loadDefaultStyle = true,
442  bool readExtentFromXml = false
443  )
444  : loadDefaultStyle( loadDefaultStyle )
445  , readExtentFromXml( readExtentFromXml )
446  , transformContext( transformContext )
447  {}
448 
450  bool loadDefaultStyle = true;
451 
456  bool readExtentFromXml = false;
457 
463 
476 
489 
503  bool skipCrsValidation = false;
504 
505  };
506 
520  explicit QgsVectorLayer( const QString &path = QString(), const QString &baseName = QString(),
521  const QString &providerLib = "ogr", const QgsVectorLayer::LayerOptions &options = QgsVectorLayer::LayerOptions() );
522 
523  ~QgsVectorLayer() override;
524 
526  QgsVectorLayer( const QgsVectorLayer &rhs ) = delete;
528  QgsVectorLayer &operator=( QgsVectorLayer const &rhs ) = delete;
529 
538  QgsVectorLayer *clone() const override SIP_FACTORY;
539 
544  QString storageType() const;
545 
549  QString capabilitiesString() const;
550 
554  QString dataComment() const;
555 
563  QString displayField() const;
564 
572  void setDisplayExpression( const QString &displayExpression );
573 
580  QString displayExpression() const;
581 
582  QgsVectorDataProvider *dataProvider() FINAL;
583  const QgsVectorDataProvider *dataProvider() const FINAL SIP_SKIP;
584 
595  void setProviderEncoding( const QString &encoding );
596 
598  void setCoordinateSystem();
599 
605  bool addJoin( const QgsVectorLayerJoinInfo &joinInfo );
606 
611  bool removeJoin( const QString &joinLayerId );
612 
617  QgsVectorLayerJoinBuffer *joinBuffer() { return mJoinBuffer; }
618 
623  const QgsVectorLayerJoinBuffer *joinBuffer() const { return mJoinBuffer; } SIP_SKIP;
624 
625  const QList<QgsVectorLayerJoinInfo> vectorJoins() const;
626 
635  bool setDependencies( const QSet<QgsMapLayerDependency> &layers ) FINAL;
636 
644  QSet<QgsMapLayerDependency> dependencies() const FINAL;
645 
656  int addExpressionField( const QString &exp, const QgsField &fld );
657 
665  void removeExpressionField( int index );
666 
676  QString expressionField( int index ) const;
677 
687  void updateExpressionField( int index, const QString &exp );
688 
695  QgsActionManager *actions() { return mActions; }
696 
702  const QgsActionManager *actions() const SIP_SKIP { return mActions; }
703 
708  QgsVectorLayerServerProperties *serverProperties() const { return mServerProperties.get(); }
709 
715  int selectedFeatureCount() const;
716 
726  Q_INVOKABLE void selectByRect( QgsRectangle &rect, QgsVectorLayer::SelectBehavior behavior = QgsVectorLayer::SetSelection );
727 
737  Q_INVOKABLE void selectByExpression( const QString &expression, QgsVectorLayer::SelectBehavior behavior = QgsVectorLayer::SetSelection );
738 
749  Q_INVOKABLE void selectByIds( const QgsFeatureIds &ids, QgsVectorLayer::SelectBehavior behavior = QgsVectorLayer::SetSelection );
750 
762  Q_INVOKABLE void modifySelection( const QgsFeatureIds &selectIds, const QgsFeatureIds &deselectIds );
763 
765  Q_INVOKABLE void invertSelection();
766 
768  Q_INVOKABLE void selectAll();
769 
777  Q_INVOKABLE void invertSelectionInRectangle( QgsRectangle &rect );
778 
791  Q_INVOKABLE QgsFeatureList selectedFeatures() const;
792 
808  QgsFeatureIterator getSelectedFeatures( QgsFeatureRequest request = QgsFeatureRequest() ) const;
809 
817  Q_INVOKABLE const QgsFeatureIds &selectedFeatureIds() const;
818 
820  Q_INVOKABLE QgsRectangle boundingBoxOfSelected() const;
821 
829  bool labelsEnabled() const;
830 
840  void setLabelsEnabled( bool enabled );
841 
847  bool diagramsEnabled() const;
848 
850  void setDiagramRenderer( QgsDiagramRenderer *r SIP_TRANSFER );
851  const QgsDiagramRenderer *diagramRenderer() const { return mDiagramRenderer; }
852 
853  void setDiagramLayerSettings( const QgsDiagramLayerSettings &s );
854  const QgsDiagramLayerSettings *diagramLayerSettings() const { return mDiagramLayerSettings; }
855 
857  QgsFeatureRenderer *renderer() { return mRenderer; }
858 
863  const QgsFeatureRenderer *renderer() const SIP_SKIP { return mRenderer; }
864 
869  void setRenderer( QgsFeatureRenderer *r SIP_TRANSFER );
870 
872  Q_INVOKABLE QgsWkbTypes::GeometryType geometryType() const;
873 
875  Q_INVOKABLE QgsWkbTypes::Type wkbType() const FINAL;
876 
878  QString sourceName() const FINAL;
879 
884  bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context ) FINAL;
885 
890  bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const FINAL;
891 
892  QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const FINAL;
893  QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const FINAL;
894 
899  void resolveReferences( QgsProject *project ) FINAL;
900 
909  virtual void saveStyleToDatabase( const QString &name, const QString &description,
910  bool useAsDefault, const QString &uiFileContent,
911  QString &msgError SIP_OUT );
912 
922  virtual int listStylesInDatabase( QStringList &ids SIP_OUT, QStringList &names SIP_OUT,
923  QStringList &descriptions SIP_OUT, QString &msgError SIP_OUT );
924 
928  virtual QString getStyleFromDatabase( const QString &styleId, QString &msgError SIP_OUT );
929 
937  virtual bool deleteStyleFromDatabase( const QString &styleId, QString &msgError SIP_OUT );
938 
946  virtual QString loadNamedStyle( const QString &theURI, bool &resultFlag SIP_OUT, bool loadFromLocalDb,
947  QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories );
948 
953  QString loadNamedStyle( const QString &theURI, bool &resultFlag SIP_OUT,
954  QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) FINAL;
955 
969  bool loadAuxiliaryLayer( const QgsAuxiliaryStorage &storage, const QString &key = QString() );
970 
980  void setAuxiliaryLayer( QgsAuxiliaryLayer *layer SIP_TRANSFER = nullptr );
981 
987  QgsAuxiliaryLayer *auxiliaryLayer();
988 
994  const QgsAuxiliaryLayer *auxiliaryLayer() const SIP_SKIP;
995 
1004  bool readSymbology( const QDomNode &layerNode, QString &errorMessage,
1005  QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) FINAL;
1006 
1015  bool readStyle( const QDomNode &node, QString &errorMessage,
1016  QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) FINAL;
1017 
1027  bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
1028  const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const FINAL;
1029 
1039  bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
1040  const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const FINAL;
1041 
1050  bool writeSld( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsStringMap &props = QgsStringMap() ) const;
1051 
1052  bool readSld( const QDomNode &node, QString &errorMessage ) FINAL;
1053 
1059  long featureCount( const QString &legendKey ) const;
1060 
1067  QgsFeatureIds symbolFeatureIds( const QString &legendKey ) const;
1068 
1080 
1092  Q_DECL_DEPRECATED void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, bool loadDefaultStyleFlag = false ) SIP_DEPRECATED;
1093 
1106  void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, bool loadDefaultStyleFlag = false ) override;
1107 
1108  QString loadDefaultStyle( bool &resultFlag SIP_OUT ) FINAL;
1109 
1123  QgsVectorLayerFeatureCounter *countSymbolFeatures( bool storeSymbolFids = false );
1124 
1132  virtual bool setSubsetString( const QString &subset );
1133 
1138  virtual QString subsetString() const;
1139 
1146 
1150  inline QgsFeatureIterator getFeatures( const QString &expression )
1151  {
1152  return getFeatures( QgsFeatureRequest( expression ) );
1153  }
1154 
1159  inline QgsFeature getFeature( QgsFeatureId fid ) const
1160  {
1161  QgsFeature feature;
1162  getFeatures( QgsFeatureRequest( fid ) ).nextFeature( feature );
1163  return feature;
1164  }
1165 
1170  QgsGeometry getGeometry( QgsFeatureId fid ) const;
1171 
1176  {
1177  return getFeatures( QgsFeatureRequest( fids ) );
1178  }
1179 
1183  inline QgsFeatureIterator getFeatures( const QgsRectangle &rectangle )
1184  {
1185  return getFeatures( QgsFeatureRequest( rectangle ) );
1186  }
1187 
1188  bool addFeature( QgsFeature &feature, QgsFeatureSink::Flags flags = nullptr ) FINAL;
1189 
1215  bool updateFeature( QgsFeature &feature, bool skipDefaultValues = false );
1216 
1228  bool insertVertex( double x, double y, QgsFeatureId atFeatureId, int beforeVertex );
1229 
1241  bool insertVertex( const QgsPoint &point, QgsFeatureId atFeatureId, int beforeVertex );
1242 
1253  bool moveVertex( double x, double y, QgsFeatureId atFeatureId, int atVertex );
1254 
1265  bool moveVertex( const QgsPoint &p, QgsFeatureId atFeatureId, int atVertex ) SIP_PYNAME( moveVertexV2 );
1266 
1277  EditResult deleteVertex( QgsFeatureId featureId, int vertex );
1278 
1283  Q_INVOKABLE bool deleteSelectedFeatures( int *deletedCount = nullptr );
1284 
1304  Q_DECL_DEPRECATED QgsGeometry::OperationResult addRing( const QVector<QgsPointXY> &ring, QgsFeatureId *featureId = nullptr ) SIP_DEPRECATED;
1305 
1306 
1325  Q_INVOKABLE QgsGeometry::OperationResult addRing( const QgsPointSequence &ring, QgsFeatureId *featureId = nullptr );
1326 
1345  Q_INVOKABLE QgsGeometry::OperationResult addRing( QgsCurve *ring SIP_TRANSFER, QgsFeatureId *featureId = nullptr ) SIP_PYNAME( addCurvedRing );
1346 
1365  Q_DECL_DEPRECATED QgsGeometry::OperationResult addPart( const QList<QgsPointXY> &ring ) SIP_DEPRECATED;
1366 
1385  Q_DECL_DEPRECATED QgsGeometry::OperationResult addPart( const QVector<QgsPointXY> &ring ) SIP_PYNAME( addPartV2 ) SIP_DEPRECATED;
1386 
1404  Q_INVOKABLE QgsGeometry::OperationResult addPart( const QgsPointSequence &ring ) SIP_PYNAME( addPartV2 );
1405 
1413  Q_INVOKABLE QgsGeometry::OperationResult addPart( QgsCurve *ring SIP_TRANSFER ) SIP_PYNAME( addCurvedPart );
1414 
1426  Q_INVOKABLE int translateFeature( QgsFeatureId featureId, double dx, double dy );
1427 
1446  Q_DECL_DEPRECATED QgsGeometry::OperationResult splitParts( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false ) SIP_DEPRECATED;
1447 
1465  Q_INVOKABLE QgsGeometry::OperationResult splitParts( const QgsPointSequence &splitLine, bool topologicalEditing = false );
1466 
1485  Q_DECL_DEPRECATED QgsGeometry::OperationResult splitFeatures( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false ) SIP_DEPRECATED;
1486 
1504  Q_INVOKABLE QgsGeometry::OperationResult splitFeatures( const QgsPointSequence &splitLine, bool topologicalEditing = false );
1505 
1516  int addTopologicalPoints( const QgsGeometry &geom );
1517 
1531  Q_DECL_DEPRECATED int addTopologicalPoints( const QgsPointXY &p ) SIP_DEPRECATED;
1532 
1546  int addTopologicalPoints( const QgsPoint &p );
1547 
1554  const QgsAbstractVectorLayerLabeling *labeling() const SIP_SKIP { return mLabeling; }
1555 
1562  QgsAbstractVectorLayerLabeling *labeling() { return mLabeling; }
1563 
1568  void setLabeling( QgsAbstractVectorLayerLabeling *labeling SIP_TRANSFER );
1569 
1571  bool isEditable() const FINAL;
1572 
1574  bool isSpatial() const FINAL;
1575 
1577  virtual bool isModified() const;
1578 
1585  bool isAuxiliaryField( int index, int &srcIndex ) const;
1586 
1588  void reload() FINAL;
1589 
1595 
1596  QgsRectangle extent() const FINAL;
1598 
1605  QgsFields fields() const FINAL;
1606 
1610  inline QgsAttributeList attributeList() const { return mFields.allAttributesList(); }
1611 
1615  QgsAttributeList primaryKeyAttributes() const;
1616 
1622  long featureCount() const FINAL;
1623 
1628  bool setReadOnly( bool readonly = true );
1629 
1650  bool changeGeometry( QgsFeatureId fid, QgsGeometry &geometry, bool skipDefaultValue = false );
1651 
1682  bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant(), bool skipDefaultValues = false );
1683 
1719  bool changeAttributeValues( QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues = QgsAttributeMap(), bool skipDefaultValues = false );
1720 
1730  bool addAttribute( const QgsField &field );
1731 
1737  void setFieldAlias( int index, const QString &aliasString );
1738 
1744  void removeFieldAlias( int index );
1745 
1756  bool renameAttribute( int index, const QString &newName );
1757 
1764  QString attributeAlias( int index ) const;
1765 
1767  QString attributeDisplayName( int index ) const;
1768 
1770  QgsStringMap attributeAliases() const;
1771 
1775  QSet<QString> excludeAttributesWms() const { return mExcludeAttributesWMS; }
1776 
1780  void setExcludeAttributesWms( const QSet<QString> &att ) { mExcludeAttributesWMS = att; }
1781 
1785  QSet<QString> excludeAttributesWfs() const { return mExcludeAttributesWFS; }
1786 
1790  void setExcludeAttributesWfs( const QSet<QString> &att ) { mExcludeAttributesWFS = att; }
1791 
1800  virtual bool deleteAttribute( int attr );
1801 
1809  bool deleteAttributes( const QList<int> &attrs );
1810 
1811  bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = nullptr ) FINAL;
1812 
1821  bool deleteFeature( QgsFeatureId fid );
1822 
1835  bool deleteFeatures( const QgsFeatureIds &fids );
1836 
1857  Q_INVOKABLE bool commitChanges();
1858 
1864  QStringList commitErrors() const;
1865 
1875  Q_INVOKABLE bool rollBack( bool deleteBuffer = true );
1876 
1883  QList<QgsRelation> referencingRelations( int idx ) const;
1884 
1891  QList<QgsWeakRelation> weakRelations( ) const SIP_SKIP;
1892 
1893 
1895  Q_INVOKABLE QgsVectorLayerEditBuffer *editBuffer() { return mEditBuffer; }
1896 
1901  const QgsVectorLayerEditBuffer *editBuffer() const SIP_SKIP { return mEditBuffer; }
1902 
1907  void beginEditCommand( const QString &text );
1908 
1910  void endEditCommand();
1911 
1913  void destroyEditCommand();
1914 
1917  {
1920  NoMarker
1921  };
1922 
1927  Q_DECL_DEPRECATED static void drawVertexMarker( double x, double y, QPainter &p, QgsVectorLayer::VertexMarkerType type, int vertexSize );
1928 
1937  void updateFields();
1938 
1953  QVariant defaultValue( int index, const QgsFeature &feature = QgsFeature(),
1954  QgsExpressionContext *context = nullptr ) const;
1955 
1967  void setDefaultValueDefinition( int index, const QgsDefaultValue &definition );
1968 
1979  QgsDefaultValue defaultValueDefinition( int index ) const;
1980 
1988  QgsFieldConstraints::Constraints fieldConstraints( int fieldIndex ) const;
1989 
1995  QMap< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrength> fieldConstraintsAndStrength( int fieldIndex ) const;
1996 
2006 
2014  void removeFieldConstraint( int index, QgsFieldConstraints::Constraint constraint );
2015 
2023  QString constraintExpression( int index ) const;
2024 
2032  QString constraintDescription( int index ) const;
2033 
2042  void setConstraintExpression( int index, const QString &expression, const QString &description = QString() );
2043 
2047  void setEditorWidgetSetup( int index, const QgsEditorWidgetSetup &setup );
2048 
2055  QgsEditorWidgetSetup editorWidgetSetup( int index ) const;
2056 
2068  QSet<QVariant> uniqueValues( int fieldIndex, int limit = -1 ) const FINAL;
2069 
2083  QStringList uniqueStringsMatching( int index, const QString &substring, int limit = -1,
2084  QgsFeedback *feedback = nullptr ) const;
2085 
2094  QVariant minimumValue( int index ) const FINAL;
2095 
2104  QVariant maximumValue( int index ) const FINAL;
2105 
2118  QVariant aggregate( QgsAggregateCalculator::Aggregate aggregate,
2119  const QString &fieldOrExpression,
2120  const QgsAggregateCalculator::AggregateParameters &parameters = QgsAggregateCalculator::AggregateParameters(),
2121  QgsExpressionContext *context = nullptr,
2122  bool *ok = nullptr,
2123  QgsFeatureIds *fids = nullptr ) const;
2124 
2126  void setFeatureBlendMode( QPainter::CompositionMode blendMode );
2128  QPainter::CompositionMode featureBlendMode() const;
2129 
2137  void setOpacity( double opacity );
2138 
2146  double opacity() const;
2147 
2148  QString htmlMetadata() const FINAL;
2149 
2154  void setSimplifyMethod( const QgsVectorSimplifyMethod &simplifyMethod ) { mSimplifyMethod = simplifyMethod; }
2155 
2160  inline const QgsVectorSimplifyMethod &simplifyMethod() const { return mSimplifyMethod; }
2161 
2167  bool simplifyDrawingCanbeApplied( const QgsRenderContext &renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint ) const;
2168 
2176  QgsConditionalLayerStyles *conditionalStyles() const;
2177 
2182  QgsAttributeTableConfig attributeTableConfig() const;
2183 
2188  void setAttributeTableConfig( const QgsAttributeTableConfig &attributeTableConfig );
2189 
2197  QString mapTipTemplate() const;
2198 
2206  void setMapTipTemplate( const QString &mapTipTemplate );
2207 
2209 
2211 
2219  QgsEditFormConfig editFormConfig() const;
2220 
2227  void setEditFormConfig( const QgsEditFormConfig &editFormConfig );
2228 
2236  void setReadExtentFromXml( bool readExtentFromXml );
2237 
2245  bool readExtentFromXml() const;
2246 
2252  bool isEditCommandActive() const { return mEditCommandActive; }
2253 
2259  QgsGeometryOptions *geometryOptions() const;
2260 
2279  bool allowCommit() const SIP_SKIP;
2280 
2299  void setAllowCommit( bool allowCommit ) SIP_SKIP;
2300 
2306  QgsStoredExpressionManager *storedExpressionManager() { return mStoredExpressionManager; }
2307 
2308  public slots:
2309 
2317  void select( QgsFeatureId featureId );
2318 
2326  void select( const QgsFeatureIds &featureIds );
2327 
2335  void deselect( QgsFeatureId featureId );
2336 
2344  void deselect( const QgsFeatureIds &featureIds );
2345 
2352  void removeSelection();
2353 
2364  void reselect();
2365 
2372  virtual void updateExtents( bool force = false );
2373 
2388  Q_INVOKABLE bool startEditing();
2389 
2395  virtual void setTransformContext( const QgsCoordinateTransformContext &transformContext ) override;
2396 
2397  SpatialIndexPresence hasSpatialIndex() const override;
2398 
2399  bool accept( QgsStyleEntityVisitorInterface *visitor ) const override;
2400 
2401  signals:
2402 
2410  void selectionChanged( const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect );
2411 
2413  void layerModified();
2414 
2420  void allowCommitChanged();
2421 
2423  void beforeModifiedCheck() const;
2424 
2426  void beforeEditingStarted();
2427 
2429  void editingStarted();
2430 
2432  void editingStopped();
2433 
2435  void beforeCommitChanges();
2436 
2438  void beforeRollBack();
2439 
2444  void afterRollBack();
2445 
2454  void attributeAdded( int idx );
2455 
2462  void beforeAddingExpressionField( const QString &fieldName );
2463 
2472  void attributeDeleted( int idx );
2473 
2480  void beforeRemovingExpressionField( int idx );
2481 
2487  void featureAdded( QgsFeatureId fid );
2488 
2497  void featureDeleted( QgsFeatureId fid );
2498 
2508  void featuresDeleted( const QgsFeatureIds &fids );
2509 
2514  void updatedFields();
2515 
2520  void subsetStringChanged();
2521 
2530  void attributeValueChanged( QgsFeatureId fid, int idx, const QVariant &value );
2531 
2539  void geometryChanged( QgsFeatureId fid, const QgsGeometry &geometry );
2540 
2542  void committedAttributesDeleted( const QString &layerId, const QgsAttributeList &deletedAttributes );
2544  void committedAttributesAdded( const QString &layerId, const QList<QgsField> &addedAttributes );
2546  void committedFeaturesAdded( const QString &layerId, const QgsFeatureList &addedFeatures );
2548  void committedFeaturesRemoved( const QString &layerId, const QgsFeatureIds &deletedFeatureIds );
2550  void committedAttributeValuesChanges( const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues );
2552  void committedGeometriesChanges( const QString &layerId, const QgsGeometryMap &changedGeometries );
2553 
2555  void labelingFontNotFound( QgsVectorLayer *layer, const QString &fontfamily );
2556 
2558  void featureBlendModeChanged( QPainter::CompositionMode blendMode );
2559 
2567  void opacityChanged( double opacity );
2568 
2574  void editCommandStarted( const QString &text );
2575 
2581  void editCommandEnded();
2582 
2588  void editCommandDestroyed();
2589 
2599  void readCustomSymbology( const QDomElement &element, QString &errorMessage );
2600 
2610  void writeCustomSymbology( QDomElement &element, QDomDocument &doc, QString &errorMessage ) const;
2611 
2617  void mapTipTemplateChanged();
2618 
2624  void displayExpressionChanged();
2625 
2629  void raiseError( const QString &msg );
2630 
2636  void editFormConfigChanged();
2637 
2644  void readOnlyChanged();
2645 
2651  void symbolFeatureCountMapChanged();
2652 
2653  protected:
2655  void setExtent( const QgsRectangle &rect ) FINAL;
2656 
2657  private slots:
2658  void invalidateSymbolCountedFlag();
2659  void onFeatureCounterCompleted();
2660  void onFeatureCounterTerminated();
2661  void onJoinedFieldsChanged();
2662  void onFeatureDeleted( QgsFeatureId fid );
2663  void onRelationsLoaded();
2664  void onSymbolsCounted();
2665  void onDirtyTransaction( const QString &sql, const QString &name );
2666  void emitDataChanged();
2667 
2668  private:
2669  void updateDefaultValues( QgsFeatureId fid, QgsFeature feature = QgsFeature() );
2670 
2674  bool isReadOnly() const FINAL;
2675 
2681  bool setDataProvider( QString const &provider, const QgsDataProvider::ProviderOptions &options );
2682 
2684  void readSldLabeling( const QDomNode &node );
2685 
2687  bool readSldTextSymbolizer( const QDomNode &node, QgsPalLayerSettings &settings ) const;
2688 
2690  QgsAbstractVectorLayerLabeling *readLabelingFromCustomProperties();
2691 
2692 #ifdef SIP_RUN
2693  QgsVectorLayer( const QgsVectorLayer &rhs );
2694 #endif
2695  QVariant minimumOrMaximumValue( int index, bool minimum ) const;
2697 
2698  private: // Private attributes
2699  QgsConditionalLayerStyles *mConditionalStyles = nullptr;
2700 
2702  QgsVectorDataProvider *mDataProvider = nullptr;
2703 
2705  QString mDisplayExpression;
2706 
2707  QString mMapTipTemplate;
2708 
2710  QgsActionManager *mActions = nullptr;
2711 
2713  bool mReadOnly = false;
2714 
2720  QgsFeatureIds mSelectedFeatureIds;
2721 
2725  QgsFeatureIds mPreviousSelectedFeatureIds;
2726 
2728  QgsFields mFields;
2729 
2731  QgsStringMap mAttributeAliasMap;
2732 
2734  QMap<QString, QgsDefaultValue> mDefaultExpressionMap;
2735 
2737  QSet<int> mDefaultValueOnUpdateFields;
2738 
2740  QMap< QString, QgsFieldConstraints::Constraints > mFieldConstraints;
2741 
2743  QMap< QPair< QString, QgsFieldConstraints::Constraint >, QgsFieldConstraints::ConstraintStrength > mFieldConstraintStrength;
2744 
2746  QMap< QString, QPair< QString, QString > > mFieldConstraintExpressions;
2747 
2748  QMap< QString, QgsEditorWidgetSetup > mFieldWidgetSetups;
2749 
2751  QgsEditFormConfig mEditFormConfig;
2752 
2754  QSet<QString> mExcludeAttributesWMS;
2755 
2757  QSet<QString> mExcludeAttributesWFS;
2758 
2761 
2763  QgsFeatureRenderer *mRenderer = nullptr;
2764 
2766  QgsVectorSimplifyMethod mSimplifyMethod;
2767 
2769  QgsAbstractVectorLayerLabeling *mLabeling = nullptr;
2770 
2772  bool mLabelsEnabled = false;
2773 
2775  bool mLabelFontNotFoundNotified = false;
2776 
2778  QPainter::CompositionMode mFeatureBlendMode = QPainter::CompositionMode_SourceOver;
2779 
2781  double mLayerOpacity = 1.0;
2782 
2784  bool mVertexMarkerOnlyForSelection = false;
2785 
2786  QStringList mCommitErrors;
2787 
2789  QgsVectorLayerEditBuffer *mEditBuffer = nullptr;
2792 
2793  //stores information about joined layers
2794  QgsVectorLayerJoinBuffer *mJoinBuffer = nullptr;
2795 
2797  std::unique_ptr< QgsVectorLayerServerProperties > mServerProperties;
2798 
2800  QgsExpressionFieldBuffer *mExpressionFieldBuffer = nullptr;
2801 
2802  //diagram rendering object. 0 if diagram drawing is disabled
2803  QgsDiagramRenderer *mDiagramRenderer = nullptr;
2804 
2805  //stores infos about diagram placement (placement type, priority, position distance)
2806  QgsDiagramLayerSettings *mDiagramLayerSettings = nullptr;
2807 
2808  mutable bool mValidExtent = false;
2809  mutable bool mLazyExtent = true;
2810 
2812  std::unique_ptr<QgsAuxiliaryLayer> mAuxiliaryLayer;
2813 
2815  QString mAuxiliaryLayerKey;
2816 
2817  // Features in renderer classes counted
2818  bool mSymbolFeatureCounted = false;
2819 
2820  // Feature counts for each renderer legend key
2821  QHash<QString, long> mSymbolFeatureCountMap;
2822  QHash<QString, QgsFeatureIds> mSymbolFeatureIdMap;
2823 
2825  bool mEditCommandActive = false;
2826 
2827  bool mReadExtentFromXml;
2828  QgsRectangle mXmlExtent;
2829 
2830  QgsFeatureIds mDeletedFids;
2831 
2832  QgsAttributeTableConfig mAttributeTableConfig;
2833 
2834  mutable QMutex mFeatureSourceConstructorMutex;
2835 
2836  QgsVectorLayerFeatureCounter *mFeatureCounter = nullptr;
2837 
2838  std::unique_ptr<QgsGeometryOptions> mGeometryOptions;
2839 
2840  bool mAllowCommit = true;
2841 
2843  QgsStoredExpressionManager *mStoredExpressionManager = nullptr;
2844 
2846 
2848  bool mDataChangedFired = false;
2849 
2850  QList<QgsWeakRelation> mWeakRelations;
2851 };
2852 
2853 
2854 
2855 // clazy:excludeall=qstring-allocations
2856 
2857 #endif
virtual bool writeStyle(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) const
Write just the symbology information for the layer into the document.
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
virtual QgsRectangle sourceExtent() const
Returns the extent of all geometries from the source.
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.
virtual QgsFields fields() const =0
Returns the fields associated with features in the source.
virtual QgsMapLayer * clone() const =0
Returns a new instance equivalent to this one except for the id which is still unique.
The QgsGeometryOptions class contains options to automatically adjust geometries to constraints on a ...
Abstract base class for all rendered symbols.
Definition: qgssymbol.h:62
virtual QSet< QgsMapLayerDependency > dependencies() const
Gets the list of dependencies.
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.
virtual QgsWkbTypes::Type wkbType() const =0
Returns the geometry type for features returned by this source.
QgsStoredExpressionManager * storedExpressionManager()
Returns the manager of the stored expressions for this layer.
virtual void reload()
Synchronises with changes in the datasource.
Definition: qgsmaplayer.h:465
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.
virtual void resolveReferences(QgsProject *project)
Resolve references to other layers (kept as layer IDs after reading XML) into layer objects...
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 ...
virtual bool writeXml(QDomNode &layer_node, QDomDocument &document, const QgsReadWriteContext &context) const
Called by writeLayerXML(), used by children to write state specific to them to project files...
Container of fields for a vector layer.
Definition: qgsfields.h:42
virtual bool accept(QgsStyleEntityVisitorInterface *visitor) const
Accepts the specified symbology visitor, causing it to visit all symbols associated with the layer...
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...
virtual QString encodedSource(const QString &source, const QgsReadWriteContext &context) const
Called by writeLayerXML(), used by derived classes to encode provider&#39;s specific data source to proje...
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:694
OperationResult
Success or failure of a geometry operation.
Definition: qgsgeometry.h:134
virtual QgsRectangle extent() const
Returns the extent of the layer.
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:45
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
virtual QgsExpressionContext createExpressionContext() const =0
This method needs to be reimplemented in all classes which implement this interface and return an exp...
virtual QString decodedSource(const QString &source, const QString &dataProvider, const QgsReadWriteContext &context) const
Called by readLayerXML(), used by derived classes to decode provider&#39;s specific data source from proj...
#define SIP_SKIP
Definition: qgis_sip.h:126
Evaluates and returns the diagram settings relating to a diagram for a specific feature.
virtual void setExtent(const QgsRectangle &rect)
Sets the extent.
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
QgsMapLayer & operator=(QgsMapLayer const &)=delete
QgsMapLayer cannot be copied.
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)...
virtual bool isEditable() const
Returns true if the layer can be edited.
virtual SpatialIndexPresence hasSpatialIndex() const
Returns an enum value representing the presence of a valid spatial index on the source, if it can be determined.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts, annotations, canvases, etc.
Definition: qgsproject.h:91
Storage and management of actions associated with a layer.
QgsAttributeList attributeList() const
Returns list of attribute indexes.
virtual bool addFeature(QgsFeature &feature, QgsFeatureSink::Flags flags=nullptr)
Adds a single feature to the sink.
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
virtual QSet< QVariant > uniqueValues(int fieldIndex, int limit=-1) const
Returns the set of unique values contained within the specified fieldIndex from this source...
virtual bool readSld(const QDomNode &node, QString &errorMessage)
Definition: qgsmaplayer.h:869
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings for fast rendering of features.
virtual bool readXml(const QDomNode &layer_node, QgsReadWriteContext &context)
Called by readLayerXML(), used by children to read state specific to them from project files...
const QgsDiagramRenderer * diagramRenderer() const
virtual bool addFeatures(QgsFeatureList &features, QgsFeatureSink::Flags flags=nullptr)=0
Adds a list of features to the sink.
virtual QgsCoordinateReferenceSystem sourceCrs() const =0
Returns the coordinate reference system for features in the source.
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.
virtual void setTransformContext(const QgsCoordinateTransformContext &transformContext)=0
Sets the coordinate transform context to transformContext.
virtual bool writeSymbology(QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories) const =0
Write the style for the layer into the docment provided.
QVector< QgsPoint > QgsPointSequence
GeometryType
The geometry types are used to group QgsWkbTypes::Type in a coarse way.
Definition: qgswkbtypes.h:139
virtual bool readStyle(const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories)
Read the style for the current layer from the DOM node supplied.
Modify current selection to include only select features which match.
SelectBehavior
Selection behavior.
virtual QString loadDefaultStyle(bool &resultFlag)
Retrieve the default style for this layer if one exists (either as a .qml file on disk or as a record...
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.
virtual QgsExpressionContextScope * createExpressionContextScope() const =0
This method needs to be reimplemented in all classes which implement this interface and return an exp...
Buffers information about expression fields for a vector layer.
#define FINAL
Definition: qgis_sip.h:223
virtual bool readSymbology(const QDomNode &node, QString &errorMessage, QgsReadWriteContext &context, StyleCategories categories=AllStyleCategories)=0
Read the symbology for the current layer from the DOM node supplied.
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.
virtual QString loadNamedStyle(const QString &uri, bool &resultFlag, QgsMapLayer::StyleCategories categories=QgsMapLayer::AllStyleCategories)
Retrieve a named style for this layer if one exists (either as a .qml file on disk or as a record in ...
This class represents a coordinate reference system (CRS).
Abstract base class - its implementations define different approaches to the labeling of a vector lay...
virtual bool isSpatial() const
Returns true if the layer is considered a spatial layer, ie it has some form of geometry associated w...
Base class for utility classes that encapsulate information necessary for rendering of map layers...
virtual QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext)=0
Returns new instance of QgsMapLayerRenderer that will be used for rendering of given context...
SpatialIndexPresence
Enumeration of spatial index presence states.
virtual void setDataSource(const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, bool loadDefaultStyleFlag=false)
Updates the data source of the layer.
const QgsFeatureRenderer * renderer() const
Returns const renderer.
QSet< int > QgsAttributeIds
QList< int > QgsAttributeList
Definition: qgsfield.h:26
bool nextFeature(QgsFeature &f)
This is a container for configuration of the attribute table.
This is the base class for vector data providers.
virtual QString sourceName() const =0
Returns a friendly display name for the source.
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.
virtual FeatureAvailability hasFeatures() const
Determines if there are any features available in the source.
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.
virtual QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const =0
Returns an iterator for the features in the source.
#define SIP_PYNAME(name)
Definition: qgis_sip.h:81
virtual long featureCount() const =0
Returns the number of features contained in the source, or -1 if the feature count is unknown...
virtual bool setDependencies(const QSet< QgsMapLayerDependency > &layers)
Sets the list of dependencies.