QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
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 QgsRelationManager;
68 class QgsSymbol;
74 class QgsPoint;
75 class QgsFeedback;
77 class QgsAuxiliaryLayer;
78 class QgsGeometryOptions;
80 
81 typedef QList<int> QgsAttributeList;
82 typedef QSet<int> QgsAttributeIds;
83 
84 
367 {
368  Q_OBJECT
369 
370  Q_PROPERTY( QString subsetString READ subsetString WRITE setSubsetString NOTIFY subsetStringChanged )
371  Q_PROPERTY( QString displayExpression READ displayExpression WRITE setDisplayExpression NOTIFY displayExpressionChanged )
372  Q_PROPERTY( QString mapTipTemplate READ mapTipTemplate WRITE setMapTipTemplate NOTIFY mapTipTemplateChanged )
373  Q_PROPERTY( QgsEditFormConfig editFormConfig READ editFormConfig WRITE setEditFormConfig NOTIFY editFormConfigChanged )
374  Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly NOTIFY readOnlyChanged )
375  Q_PROPERTY( double opacity READ opacity WRITE setOpacity NOTIFY opacityChanged )
376 
377  public:
378 
381  {
382  Success = 0,
383  EmptyGeometry = 1,
384  EditFailed = 2,
385  FetchFeatureFailed = 3,
386  InvalidLayer = 4,
387  };
388 
391  {
396  };
397 
403  {
404 
408  explicit LayerOptions( bool loadDefaultStyle = true,
409  bool readExtentFromXml = false )
410  : loadDefaultStyle( loadDefaultStyle )
411  , readExtentFromXml( readExtentFromXml )
412  {}
413 
418  explicit LayerOptions( const QgsCoordinateTransformContext &transformContext,
419  bool loadDefaultStyle = true,
420  bool readExtentFromXml = false
421  )
422  : loadDefaultStyle( loadDefaultStyle )
423  , readExtentFromXml( readExtentFromXml )
424  , transformContext( transformContext )
425  {}
426 
428  bool loadDefaultStyle = true;
429 
434  bool readExtentFromXml = false;
435 
441 
454 
467 
481  bool skipCrsValidation = false;
482 
483  };
484 
498  explicit QgsVectorLayer( const QString &path = QString(), const QString &baseName = QString(),
499  const QString &providerLib = "ogr", const QgsVectorLayer::LayerOptions &options = QgsVectorLayer::LayerOptions() );
500 
501  ~QgsVectorLayer() override;
502 
504  QgsVectorLayer( const QgsVectorLayer &rhs ) = delete;
506  QgsVectorLayer &operator=( QgsVectorLayer const &rhs ) = delete;
507 
516  QgsVectorLayer *clone() const override SIP_FACTORY;
517 
522  QString storageType() const;
523 
527  QString capabilitiesString() const;
528 
532  QString dataComment() const;
533 
541  QString displayField() const;
542 
550  void setDisplayExpression( const QString &displayExpression );
551 
558  QString displayExpression() const;
559 
560  QgsVectorDataProvider *dataProvider() FINAL;
561  const QgsVectorDataProvider *dataProvider() const FINAL SIP_SKIP;
562 
564  void setProviderEncoding( const QString &encoding );
565 
567  void setCoordinateSystem();
568 
574  bool addJoin( const QgsVectorLayerJoinInfo &joinInfo );
575 
580  bool removeJoin( const QString &joinLayerId );
581 
586  QgsVectorLayerJoinBuffer *joinBuffer() { return mJoinBuffer; }
587 
592  const QgsVectorLayerJoinBuffer *joinBuffer() const { return mJoinBuffer; } SIP_SKIP;
593 
594  const QList<QgsVectorLayerJoinInfo> vectorJoins() const;
595 
604  bool setDependencies( const QSet<QgsMapLayerDependency> &layers ) FINAL;
605 
613  QSet<QgsMapLayerDependency> dependencies() const FINAL;
614 
625  int addExpressionField( const QString &exp, const QgsField &fld );
626 
634  void removeExpressionField( int index );
635 
645  QString expressionField( int index ) const;
646 
656  void updateExpressionField( int index, const QString &exp );
657 
664  QgsActionManager *actions() { return mActions; }
665 
671  const QgsActionManager *actions() const SIP_SKIP { return mActions; }
672 
677  QgsVectorLayerServerProperties *serverProperties() { return mServerProperties.get(); }
678 
684  int selectedFeatureCount() const;
685 
695  void selectByRect( QgsRectangle &rect, SelectBehavior behavior = SetSelection );
696 
706  void selectByExpression( const QString &expression, SelectBehavior behavior = SetSelection );
707 
718  void selectByIds( const QgsFeatureIds &ids, SelectBehavior behavior = SetSelection );
719 
731  void modifySelection( const QgsFeatureIds &selectIds, const QgsFeatureIds &deselectIds );
732 
734  void invertSelection();
735 
737  void selectAll();
738 
746  void invertSelectionInRectangle( QgsRectangle &rect );
747 
760  QgsFeatureList selectedFeatures() const;
761 
777  QgsFeatureIterator getSelectedFeatures( QgsFeatureRequest request = QgsFeatureRequest() ) const;
778 
786  const QgsFeatureIds &selectedFeatureIds() const;
787 
789  QgsRectangle boundingBoxOfSelected() const;
790 
798  bool labelsEnabled() const;
799 
809  void setLabelsEnabled( bool enabled );
810 
816  bool diagramsEnabled() const;
817 
819  void setDiagramRenderer( QgsDiagramRenderer *r SIP_TRANSFER );
820  const QgsDiagramRenderer *diagramRenderer() const { return mDiagramRenderer; }
821 
822  void setDiagramLayerSettings( const QgsDiagramLayerSettings &s );
823  const QgsDiagramLayerSettings *diagramLayerSettings() const { return mDiagramLayerSettings; }
824 
826  QgsFeatureRenderer *renderer() { return mRenderer; }
827 
832  const QgsFeatureRenderer *renderer() const SIP_SKIP { return mRenderer; }
833 
838  void setRenderer( QgsFeatureRenderer *r SIP_TRANSFER );
839 
841  QgsWkbTypes::GeometryType geometryType() const;
842 
844  QgsWkbTypes::Type wkbType() const FINAL;
845 
846  QgsCoordinateReferenceSystem sourceCrs() const FINAL;
847  QString sourceName() const FINAL;
848 
853  bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context ) FINAL;
854 
859  bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const FINAL;
860 
861  QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const FINAL;
862  QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const FINAL;
863 
868  void resolveReferences( QgsProject *project ) FINAL;
869 
878  virtual void saveStyleToDatabase( const QString &name, const QString &description,
879  bool useAsDefault, const QString &uiFileContent,
880  QString &msgError SIP_OUT );
881 
891  virtual int listStylesInDatabase( QStringList &ids SIP_OUT, QStringList &names SIP_OUT,
892  QStringList &descriptions SIP_OUT, QString &msgError SIP_OUT );
893 
897  virtual QString getStyleFromDatabase( const QString &styleId, QString &msgError SIP_OUT );
898 
906  virtual bool deleteStyleFromDatabase( const QString &styleId, QString &msgError SIP_OUT );
907 
915  virtual QString loadNamedStyle( const QString &theURI, bool &resultFlag SIP_OUT, bool loadFromLocalDb,
916  QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories );
917 
922  QString loadNamedStyle( const QString &theURI, bool &resultFlag SIP_OUT,
923  QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) FINAL;
924 
938  bool loadAuxiliaryLayer( const QgsAuxiliaryStorage &storage, const QString &key = QString() );
939 
949  void setAuxiliaryLayer( QgsAuxiliaryLayer *layer SIP_TRANSFER = nullptr );
950 
956  QgsAuxiliaryLayer *auxiliaryLayer();
957 
963  const QgsAuxiliaryLayer *auxiliaryLayer() const SIP_SKIP;
964 
973  bool readSymbology( const QDomNode &layerNode, QString &errorMessage,
974  QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) FINAL;
975 
984  bool readStyle( const QDomNode &node, QString &errorMessage,
985  QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) FINAL;
986 
996  bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
997  const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const FINAL;
998 
1008  bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
1009  const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const FINAL;
1010 
1019  bool writeSld( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsStringMap &props = QgsStringMap() ) const;
1020 
1021  bool readSld( const QDomNode &node, QString &errorMessage ) FINAL;
1022 
1028  long featureCount( const QString &legendKey ) const;
1029 
1036  QgsFeatureIds symbolFeatureIds( const QString &legendKey ) const;
1037 
1048  FeatureAvailability hasFeatures() const FINAL;
1049 
1061  Q_DECL_DEPRECATED void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, bool loadDefaultStyleFlag = false ) SIP_DEPRECATED;
1062 
1075  void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, bool loadDefaultStyleFlag = false ) override;
1076 
1077  QString loadDefaultStyle( bool &resultFlag SIP_OUT ) FINAL;
1078 
1091  QgsVectorLayerFeatureCounter *countSymbolFeatures();
1092 
1100  virtual bool setSubsetString( const QString &subset );
1101 
1106  virtual QString subsetString() const;
1107 
1113  QgsFeatureIterator getFeatures( const QgsFeatureRequest &request = QgsFeatureRequest() ) const FINAL;
1114 
1118  inline QgsFeatureIterator getFeatures( const QString &expression )
1119  {
1120  return getFeatures( QgsFeatureRequest( expression ) );
1121  }
1122 
1127  inline QgsFeature getFeature( QgsFeatureId fid ) const
1128  {
1129  QgsFeature feature;
1130  getFeatures( QgsFeatureRequest( fid ) ).nextFeature( feature );
1131  return feature;
1132  }
1133 
1138  QgsGeometry getGeometry( QgsFeatureId fid ) const;
1139 
1144  {
1145  return getFeatures( QgsFeatureRequest( fids ) );
1146  }
1147 
1151  inline QgsFeatureIterator getFeatures( const QgsRectangle &rectangle )
1152  {
1153  return getFeatures( QgsFeatureRequest( rectangle ) );
1154  }
1155 
1156  bool addFeature( QgsFeature &feature, QgsFeatureSink::Flags flags = nullptr ) FINAL;
1157 
1183  bool updateFeature( QgsFeature &feature, bool skipDefaultValues = false );
1184 
1196  bool insertVertex( double x, double y, QgsFeatureId atFeatureId, int beforeVertex );
1197 
1209  bool insertVertex( const QgsPoint &point, QgsFeatureId atFeatureId, int beforeVertex );
1210 
1221  bool moveVertex( double x, double y, QgsFeatureId atFeatureId, int atVertex );
1222 
1233  bool moveVertex( const QgsPoint &p, QgsFeatureId atFeatureId, int atVertex ) SIP_PYNAME( moveVertexV2 );
1234 
1245  EditResult deleteVertex( QgsFeatureId featureId, int vertex );
1246 
1251  bool deleteSelectedFeatures( int *deletedCount = nullptr );
1252 
1272  Q_DECL_DEPRECATED QgsGeometry::OperationResult addRing( const QVector<QgsPointXY> &ring, QgsFeatureId *featureId = nullptr ) SIP_DEPRECATED;
1273 
1274 
1293  QgsGeometry::OperationResult addRing( const QgsPointSequence &ring, QgsFeatureId *featureId = nullptr );
1294 
1313  QgsGeometry::OperationResult addRing( QgsCurve *ring SIP_TRANSFER, QgsFeatureId *featureId = nullptr ) SIP_PYNAME( addCurvedRing );
1314 
1333  Q_DECL_DEPRECATED QgsGeometry::OperationResult addPart( const QList<QgsPointXY> &ring ) SIP_DEPRECATED;
1334 
1353  Q_DECL_DEPRECATED QgsGeometry::OperationResult addPart( const QVector<QgsPointXY> &ring ) SIP_PYNAME( addPartV2 ) SIP_DEPRECATED;
1354 
1372  QgsGeometry::OperationResult addPart( const QgsPointSequence &ring ) SIP_PYNAME( addPartV2 );
1373 
1381  QgsGeometry::OperationResult addPart( QgsCurve *ring SIP_TRANSFER ) SIP_PYNAME( addCurvedPart );
1382 
1394  int translateFeature( QgsFeatureId featureId, double dx, double dy );
1395 
1414  Q_DECL_DEPRECATED QgsGeometry::OperationResult splitParts( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false ) SIP_DEPRECATED;
1415 
1433  QgsGeometry::OperationResult splitParts( const QgsPointSequence &splitLine, bool topologicalEditing = false );
1434 
1453  Q_DECL_DEPRECATED QgsGeometry::OperationResult splitFeatures( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false ) SIP_DEPRECATED;
1454 
1472  QgsGeometry::OperationResult splitFeatures( const QgsPointSequence &splitLine, bool topologicalEditing = false );
1473 
1484  int addTopologicalPoints( const QgsGeometry &geom );
1485 
1499  Q_DECL_DEPRECATED int addTopologicalPoints( const QgsPointXY &p ) SIP_DEPRECATED;
1500 
1514  int addTopologicalPoints( const QgsPoint &p );
1515 
1522  const QgsAbstractVectorLayerLabeling *labeling() const SIP_SKIP { return mLabeling; }
1523 
1530  QgsAbstractVectorLayerLabeling *labeling() { return mLabeling; }
1531 
1536  void setLabeling( QgsAbstractVectorLayerLabeling *labeling SIP_TRANSFER );
1537 
1539  bool isEditable() const FINAL;
1540 
1542  bool isSpatial() const FINAL;
1543 
1545  virtual bool isModified() const;
1546 
1553  bool isAuxiliaryField( int index, int &srcIndex ) const;
1554 
1556  void reload() FINAL;
1557 
1562  QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) FINAL SIP_FACTORY;
1563 
1564  QgsRectangle extent() const FINAL;
1565  QgsRectangle sourceExtent() const FINAL;
1566 
1573  QgsFields fields() const FINAL;
1574 
1578  inline QgsAttributeList attributeList() const { return mFields.allAttributesList(); }
1579 
1583  QgsAttributeList primaryKeyAttributes() const;
1584 
1590  long featureCount() const FINAL;
1591 
1596  bool setReadOnly( bool readonly = true );
1597 
1618  bool changeGeometry( QgsFeatureId fid, QgsGeometry &geometry, bool skipDefaultValue = false );
1619 
1650  bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant(), bool skipDefaultValues = false );
1651 
1687  bool changeAttributeValues( QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues = QgsAttributeMap(), bool skipDefaultValues = false );
1688 
1698  bool addAttribute( const QgsField &field );
1699 
1705  void setFieldAlias( int index, const QString &aliasString );
1706 
1712  void removeFieldAlias( int index );
1713 
1724  bool renameAttribute( int index, const QString &newName );
1725 
1732  QString attributeAlias( int index ) const;
1733 
1735  QString attributeDisplayName( int index ) const;
1736 
1738  QgsStringMap attributeAliases() const;
1739 
1743  QSet<QString> excludeAttributesWms() const { return mExcludeAttributesWMS; }
1744 
1748  void setExcludeAttributesWms( const QSet<QString> &att ) { mExcludeAttributesWMS = att; }
1749 
1753  QSet<QString> excludeAttributesWfs() const { return mExcludeAttributesWFS; }
1754 
1758  void setExcludeAttributesWfs( const QSet<QString> &att ) { mExcludeAttributesWFS = att; }
1759 
1768  virtual bool deleteAttribute( int attr );
1769 
1777  bool deleteAttributes( const QList<int> &attrs );
1778 
1779  bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = nullptr ) FINAL;
1780 
1789  bool deleteFeature( QgsFeatureId fid );
1790 
1803  bool deleteFeatures( const QgsFeatureIds &fids );
1804 
1825  bool commitChanges();
1826 
1832  QStringList commitErrors() const;
1833 
1843  bool rollBack( bool deleteBuffer = true );
1844 
1851  QList<QgsRelation> referencingRelations( int idx ) const;
1852 
1854  QgsVectorLayerEditBuffer *editBuffer() { return mEditBuffer; }
1855 
1860  const QgsVectorLayerEditBuffer *editBuffer() const SIP_SKIP { return mEditBuffer; }
1861 
1866  void beginEditCommand( const QString &text );
1867 
1869  void endEditCommand();
1870 
1872  void destroyEditCommand();
1873 
1876  {
1879  NoMarker
1880  };
1881 
1886  Q_DECL_DEPRECATED static void drawVertexMarker( double x, double y, QPainter &p, QgsVectorLayer::VertexMarkerType type, int vertexSize );
1887 
1896  void updateFields();
1897 
1912  QVariant defaultValue( int index, const QgsFeature &feature = QgsFeature(),
1913  QgsExpressionContext *context = nullptr ) const;
1914 
1926  void setDefaultValueDefinition( int index, const QgsDefaultValue &definition );
1927 
1938  QgsDefaultValue defaultValueDefinition( int index ) const;
1939 
1947  QgsFieldConstraints::Constraints fieldConstraints( int fieldIndex ) const;
1948 
1954  QMap< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrength> fieldConstraintsAndStrength( int fieldIndex ) const;
1955 
1965 
1973  void removeFieldConstraint( int index, QgsFieldConstraints::Constraint constraint );
1974 
1982  QString constraintExpression( int index ) const;
1983 
1991  QString constraintDescription( int index ) const;
1992 
2001  void setConstraintExpression( int index, const QString &expression, const QString &description = QString() );
2002 
2006  void setEditorWidgetSetup( int index, const QgsEditorWidgetSetup &setup );
2007 
2014  QgsEditorWidgetSetup editorWidgetSetup( int index ) const;
2015 
2027  QSet<QVariant> uniqueValues( int fieldIndex, int limit = -1 ) const FINAL;
2028 
2042  QStringList uniqueStringsMatching( int index, const QString &substring, int limit = -1,
2043  QgsFeedback *feedback = nullptr ) const;
2044 
2053  QVariant minimumValue( int index ) const FINAL;
2054 
2063  QVariant maximumValue( int index ) const FINAL;
2064 
2077  QVariant aggregate( QgsAggregateCalculator::Aggregate aggregate,
2078  const QString &fieldOrExpression,
2079  const QgsAggregateCalculator::AggregateParameters &parameters = QgsAggregateCalculator::AggregateParameters(),
2080  QgsExpressionContext *context = nullptr,
2081  bool *ok = nullptr,
2082  QgsFeatureIds *fids = nullptr ) const;
2083 
2085  void setFeatureBlendMode( QPainter::CompositionMode blendMode );
2087  QPainter::CompositionMode featureBlendMode() const;
2088 
2096  void setOpacity( double opacity );
2097 
2105  double opacity() const;
2106 
2107  QString htmlMetadata() const FINAL;
2108 
2113  void setSimplifyMethod( const QgsVectorSimplifyMethod &simplifyMethod ) { mSimplifyMethod = simplifyMethod; }
2114 
2119  inline const QgsVectorSimplifyMethod &simplifyMethod() const { return mSimplifyMethod; }
2120 
2126  bool simplifyDrawingCanbeApplied( const QgsRenderContext &renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint ) const;
2127 
2135  QgsConditionalLayerStyles *conditionalStyles() const;
2136 
2141  QgsAttributeTableConfig attributeTableConfig() const;
2142 
2147  void setAttributeTableConfig( const QgsAttributeTableConfig &attributeTableConfig );
2148 
2156  QString mapTipTemplate() const;
2157 
2165  void setMapTipTemplate( const QString &mapTipTemplate );
2166 
2167  QgsExpressionContext createExpressionContext() const FINAL;
2168 
2169  QgsExpressionContextScope *createExpressionContextScope() const FINAL SIP_FACTORY;
2170 
2178  QgsEditFormConfig editFormConfig() const;
2179 
2186  void setEditFormConfig( const QgsEditFormConfig &editFormConfig );
2187 
2195  void setReadExtentFromXml( bool readExtentFromXml );
2196 
2204  bool readExtentFromXml() const;
2205 
2211  bool isEditCommandActive() const { return mEditCommandActive; }
2212 
2218  QgsGeometryOptions *geometryOptions() const;
2219 
2238  bool allowCommit() const SIP_SKIP;
2239 
2258  void setAllowCommit( bool allowCommit ) SIP_SKIP;
2259 
2265  QgsStoredExpressionManager *storedExpressionManager() { return mStoredExpressionManager; }
2266 
2267  public slots:
2268 
2276  void select( QgsFeatureId featureId );
2277 
2285  void select( const QgsFeatureIds &featureIds );
2286 
2294  void deselect( QgsFeatureId featureId );
2295 
2303  void deselect( const QgsFeatureIds &featureIds );
2304 
2311  void removeSelection();
2312 
2323  void reselect();
2324 
2331  virtual void updateExtents( bool force = false );
2332 
2347  bool startEditing();
2348 
2354  virtual void setTransformContext( const QgsCoordinateTransformContext &transformContext ) override;
2355 
2356  bool accept( QgsStyleEntityVisitorInterface *visitor ) const override;
2357 
2358  signals:
2359 
2367  void selectionChanged( const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect );
2368 
2370  void layerModified();
2371 
2377  void allowCommitChanged();
2378 
2380  void beforeModifiedCheck() const;
2381 
2383  void beforeEditingStarted();
2384 
2386  void editingStarted();
2387 
2389  void editingStopped();
2390 
2392  void beforeCommitChanges();
2393 
2395  void beforeRollBack();
2396 
2401  void afterRollBack();
2402 
2411  void attributeAdded( int idx );
2412 
2419  void beforeAddingExpressionField( const QString &fieldName );
2420 
2429  void attributeDeleted( int idx );
2430 
2437  void beforeRemovingExpressionField( int idx );
2438 
2444  void featureAdded( QgsFeatureId fid );
2445 
2454  void featureDeleted( QgsFeatureId fid );
2455 
2465  void featuresDeleted( const QgsFeatureIds &fids );
2466 
2471  void updatedFields();
2472 
2477  void subsetStringChanged();
2478 
2487  void attributeValueChanged( QgsFeatureId fid, int idx, const QVariant &value );
2488 
2496  void geometryChanged( QgsFeatureId fid, const QgsGeometry &geometry );
2497 
2499  void committedAttributesDeleted( const QString &layerId, const QgsAttributeList &deletedAttributes );
2501  void committedAttributesAdded( const QString &layerId, const QList<QgsField> &addedAttributes );
2503  void committedFeaturesAdded( const QString &layerId, const QgsFeatureList &addedFeatures );
2505  void committedFeaturesRemoved( const QString &layerId, const QgsFeatureIds &deletedFeatureIds );
2507  void committedAttributeValuesChanges( const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues );
2509  void committedGeometriesChanges( const QString &layerId, const QgsGeometryMap &changedGeometries );
2510 
2512  void labelingFontNotFound( QgsVectorLayer *layer, const QString &fontfamily );
2513 
2515  void featureBlendModeChanged( QPainter::CompositionMode blendMode );
2516 
2524  void opacityChanged( double opacity );
2525 
2531  void editCommandStarted( const QString &text );
2532 
2538  void editCommandEnded();
2539 
2545  void editCommandDestroyed();
2546 
2556  void readCustomSymbology( const QDomElement &element, QString &errorMessage );
2557 
2567  void writeCustomSymbology( QDomElement &element, QDomDocument &doc, QString &errorMessage ) const;
2568 
2574  void mapTipTemplateChanged();
2575 
2581  void displayExpressionChanged();
2582 
2586  void raiseError( const QString &msg );
2587 
2593  void editFormConfigChanged();
2594 
2601  void readOnlyChanged();
2602 
2608  void symbolFeatureCountMapChanged();
2609 
2610  protected:
2612  void setExtent( const QgsRectangle &rect ) FINAL;
2613 
2614  private slots:
2615  void invalidateSymbolCountedFlag();
2616  void onFeatureCounterCompleted();
2617  void onFeatureCounterTerminated();
2618  void onJoinedFieldsChanged();
2619  void onFeatureDeleted( QgsFeatureId fid );
2620  void onRelationsLoaded();
2621  void onSymbolsCounted();
2622  void onDirtyTransaction( const QString &sql, const QString &name );
2623  void emitDataChanged();
2624 
2625  private:
2626  void updateDefaultValues( QgsFeatureId fid, QgsFeature feature = QgsFeature() );
2627 
2631  bool isReadOnly() const FINAL;
2632 
2638  bool setDataProvider( QString const &provider, const QgsDataProvider::ProviderOptions &options );
2639 
2641  void readSldLabeling( const QDomNode &node );
2642 
2644  QgsAbstractVectorLayerLabeling *readLabelingFromCustomProperties();
2645 
2646 #ifdef SIP_RUN
2647  QgsVectorLayer( const QgsVectorLayer &rhs );
2648 #endif
2649  QVariant minimumOrMaximumValue( int index, bool minimum ) const;
2651 
2652  private: // Private attributes
2653  QgsConditionalLayerStyles *mConditionalStyles = nullptr;
2654 
2656  QgsVectorDataProvider *mDataProvider = nullptr;
2657 
2659  QString mDisplayExpression;
2660 
2661  QString mMapTipTemplate;
2662 
2664  QgsActionManager *mActions = nullptr;
2665 
2667  bool mReadOnly = false;
2668 
2674  QgsFeatureIds mSelectedFeatureIds;
2675 
2679  QgsFeatureIds mPreviousSelectedFeatureIds;
2680 
2682  QgsFields mFields;
2683 
2685  QgsStringMap mAttributeAliasMap;
2686 
2688  QMap<QString, QgsDefaultValue> mDefaultExpressionMap;
2689 
2691  QSet<int> mDefaultValueOnUpdateFields;
2692 
2694  QMap< QString, QgsFieldConstraints::Constraints > mFieldConstraints;
2695 
2697  QMap< QPair< QString, QgsFieldConstraints::Constraint >, QgsFieldConstraints::ConstraintStrength > mFieldConstraintStrength;
2698 
2700  QMap< QString, QPair< QString, QString > > mFieldConstraintExpressions;
2701 
2702  QMap< QString, QgsEditorWidgetSetup > mFieldWidgetSetups;
2703 
2705  QgsEditFormConfig mEditFormConfig;
2706 
2708  QSet<QString> mExcludeAttributesWMS;
2709 
2711  QSet<QString> mExcludeAttributesWFS;
2712 
2715 
2717  QgsFeatureRenderer *mRenderer = nullptr;
2718 
2720  QgsVectorSimplifyMethod mSimplifyMethod;
2721 
2723  QgsAbstractVectorLayerLabeling *mLabeling = nullptr;
2724 
2726  bool mLabelsEnabled = false;
2727 
2729  bool mLabelFontNotFoundNotified = false;
2730 
2732  QPainter::CompositionMode mFeatureBlendMode = QPainter::CompositionMode_SourceOver;
2733 
2735  double mLayerOpacity = 1.0;
2736 
2738  bool mVertexMarkerOnlyForSelection = false;
2739 
2740  QStringList mCommitErrors;
2741 
2743  QgsVectorLayerEditBuffer *mEditBuffer = nullptr;
2746 
2747  //stores information about joined layers
2748  QgsVectorLayerJoinBuffer *mJoinBuffer = nullptr;
2749 
2751  std::unique_ptr< QgsVectorLayerServerProperties > mServerProperties;
2752 
2754  QgsExpressionFieldBuffer *mExpressionFieldBuffer = nullptr;
2755 
2756  //diagram rendering object. 0 if diagram drawing is disabled
2757  QgsDiagramRenderer *mDiagramRenderer = nullptr;
2758 
2759  //stores infos about diagram placement (placement type, priority, position distance)
2760  QgsDiagramLayerSettings *mDiagramLayerSettings = nullptr;
2761 
2762  mutable bool mValidExtent = false;
2763  mutable bool mLazyExtent = true;
2764 
2766  std::unique_ptr<QgsAuxiliaryLayer> mAuxiliaryLayer;
2767 
2769  QString mAuxiliaryLayerKey;
2770 
2771  // Features in renderer classes counted
2772  bool mSymbolFeatureCounted = false;
2773 
2774  // Feature counts for each renderer legend key
2775  QHash<QString, long> mSymbolFeatureCountMap;
2776  QHash<QString, QgsFeatureIds> mSymbolFeatureIdMap;
2777 
2779  bool mEditCommandActive = false;
2780 
2781  bool mReadExtentFromXml;
2782  QgsRectangle mXmlExtent;
2783 
2784  QgsFeatureIds mDeletedFids;
2785 
2786  QgsAttributeTableConfig mAttributeTableConfig;
2787 
2788  mutable QMutex mFeatureSourceConstructorMutex;
2789 
2790  QgsVectorLayerFeatureCounter *mFeatureCounter = nullptr;
2791 
2792  std::unique_ptr<QgsGeometryOptions> mGeometryOptions;
2793 
2794  bool mAllowCommit = true;
2795 
2797  QgsStoredExpressionManager *mStoredExpressionManager = nullptr;
2798 
2800 
2802  bool mDataChangedFired = false;
2803 };
2804 
2805 
2806 
2807 // clazy:excludeall=qstring-allocations
2808 
2809 #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:122
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:612
OperationResult
Success or failure of a geometry operation.
Definition: qgsgeometry.h:134
Manages joined fields for a vector layer.
Base class for feedback objects to be used for cancellation of something running in a worker thread...
Definition: qgsfeedback.h:44
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.
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)...
Encapsulates a QGIS project, including sets of map layers and their styles, layouts, annotations, canvases, etc.
Definition: qgsproject.h:89
Storage and management of actions associated with a layer.
QgsAttributeList attributeList() const
Returns list of attribute indexes.
Manages QGIS Server properties for a vector layer.
QgsFeatureRenderer * renderer()
Returns renderer.
Abstract base class for curved geometry type.
Definition: qgscurve.h:35
#define SIP_FACTORY
Definition: qgis_sip.h:76
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h: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...
QgsVectorLayerServerProperties * serverProperties()
Returns QGIS Server Properties of the vector layer.
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