QGIS API Documentation  3.6.0-Noosa (5873452)
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, bool readExtentFromXml = false )
405  : loadDefaultStyle( loadDefaultStyle )
406  , readExtentFromXml( readExtentFromXml )
407  {}
408 
410  bool loadDefaultStyle = true;
411 
416  bool readExtentFromXml = false;
417 
418  };
419 
433  explicit QgsVectorLayer( const QString &path = QString(), const QString &baseName = QString(),
434  const QString &providerLib = "ogr", const QgsVectorLayer::LayerOptions &options = QgsVectorLayer::LayerOptions() );
435 
436 
437  ~QgsVectorLayer() override;
438 
440  QgsVectorLayer( const QgsVectorLayer &rhs ) = delete;
442  QgsVectorLayer &operator=( QgsVectorLayer const &rhs ) = delete;
443 
452  QgsVectorLayer *clone() const override SIP_FACTORY;
453 
458  QString storageType() const;
459 
463  QString capabilitiesString() const;
464 
468  QString dataComment() const;
469 
477  QString displayField() const;
478 
486  void setDisplayExpression( const QString &displayExpression );
487 
494  QString displayExpression() const;
495 
496  QgsVectorDataProvider *dataProvider() FINAL;
497  const QgsVectorDataProvider *dataProvider() const FINAL SIP_SKIP;
498 
500  void setProviderEncoding( const QString &encoding );
501 
503  void setCoordinateSystem();
504 
509  bool addJoin( const QgsVectorLayerJoinInfo &joinInfo );
510 
514  bool removeJoin( const QString &joinLayerId );
515 
520  QgsVectorLayerJoinBuffer *joinBuffer() { return mJoinBuffer; }
521  const QList<QgsVectorLayerJoinInfo> vectorJoins() const;
522 
531  bool setDependencies( const QSet<QgsMapLayerDependency> &layers ) FINAL;
532 
540  QSet<QgsMapLayerDependency> dependencies() const FINAL;
541 
552  int addExpressionField( const QString &exp, const QgsField &fld );
553 
561  void removeExpressionField( int index );
562 
572  QString expressionField( int index ) const;
573 
583  void updateExpressionField( int index, const QString &exp );
584 
591  QgsActionManager *actions() { return mActions; }
592 
598  const QgsActionManager *actions() const SIP_SKIP { return mActions; }
599 
605  int selectedFeatureCount() const;
606 
616  void selectByRect( QgsRectangle &rect, SelectBehavior behavior = SetSelection );
617 
627  void selectByExpression( const QString &expression, SelectBehavior behavior = SetSelection );
628 
639  void selectByIds( const QgsFeatureIds &ids, SelectBehavior behavior = SetSelection );
640 
652  void modifySelection( const QgsFeatureIds &selectIds, const QgsFeatureIds &deselectIds );
653 
655  void invertSelection();
656 
658  void selectAll();
659 
667  void invertSelectionInRectangle( QgsRectangle &rect );
668 
681  QgsFeatureList selectedFeatures() const;
682 
698  QgsFeatureIterator getSelectedFeatures( QgsFeatureRequest request = QgsFeatureRequest() ) const;
699 
707  const QgsFeatureIds &selectedFeatureIds() const;
708 
710  QgsRectangle boundingBoxOfSelected() const;
711 
719  bool labelsEnabled() const;
720 
730  void setLabelsEnabled( bool enabled );
731 
737  bool diagramsEnabled() const;
738 
740  void setDiagramRenderer( QgsDiagramRenderer *r SIP_TRANSFER );
741  const QgsDiagramRenderer *diagramRenderer() const { return mDiagramRenderer; }
742 
743  void setDiagramLayerSettings( const QgsDiagramLayerSettings &s );
744  const QgsDiagramLayerSettings *diagramLayerSettings() const { return mDiagramLayerSettings; }
745 
747  QgsFeatureRenderer *renderer() { return mRenderer; }
748 
753  const QgsFeatureRenderer *renderer() const SIP_SKIP { return mRenderer; }
754 
759  void setRenderer( QgsFeatureRenderer *r SIP_TRANSFER );
760 
762  QgsWkbTypes::GeometryType geometryType() const;
763 
765  QgsWkbTypes::Type wkbType() const FINAL;
766 
767  QgsCoordinateReferenceSystem sourceCrs() const FINAL;
768  QString sourceName() const FINAL;
769 
774  bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context ) FINAL;
775 
780  bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const FINAL;
781 
782  QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const FINAL;
783  QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const FINAL;
784 
789  void resolveReferences( QgsProject *project ) FINAL;
790 
799  virtual void saveStyleToDatabase( const QString &name, const QString &description,
800  bool useAsDefault, const QString &uiFileContent,
801  QString &msgError SIP_OUT );
802 
812  virtual int listStylesInDatabase( QStringList &ids SIP_OUT, QStringList &names SIP_OUT,
813  QStringList &descriptions SIP_OUT, QString &msgError SIP_OUT );
814 
818  virtual QString getStyleFromDatabase( const QString &styleId, QString &msgError SIP_OUT );
819 
827  virtual bool deleteStyleFromDatabase( const QString &styleId, QString &msgError SIP_OUT );
828 
836  virtual QString loadNamedStyle( const QString &theURI, bool &resultFlag SIP_OUT, bool loadFromLocalDb,
837  QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories );
838 
843  QString loadNamedStyle( const QString &theURI, bool &resultFlag SIP_OUT,
844  QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) FINAL;
845 
859  bool loadAuxiliaryLayer( const QgsAuxiliaryStorage &storage, const QString &key = QString() );
860 
870  void setAuxiliaryLayer( QgsAuxiliaryLayer *layer SIP_TRANSFER = nullptr );
871 
877  QgsAuxiliaryLayer *auxiliaryLayer();
878 
884  const QgsAuxiliaryLayer *auxiliaryLayer() const SIP_SKIP;
885 
894  bool readSymbology( const QDomNode &layerNode, QString &errorMessage,
895  QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) FINAL;
896 
905  bool readStyle( const QDomNode &node, QString &errorMessage,
906  QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) FINAL;
907 
917  bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
918  const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const FINAL;
919 
929  bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
930  const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const FINAL;
931 
940  bool writeSld( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsStringMap &props = QgsStringMap() ) const;
941 
942  bool readSld( const QDomNode &node, QString &errorMessage ) FINAL;
943 
949  long featureCount( const QString &legendKey ) const;
950 
961  FeatureAvailability hasFeatures() const FINAL;
962 
974  Q_DECL_DEPRECATED void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, bool loadDefaultStyleFlag = false ) SIP_DEPRECATED;
975 
988  void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, bool loadDefaultStyleFlag = false ) override;
989 
990  QString loadDefaultStyle( bool &resultFlag SIP_OUT ) FINAL;
991 
1004  QgsVectorLayerFeatureCounter *countSymbolFeatures();
1005 
1013  virtual bool setSubsetString( const QString &subset );
1014 
1019  virtual QString subsetString() const;
1020 
1026  QgsFeatureIterator getFeatures( const QgsFeatureRequest &request = QgsFeatureRequest() ) const FINAL;
1027 
1031  inline QgsFeatureIterator getFeatures( const QString &expression )
1032  {
1033  return getFeatures( QgsFeatureRequest( expression ) );
1034  }
1035 
1040  inline QgsFeature getFeature( QgsFeatureId fid ) const
1041  {
1042  QgsFeature feature;
1043  getFeatures( QgsFeatureRequest( fid ) ).nextFeature( feature );
1044  return feature;
1045  }
1046 
1051  QgsGeometry getGeometry( QgsFeatureId fid ) const;
1052 
1057  {
1058  return getFeatures( QgsFeatureRequest( fids ) );
1059  }
1060 
1064  inline QgsFeatureIterator getFeatures( const QgsRectangle &rectangle )
1065  {
1066  return getFeatures( QgsFeatureRequest( rectangle ) );
1067  }
1068 
1069  bool addFeature( QgsFeature &feature, QgsFeatureSink::Flags flags = nullptr ) FINAL;
1070 
1096  bool updateFeature( QgsFeature &feature, bool skipDefaultValues = false );
1097 
1108  bool insertVertex( double x, double y, QgsFeatureId atFeatureId, int beforeVertex );
1109 
1120  bool insertVertex( const QgsPoint &point, QgsFeatureId atFeatureId, int beforeVertex );
1121 
1132  bool moveVertex( double x, double y, QgsFeatureId atFeatureId, int atVertex );
1133 
1144  bool moveVertex( const QgsPoint &p, QgsFeatureId atFeatureId, int atVertex ) SIP_PYNAME( moveVertexV2 );
1145 
1156  EditResult deleteVertex( QgsFeatureId featureId, int vertex );
1157 
1162  bool deleteSelectedFeatures( int *deletedCount = nullptr );
1163 
1182  QgsGeometry::OperationResult addRing( const QVector<QgsPointXY> &ring, QgsFeatureId *featureId = nullptr );
1183 
1202  QgsGeometry::OperationResult addRing( QgsCurve *ring SIP_TRANSFER, QgsFeatureId *featureId = nullptr ) SIP_PYNAME( addCurvedRing );
1203 
1221  QgsGeometry::OperationResult addPart( const QList<QgsPointXY> &ring );
1222 
1240  QgsGeometry::OperationResult addPart( const QgsPointSequence &ring ) SIP_PYNAME( addPartV2 );
1241 
1249  QgsGeometry::OperationResult addPart( QgsCurve *ring SIP_TRANSFER ) SIP_PYNAME( addCurvedPart );
1250 
1262  int translateFeature( QgsFeatureId featureId, double dx, double dy );
1263 
1281  QgsGeometry::OperationResult splitParts( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false );
1282 
1300  QgsGeometry::OperationResult splitFeatures( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false );
1301 
1312  int addTopologicalPoints( const QgsGeometry &geom );
1313 
1326  int addTopologicalPoints( const QgsPointXY &p );
1327 
1334  const QgsAbstractVectorLayerLabeling *labeling() const SIP_SKIP { return mLabeling; }
1335 
1342  QgsAbstractVectorLayerLabeling *labeling() { return mLabeling; }
1343 
1348  void setLabeling( QgsAbstractVectorLayerLabeling *labeling SIP_TRANSFER );
1349 
1351  bool isEditable() const FINAL;
1352 
1354  bool isSpatial() const FINAL;
1355 
1357  virtual bool isModified() const;
1358 
1365  bool isAuxiliaryField( int index, int &srcIndex ) const;
1366 
1368  void reload() FINAL;
1369 
1374  QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) FINAL SIP_FACTORY;
1375 
1376  QgsRectangle extent() const FINAL;
1377  QgsRectangle sourceExtent() const FINAL;
1378 
1385  QgsFields fields() const FINAL;
1386 
1390  inline QgsAttributeList attributeList() const { return mFields.allAttributesList(); }
1391 
1395  QgsAttributeList primaryKeyAttributes() const;
1396 
1402  long featureCount() const FINAL;
1403 
1408  bool setReadOnly( bool readonly = true );
1409 
1430  bool changeGeometry( QgsFeatureId fid, QgsGeometry &geometry, bool skipDefaultValue = false );
1431 
1462  bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant(), bool skipDefaultValues = false );
1463 
1499  bool changeAttributeValues( QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues = QgsAttributeMap(), bool skipDefaultValues = false );
1500 
1510  bool addAttribute( const QgsField &field );
1511 
1517  void setFieldAlias( int index, const QString &aliasString );
1518 
1524  void removeFieldAlias( int index );
1525 
1536  bool renameAttribute( int index, const QString &newName );
1537 
1544  QString attributeAlias( int index ) const;
1545 
1547  QString attributeDisplayName( int index ) const;
1548 
1550  QgsStringMap attributeAliases() const;
1551 
1555  QSet<QString> excludeAttributesWms() const { return mExcludeAttributesWMS; }
1556 
1560  void setExcludeAttributesWms( const QSet<QString> &att ) { mExcludeAttributesWMS = att; }
1561 
1565  QSet<QString> excludeAttributesWfs() const { return mExcludeAttributesWFS; }
1566 
1570  void setExcludeAttributesWfs( const QSet<QString> &att ) { mExcludeAttributesWFS = att; }
1571 
1580  virtual bool deleteAttribute( int attr );
1581 
1589  bool deleteAttributes( const QList<int> &attrs );
1590 
1591  bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = nullptr ) FINAL;
1592 
1601  bool deleteFeature( QgsFeatureId fid );
1602 
1615  bool deleteFeatures( const QgsFeatureIds &fids );
1616 
1637  bool commitChanges();
1638 
1644  QStringList commitErrors() const;
1645 
1655  bool rollBack( bool deleteBuffer = true );
1656 
1663  QList<QgsRelation> referencingRelations( int idx ) const;
1664 
1666  QgsVectorLayerEditBuffer *editBuffer() { return mEditBuffer; }
1667 
1672  const QgsVectorLayerEditBuffer *editBuffer() const SIP_SKIP { return mEditBuffer; }
1673 
1678  void beginEditCommand( const QString &text );
1679 
1681  void endEditCommand();
1682 
1684  void destroyEditCommand();
1685 
1688  {
1691  NoMarker
1692  };
1693 
1698  Q_DECL_DEPRECATED static void drawVertexMarker( double x, double y, QPainter &p, QgsVectorLayer::VertexMarkerType type, int vertexSize );
1699 
1708  void updateFields();
1709 
1724  QVariant defaultValue( int index, const QgsFeature &feature = QgsFeature(),
1725  QgsExpressionContext *context = nullptr ) const;
1726 
1738  void setDefaultValueDefinition( int index, const QgsDefaultValue &definition );
1739 
1750  QgsDefaultValue defaultValueDefinition( int index ) const;
1751 
1759  QgsFieldConstraints::Constraints fieldConstraints( int fieldIndex ) const;
1760 
1766  QMap< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrength> fieldConstraintsAndStrength( int fieldIndex ) const;
1767 
1777 
1785  void removeFieldConstraint( int index, QgsFieldConstraints::Constraint constraint );
1786 
1794  QString constraintExpression( int index ) const;
1795 
1803  QString constraintDescription( int index ) const;
1804 
1813  void setConstraintExpression( int index, const QString &expression, const QString &description = QString() );
1814 
1818  void setEditorWidgetSetup( int index, const QgsEditorWidgetSetup &setup );
1819 
1826  QgsEditorWidgetSetup editorWidgetSetup( int index ) const;
1827 
1839  QSet<QVariant> uniqueValues( int fieldIndex, int limit = -1 ) const FINAL;
1840 
1854  QStringList uniqueStringsMatching( int index, const QString &substring, int limit = -1,
1855  QgsFeedback *feedback = nullptr ) const;
1856 
1865  QVariant minimumValue( int index ) const FINAL;
1866 
1875  QVariant maximumValue( int index ) const FINAL;
1876 
1887  QVariant aggregate( QgsAggregateCalculator::Aggregate aggregate,
1888  const QString &fieldOrExpression,
1889  const QgsAggregateCalculator::AggregateParameters &parameters = QgsAggregateCalculator::AggregateParameters(),
1890  QgsExpressionContext *context = nullptr,
1891  bool *ok = nullptr ) const;
1892 
1894  void setFeatureBlendMode( QPainter::CompositionMode blendMode );
1896  QPainter::CompositionMode featureBlendMode() const;
1897 
1905  void setOpacity( double opacity );
1906 
1914  double opacity() const;
1915 
1916  QString htmlMetadata() const FINAL;
1917 
1922  void setSimplifyMethod( const QgsVectorSimplifyMethod &simplifyMethod ) { mSimplifyMethod = simplifyMethod; }
1923 
1928  inline const QgsVectorSimplifyMethod &simplifyMethod() const { return mSimplifyMethod; }
1929 
1935  bool simplifyDrawingCanbeApplied( const QgsRenderContext &renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint ) const;
1936 
1944  QgsConditionalLayerStyles *conditionalStyles() const;
1945 
1950  QgsAttributeTableConfig attributeTableConfig() const;
1951 
1956  void setAttributeTableConfig( const QgsAttributeTableConfig &attributeTableConfig );
1957 
1965  QString mapTipTemplate() const;
1966 
1974  void setMapTipTemplate( const QString &mapTipTemplate );
1975 
1976  QgsExpressionContext createExpressionContext() const FINAL;
1977 
1978  QgsExpressionContextScope *createExpressionContextScope() const FINAL SIP_FACTORY;
1979 
1987  QgsEditFormConfig editFormConfig() const;
1988 
1995  void setEditFormConfig( const QgsEditFormConfig &editFormConfig );
1996 
2004  void setReadExtentFromXml( bool readExtentFromXml );
2005 
2013  bool readExtentFromXml() const;
2014 
2020  bool isEditCommandActive() const { return mEditCommandActive; }
2021 
2027  QgsGeometryOptions *geometryOptions() const;
2028 
2047  bool allowCommit() const SIP_SKIP;
2048 
2067  void setAllowCommit( bool allowCommit ) SIP_SKIP;
2068 
2069  public slots:
2070 
2078  void select( QgsFeatureId featureId );
2079 
2087  void select( const QgsFeatureIds &featureIds );
2088 
2096  void deselect( QgsFeatureId featureId );
2097 
2105  void deselect( const QgsFeatureIds &featureIds );
2106 
2112  void removeSelection();
2113 
2120  virtual void updateExtents( bool force = false );
2121 
2136  bool startEditing();
2137 
2138  signals:
2139 
2147  void selectionChanged( const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect );
2148 
2150  void layerModified();
2151 
2157  void allowCommitChanged();
2158 
2160  void beforeModifiedCheck() const;
2161 
2163  void beforeEditingStarted();
2164 
2166  void editingStarted();
2167 
2169  void editingStopped();
2170 
2172  void beforeCommitChanges();
2173 
2175  void beforeRollBack();
2176 
2181  void afterRollBack();
2182 
2191  void attributeAdded( int idx );
2192 
2199  void beforeAddingExpressionField( const QString &fieldName );
2200 
2209  void attributeDeleted( int idx );
2210 
2217  void beforeRemovingExpressionField( int idx );
2218 
2224  void featureAdded( QgsFeatureId fid );
2225 
2234  void featureDeleted( QgsFeatureId fid );
2235 
2245  void featuresDeleted( const QgsFeatureIds &fids );
2246 
2251  void updatedFields();
2252 
2257  void subsetStringChanged();
2258 
2267  void attributeValueChanged( QgsFeatureId fid, int idx, const QVariant &value );
2268 
2276  void geometryChanged( QgsFeatureId fid, const QgsGeometry &geometry );
2277 
2279  void committedAttributesDeleted( const QString &layerId, const QgsAttributeList &deletedAttributes );
2281  void committedAttributesAdded( const QString &layerId, const QList<QgsField> &addedAttributes );
2283  void committedFeaturesAdded( const QString &layerId, const QgsFeatureList &addedFeatures );
2285  void committedFeaturesRemoved( const QString &layerId, const QgsFeatureIds &deletedFeatureIds );
2287  void committedAttributeValuesChanges( const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues );
2289  void committedGeometriesChanges( const QString &layerId, const QgsGeometryMap &changedGeometries );
2290 
2292  void labelingFontNotFound( QgsVectorLayer *layer, const QString &fontfamily );
2293 
2295  void featureBlendModeChanged( QPainter::CompositionMode blendMode );
2296 
2304  void opacityChanged( double opacity );
2305 
2311  void editCommandStarted( const QString &text );
2312 
2318  void editCommandEnded();
2319 
2325  void editCommandDestroyed();
2326 
2336  void readCustomSymbology( const QDomElement &element, QString &errorMessage );
2337 
2347  void writeCustomSymbology( QDomElement &element, QDomDocument &doc, QString &errorMessage ) const;
2348 
2354  void mapTipTemplateChanged();
2355 
2361  void displayExpressionChanged();
2362 
2366  void raiseError( const QString &msg );
2367 
2373  void editFormConfigChanged();
2374 
2381  void readOnlyChanged();
2382 
2388  void symbolFeatureCountMapChanged();
2389 
2390  protected:
2392  void setExtent( const QgsRectangle &rect ) FINAL;
2393 
2394  private slots:
2395  void invalidateSymbolCountedFlag();
2396  void onFeatureCounterCompleted();
2397  void onFeatureCounterTerminated();
2398  void onJoinedFieldsChanged();
2399  void onFeatureDeleted( QgsFeatureId fid );
2400  void onRelationsLoaded();
2401  void onSymbolsCounted();
2402  void onDirtyTransaction( const QString &sql, const QString &name );
2403 
2404  private:
2405  void updateDefaultValues( QgsFeatureId fid, QgsFeature feature = QgsFeature() );
2406 
2410  bool isReadOnly() const FINAL;
2411 
2417  bool setDataProvider( QString const &provider, const QgsDataProvider::ProviderOptions &options );
2418 
2420  void readSldLabeling( const QDomNode &node );
2421 
2423  QgsAbstractVectorLayerLabeling *readLabelingFromCustomProperties();
2424 
2425 #ifdef SIP_RUN
2426  QgsVectorLayer( const QgsVectorLayer &rhs );
2427 #endif
2428 
2429  private: // Private attributes
2430  QgsConditionalLayerStyles *mConditionalStyles = nullptr;
2431 
2433  QgsVectorDataProvider *mDataProvider = nullptr;
2434 
2436  QString mDisplayExpression;
2437 
2438  QString mMapTipTemplate;
2439 
2441  QgsActionManager *mActions = nullptr;
2442 
2444  bool mReadOnly = false;
2445 
2451  QgsFeatureIds mSelectedFeatureIds;
2452 
2454  QgsFields mFields;
2455 
2457  QgsStringMap mAttributeAliasMap;
2458 
2460  QMap<QString, QgsDefaultValue> mDefaultExpressionMap;
2461 
2463  QSet<int> mDefaultValueOnUpdateFields;
2464 
2466  QMap< QString, QgsFieldConstraints::Constraints > mFieldConstraints;
2467 
2469  QMap< QPair< QString, QgsFieldConstraints::Constraint >, QgsFieldConstraints::ConstraintStrength > mFieldConstraintStrength;
2470 
2472  QMap< QString, QPair< QString, QString > > mFieldConstraintExpressions;
2473 
2474  QMap< QString, QgsEditorWidgetSetup > mFieldWidgetSetups;
2475 
2477  QgsEditFormConfig mEditFormConfig;
2478 
2480  QSet<QString> mExcludeAttributesWMS;
2481 
2483  QSet<QString> mExcludeAttributesWFS;
2484 
2487 
2489  QgsFeatureRenderer *mRenderer = nullptr;
2490 
2492  QgsVectorSimplifyMethod mSimplifyMethod;
2493 
2495  QgsAbstractVectorLayerLabeling *mLabeling = nullptr;
2496 
2498  bool mLabelsEnabled = false;
2499 
2501  bool mLabelFontNotFoundNotified = false;
2502 
2504  QPainter::CompositionMode mFeatureBlendMode = QPainter::CompositionMode_SourceOver;
2505 
2507  double mLayerOpacity = 1.0;
2508 
2510  bool mVertexMarkerOnlyForSelection = false;
2511 
2512  QStringList mCommitErrors;
2513 
2515  QgsVectorLayerEditBuffer *mEditBuffer = nullptr;
2518 
2519  //stores information about joined layers
2520  QgsVectorLayerJoinBuffer *mJoinBuffer = nullptr;
2521 
2523  QgsExpressionFieldBuffer *mExpressionFieldBuffer = nullptr;
2524 
2525  //diagram rendering object. 0 if diagram drawing is disabled
2526  QgsDiagramRenderer *mDiagramRenderer = nullptr;
2527 
2528  //stores infos about diagram placement (placement type, priority, position distance)
2529  QgsDiagramLayerSettings *mDiagramLayerSettings = nullptr;
2530 
2531  mutable bool mValidExtent = false;
2532  mutable bool mLazyExtent = true;
2533 
2535  std::unique_ptr<QgsAuxiliaryLayer> mAuxiliaryLayer;
2536 
2538  QString mAuxiliaryLayerKey;
2539 
2540  // Features in renderer classes counted
2541  bool mSymbolFeatureCounted = false;
2542 
2543  // Feature counts for each renderer legend key
2544  QHash<QString, long> mSymbolFeatureCountMap;
2545 
2547  bool mEditCommandActive = false;
2548 
2549  bool mReadExtentFromXml;
2550  QgsRectangle mXmlExtent;
2551 
2552  QgsFeatureIds mDeletedFids;
2553 
2554  QgsAttributeTableConfig mAttributeTableConfig;
2555 
2556  mutable QMutex mFeatureSourceConstructorMutex;
2557 
2558  QgsVectorLayerFeatureCounter *mFeatureCounter = nullptr;
2559 
2560  std::unique_ptr<QgsGeometryOptions> mGeometryOptions;
2561 
2562  bool mAllowCommit = true;
2563 
2565 };
2566 
2567 
2568 
2569 // clazy:excludeall=qstring-allocations
2570 
2571 #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:64
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
Query 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:106
bool isEditCommandActive() const
Test 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:118
Manages joined fields for a vector layer.
Base class for feedback objects to be used for cancelation 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...
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)
Query 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.
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)
Query 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:138
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
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)
Query 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