QGIS API Documentation  3.4.3-Madeira (2f64a3c)
qgsvectorlayer.h
Go to the documentation of this file.
1 
2 /***************************************************************************
3  -------------------
4  begin : Oct 29, 2003
5  copyright : (C) 2003 by Gary E.Sherman
6  email : sherman at mrcc.com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef QGSVECTORLAYER_H
19 #define QGSVECTORLAYER_H
20 
21 
22 #include "qgis_core.h"
23 #include <QMap>
24 #include <QSet>
25 #include <QList>
26 #include <QStringList>
27 #include <QFont>
28 #include <QMutex>
29 
30 #include "qgis.h"
31 #include "qgsmaplayer.h"
32 #include "qgsfeature.h"
33 #include "qgsfeaturerequest.h"
34 #include "qgsfeaturesource.h"
35 #include "qgsfields.h"
36 #include "qgsvectordataprovider.h"
38 #include "qgseditformconfig.h"
40 #include "qgsaggregatecalculator.h"
41 #include "qgsfeatureiterator.h"
44 
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 
706  const QgsFeatureIds &selectedFeatureIds() const;
707 
709  QgsRectangle boundingBoxOfSelected() const;
710 
718  bool labelsEnabled() const;
719 
729  void setLabelsEnabled( bool enabled );
730 
736  bool diagramsEnabled() const;
737 
739  void setDiagramRenderer( QgsDiagramRenderer *r SIP_TRANSFER );
740  const QgsDiagramRenderer *diagramRenderer() const { return mDiagramRenderer; }
741 
742  void setDiagramLayerSettings( const QgsDiagramLayerSettings &s );
743  const QgsDiagramLayerSettings *diagramLayerSettings() const { return mDiagramLayerSettings; }
744 
746  QgsFeatureRenderer *renderer() { return mRenderer; }
747 
752  const QgsFeatureRenderer *renderer() const SIP_SKIP { return mRenderer; }
753 
758  void setRenderer( QgsFeatureRenderer *r SIP_TRANSFER );
759 
761  QgsWkbTypes::GeometryType geometryType() const;
762 
764  QgsWkbTypes::Type wkbType() const FINAL;
765 
767  QString providerType() const;
768 
769  QgsCoordinateReferenceSystem sourceCrs() const FINAL;
770  QString sourceName() const FINAL;
771 
776  bool readXml( const QDomNode &layer_node, QgsReadWriteContext &context ) FINAL;
777 
782  bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const FINAL;
783 
784  QString encodedSource( const QString &source, const QgsReadWriteContext &context ) const FINAL;
785  QString decodedSource( const QString &source, const QString &provider, const QgsReadWriteContext &context ) const FINAL;
786 
791  void resolveReferences( QgsProject *project ) FINAL;
792 
801  virtual void saveStyleToDatabase( const QString &name, const QString &description,
802  bool useAsDefault, const QString &uiFileContent,
803  QString &msgError SIP_OUT );
804 
814  virtual int listStylesInDatabase( QStringList &ids SIP_OUT, QStringList &names SIP_OUT,
815  QStringList &descriptions SIP_OUT, QString &msgError SIP_OUT );
816 
820  virtual QString getStyleFromDatabase( const QString &styleId, QString &msgError SIP_OUT );
821 
829  virtual bool deleteStyleFromDatabase( const QString &styleId, QString &msgError SIP_OUT );
830 
838  virtual QString loadNamedStyle( const QString &theURI, bool &resultFlag SIP_OUT, bool loadFromLocalDb,
839  QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories );
840 
845  QString loadNamedStyle( const QString &theURI, bool &resultFlag SIP_OUT,
846  QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) FINAL;
847 
861  bool loadAuxiliaryLayer( const QgsAuxiliaryStorage &storage, const QString &key = QString() );
862 
872  void setAuxiliaryLayer( QgsAuxiliaryLayer *layer SIP_TRANSFER = nullptr );
873 
879  QgsAuxiliaryLayer *auxiliaryLayer();
880 
886  const QgsAuxiliaryLayer *auxiliaryLayer() const SIP_SKIP;
887 
896  bool readSymbology( const QDomNode &layerNode, QString &errorMessage,
897  QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) FINAL;
898 
907  bool readStyle( const QDomNode &node, QString &errorMessage,
908  QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) FINAL;
909 
919  bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage,
920  const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const FINAL;
921 
931  bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage,
932  const QgsReadWriteContext &context, QgsMapLayer::StyleCategories categories = QgsMapLayer::AllStyleCategories ) const FINAL;
933 
942  bool writeSld( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsStringMap &props = QgsStringMap() ) const;
943 
944  bool readSld( const QDomNode &node, QString &errorMessage ) FINAL;
945 
951  long featureCount( const QString &legendKey ) const;
952 
963  FeatureAvailability hasFeatures() const FINAL;
964 
976  Q_DECL_DEPRECATED void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, bool loadDefaultStyleFlag = false ) SIP_DEPRECATED;
977 
990  void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, bool loadDefaultStyleFlag = false );
991 
992  QString loadDefaultStyle( bool &resultFlag SIP_OUT ) FINAL;
993 
1006  QgsVectorLayerFeatureCounter *countSymbolFeatures();
1007 
1015  virtual bool setSubsetString( const QString &subset );
1016 
1021  virtual QString subsetString() const;
1022 
1028  QgsFeatureIterator getFeatures( const QgsFeatureRequest &request = QgsFeatureRequest() ) const FINAL;
1029 
1033  inline QgsFeatureIterator getFeatures( const QString &expression )
1034  {
1035  return getFeatures( QgsFeatureRequest( expression ) );
1036  }
1037 
1042  inline QgsFeature getFeature( QgsFeatureId fid ) const
1043  {
1044  QgsFeature feature;
1045  getFeatures( QgsFeatureRequest( fid ) ).nextFeature( feature );
1046  return feature;
1047  }
1048 
1053  QgsGeometry getGeometry( QgsFeatureId fid ) const;
1054 
1059  {
1060  return getFeatures( QgsFeatureRequest( fids ) );
1061  }
1062 
1066  inline QgsFeatureIterator getFeatures( const QgsRectangle &rectangle )
1067  {
1068  return getFeatures( QgsFeatureRequest( rectangle ) );
1069  }
1070 
1071  bool addFeature( QgsFeature &feature, QgsFeatureSink::Flags flags = nullptr ) FINAL;
1072 
1098  bool updateFeature( QgsFeature &feature, bool skipDefaultValues = false );
1099 
1110  bool insertVertex( double x, double y, QgsFeatureId atFeatureId, int beforeVertex );
1111 
1122  bool insertVertex( const QgsPoint &point, QgsFeatureId atFeatureId, int beforeVertex );
1123 
1134  bool moveVertex( double x, double y, QgsFeatureId atFeatureId, int atVertex );
1135 
1146  bool moveVertex( const QgsPoint &p, QgsFeatureId atFeatureId, int atVertex ) SIP_PYNAME( moveVertexV2 );
1147 
1158  EditResult deleteVertex( QgsFeatureId featureId, int vertex );
1159 
1164  bool deleteSelectedFeatures( int *deletedCount = nullptr );
1165 
1184  QgsGeometry::OperationResult addRing( const QVector<QgsPointXY> &ring, QgsFeatureId *featureId = nullptr );
1185 
1204  QgsGeometry::OperationResult addRing( QgsCurve *ring SIP_TRANSFER, QgsFeatureId *featureId = nullptr ) SIP_PYNAME( addCurvedRing );
1205 
1223  QgsGeometry::OperationResult addPart( const QList<QgsPointXY> &ring );
1224 
1242  QgsGeometry::OperationResult addPart( const QgsPointSequence &ring ) SIP_PYNAME( addPartV2 );
1243 
1251  QgsGeometry::OperationResult addPart( QgsCurve *ring SIP_TRANSFER ) SIP_PYNAME( addCurvedPart );
1252 
1264  int translateFeature( QgsFeatureId featureId, double dx, double dy );
1265 
1283  QgsGeometry::OperationResult splitParts( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false );
1284 
1302  QgsGeometry::OperationResult splitFeatures( const QVector<QgsPointXY> &splitLine, bool topologicalEditing = false );
1303 
1314  int addTopologicalPoints( const QgsGeometry &geom );
1315 
1328  int addTopologicalPoints( const QgsPointXY &p );
1329 
1336  const QgsAbstractVectorLayerLabeling *labeling() const SIP_SKIP { return mLabeling; }
1337 
1344  QgsAbstractVectorLayerLabeling *labeling() { return mLabeling; }
1345 
1350  void setLabeling( QgsAbstractVectorLayerLabeling *labeling SIP_TRANSFER );
1351 
1353  bool isEditable() const FINAL;
1354 
1356  bool isSpatial() const FINAL;
1357 
1359  virtual bool isModified() const;
1360 
1367  bool isAuxiliaryField( int index, int &srcIndex ) const;
1368 
1370  void reload() FINAL;
1371 
1376  QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) FINAL SIP_FACTORY;
1377 
1378  QgsRectangle extent() const FINAL;
1379  QgsRectangle sourceExtent() const FINAL;
1380 
1387  QgsFields fields() const FINAL;
1388 
1392  inline QgsAttributeList attributeList() const { return mFields.allAttributesList(); }
1393 
1397  QgsAttributeList primaryKeyAttributes() const;
1398 
1403  long featureCount() const FINAL;
1404 
1409  bool setReadOnly( bool readonly = true );
1410 
1431  bool changeGeometry( QgsFeatureId fid, QgsGeometry &geometry, bool skipDefaultValue = false );
1432 
1463  bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant(), bool skipDefaultValues = false );
1464 
1500  bool changeAttributeValues( QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues = QgsAttributeMap(), bool skipDefaultValues = false );
1501 
1511  bool addAttribute( const QgsField &field );
1512 
1518  void setFieldAlias( int index, const QString &aliasString );
1519 
1525  void removeFieldAlias( int index );
1526 
1537  bool renameAttribute( int index, const QString &newName );
1538 
1545  QString attributeAlias( int index ) const;
1546 
1548  QString attributeDisplayName( int index ) const;
1549 
1551  QgsStringMap attributeAliases() const;
1552 
1556  QSet<QString> excludeAttributesWms() const { return mExcludeAttributesWMS; }
1557 
1561  void setExcludeAttributesWms( const QSet<QString> &att ) { mExcludeAttributesWMS = att; }
1562 
1566  QSet<QString> excludeAttributesWfs() const { return mExcludeAttributesWFS; }
1567 
1571  void setExcludeAttributesWfs( const QSet<QString> &att ) { mExcludeAttributesWFS = att; }
1572 
1581  virtual bool deleteAttribute( int attr );
1582 
1590  bool deleteAttributes( const QList<int> &attrs );
1591 
1592  bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = nullptr ) FINAL;
1593 
1602  bool deleteFeature( QgsFeatureId fid );
1603 
1616  bool deleteFeatures( const QgsFeatureIds &fids );
1617 
1638  bool commitChanges();
1639 
1645  QStringList commitErrors() const;
1646 
1656  bool rollBack( bool deleteBuffer = true );
1657 
1664  QList<QgsRelation> referencingRelations( int idx ) const;
1665 
1667  QgsVectorLayerEditBuffer *editBuffer() { return mEditBuffer; }
1668 
1673  const QgsVectorLayerEditBuffer *editBuffer() const SIP_SKIP { return mEditBuffer; }
1674 
1679  void beginEditCommand( const QString &text );
1680 
1682  void endEditCommand();
1683 
1685  void destroyEditCommand();
1686 
1689  {
1692  NoMarker
1693  };
1694 
1696  static void drawVertexMarker( double x, double y, QPainter &p, QgsVectorLayer::VertexMarkerType type, int vertexSize );
1697 
1706  void updateFields();
1707 
1722  QVariant defaultValue( int index, const QgsFeature &feature = QgsFeature(),
1723  QgsExpressionContext *context = nullptr ) const;
1724 
1736  void setDefaultValueDefinition( int index, const QgsDefaultValue &definition );
1737 
1748  QgsDefaultValue defaultValueDefinition( int index ) const;
1749 
1757  QgsFieldConstraints::Constraints fieldConstraints( int fieldIndex ) const;
1758 
1764  QMap< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrength> fieldConstraintsAndStrength( int fieldIndex ) const;
1765 
1775 
1783  void removeFieldConstraint( int index, QgsFieldConstraints::Constraint constraint );
1784 
1792  QString constraintExpression( int index ) const;
1793 
1801  QString constraintDescription( int index ) const;
1802 
1811  void setConstraintExpression( int index, const QString &expression, const QString &description = QString() );
1812 
1816  void setEditorWidgetSetup( int index, const QgsEditorWidgetSetup &setup );
1817 
1824  QgsEditorWidgetSetup editorWidgetSetup( int index ) const;
1825 
1837  QSet<QVariant> uniqueValues( int fieldIndex, int limit = -1 ) const FINAL;
1838 
1852  QStringList uniqueStringsMatching( int index, const QString &substring, int limit = -1,
1853  QgsFeedback *feedback = nullptr ) const;
1854 
1863  QVariant minimumValue( int index ) const FINAL;
1864 
1873  QVariant maximumValue( int index ) const FINAL;
1874 
1885  QVariant aggregate( QgsAggregateCalculator::Aggregate aggregate,
1886  const QString &fieldOrExpression,
1887  const QgsAggregateCalculator::AggregateParameters &parameters = QgsAggregateCalculator::AggregateParameters(),
1888  QgsExpressionContext *context = nullptr,
1889  bool *ok = nullptr ) const;
1890 
1892  void setFeatureBlendMode( QPainter::CompositionMode blendMode );
1894  QPainter::CompositionMode featureBlendMode() const;
1895 
1903  void setOpacity( double opacity );
1904 
1912  double opacity() const;
1913 
1914  QString htmlMetadata() const FINAL;
1915 
1920  void setSimplifyMethod( const QgsVectorSimplifyMethod &simplifyMethod ) { mSimplifyMethod = simplifyMethod; }
1921 
1926  inline const QgsVectorSimplifyMethod &simplifyMethod() const { return mSimplifyMethod; }
1927 
1933  bool simplifyDrawingCanbeApplied( const QgsRenderContext &renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint ) const;
1934 
1942  QgsConditionalLayerStyles *conditionalStyles() const;
1943 
1948  QgsAttributeTableConfig attributeTableConfig() const;
1949 
1954  void setAttributeTableConfig( const QgsAttributeTableConfig &attributeTableConfig );
1955 
1963  QString mapTipTemplate() const;
1964 
1972  void setMapTipTemplate( const QString &mapTipTemplate );
1973 
1974  QgsExpressionContext createExpressionContext() const FINAL;
1975 
1976  QgsExpressionContextScope *createExpressionContextScope() const FINAL SIP_FACTORY;
1977 
1985  QgsEditFormConfig editFormConfig() const;
1986 
1993  void setEditFormConfig( const QgsEditFormConfig &editFormConfig );
1994 
2002  void setReadExtentFromXml( bool readExtentFromXml );
2003 
2011  bool readExtentFromXml() const;
2012 
2018  bool isEditCommandActive() const { return mEditCommandActive; }
2019 
2025  QgsGeometryOptions *geometryOptions() const;
2026 
2045  bool allowCommit() const SIP_SKIP;
2046 
2065  void setAllowCommit( bool allowCommit ) SIP_SKIP;
2066 
2067  public slots:
2068 
2076  void select( QgsFeatureId featureId );
2077 
2085  void select( const QgsFeatureIds &featureIds );
2086 
2094  void deselect( QgsFeatureId featureId );
2095 
2103  void deselect( const QgsFeatureIds &featureIds );
2104 
2110  void removeSelection();
2111 
2118  virtual void updateExtents( bool force = false );
2119 
2134  bool startEditing();
2135 
2136  signals:
2137 
2145  void dataSourceChanged();
2146 
2154  void selectionChanged( const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect );
2155 
2157  void layerModified();
2158 
2164  void allowCommitChanged();
2165 
2167  void beforeModifiedCheck() const;
2168 
2170  void beforeEditingStarted();
2171 
2173  void editingStarted();
2174 
2176  void editingStopped();
2177 
2179  void beforeCommitChanges();
2180 
2182  void beforeRollBack();
2183 
2188  void afterRollBack();
2189 
2198  void attributeAdded( int idx );
2199 
2206  void beforeAddingExpressionField( const QString &fieldName );
2207 
2216  void attributeDeleted( int idx );
2217 
2224  void beforeRemovingExpressionField( int idx );
2225 
2231  void featureAdded( QgsFeatureId fid );
2232 
2241  void featureDeleted( QgsFeatureId fid );
2242 
2252  void featuresDeleted( const QgsFeatureIds &fids );
2253 
2258  void updatedFields();
2259 
2264  void subsetStringChanged();
2265 
2274  void attributeValueChanged( QgsFeatureId fid, int idx, const QVariant &value );
2275 
2283  void geometryChanged( QgsFeatureId fid, const QgsGeometry &geometry );
2284 
2286  void committedAttributesDeleted( const QString &layerId, const QgsAttributeList &deletedAttributes );
2288  void committedAttributesAdded( const QString &layerId, const QList<QgsField> &addedAttributes );
2290  void committedFeaturesAdded( const QString &layerId, const QgsFeatureList &addedFeatures );
2292  void committedFeaturesRemoved( const QString &layerId, const QgsFeatureIds &deletedFeatureIds );
2294  void committedAttributeValuesChanges( const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues );
2296  void committedGeometriesChanges( const QString &layerId, const QgsGeometryMap &changedGeometries );
2297 
2299  void labelingFontNotFound( QgsVectorLayer *layer, const QString &fontfamily );
2300 
2302  void featureBlendModeChanged( QPainter::CompositionMode blendMode );
2303 
2311  void opacityChanged( double opacity );
2312 
2318  void editCommandStarted( const QString &text );
2319 
2325  void editCommandEnded();
2326 
2332  void editCommandDestroyed();
2333 
2343  void readCustomSymbology( const QDomElement &element, QString &errorMessage );
2344 
2354  void writeCustomSymbology( QDomElement &element, QDomDocument &doc, QString &errorMessage ) const;
2355 
2361  void mapTipTemplateChanged();
2362 
2368  void displayExpressionChanged();
2369 
2373  void raiseError( const QString &msg );
2374 
2380  void editFormConfigChanged();
2381 
2388  void readOnlyChanged();
2389 
2395  void symbolFeatureCountMapChanged();
2396 
2397  protected:
2399  void setExtent( const QgsRectangle &rect ) FINAL;
2400 
2401  private slots:
2402  void invalidateSymbolCountedFlag();
2403  void onFeatureCounterCompleted();
2404  void onFeatureCounterTerminated();
2405  void onJoinedFieldsChanged();
2406  void onFeatureDeleted( QgsFeatureId fid );
2407  void onRelationsLoaded();
2408  void onSymbolsCounted();
2409  void onDirtyTransaction( const QString &sql, const QString &name );
2410 
2411  private:
2412  void updateDefaultValues( QgsFeatureId fid, QgsFeature feature = QgsFeature() );
2413 
2417  bool isReadOnly() const FINAL;
2418 
2424  bool setDataProvider( QString const &provider, const QgsDataProvider::ProviderOptions &options );
2425 
2427  void readSldLabeling( const QDomNode &node );
2428 
2430  QgsAbstractVectorLayerLabeling *readLabelingFromCustomProperties();
2431 
2432 #ifdef SIP_RUN
2433  QgsVectorLayer( const QgsVectorLayer &rhs );
2434 #endif
2435 
2436  private: // Private attributes
2437  QgsConditionalLayerStyles *mConditionalStyles = nullptr;
2438 
2440  QgsVectorDataProvider *mDataProvider = nullptr;
2441 
2443  QString mDisplayExpression;
2444 
2445  QString mMapTipTemplate;
2446 
2448  QString mProviderKey;
2449 
2451  QgsActionManager *mActions = nullptr;
2452 
2454  bool mReadOnly = false;
2455 
2461  QgsFeatureIds mSelectedFeatureIds;
2462 
2464  QgsFields mFields;
2465 
2467  QgsStringMap mAttributeAliasMap;
2468 
2470  QMap<QString, QgsDefaultValue> mDefaultExpressionMap;
2471 
2473  QSet<int> mDefaultValueOnUpdateFields;
2474 
2476  QMap< QString, QgsFieldConstraints::Constraints > mFieldConstraints;
2477 
2479  QMap< QPair< QString, QgsFieldConstraints::Constraint >, QgsFieldConstraints::ConstraintStrength > mFieldConstraintStrength;
2480 
2482  QMap< QString, QPair< QString, QString > > mFieldConstraintExpressions;
2483 
2484  QMap< QString, QgsEditorWidgetSetup > mFieldWidgetSetups;
2485 
2487  QgsEditFormConfig mEditFormConfig;
2488 
2490  QSet<QString> mExcludeAttributesWMS;
2491 
2493  QSet<QString> mExcludeAttributesWFS;
2494 
2497 
2499  QgsFeatureRenderer *mRenderer = nullptr;
2500 
2502  QgsVectorSimplifyMethod mSimplifyMethod;
2503 
2505  QgsAbstractVectorLayerLabeling *mLabeling = nullptr;
2506 
2508  bool mLabelsEnabled = false;
2509 
2511  bool mLabelFontNotFoundNotified = false;
2512 
2514  QPainter::CompositionMode mFeatureBlendMode = QPainter::CompositionMode_SourceOver;
2515 
2517  double mLayerOpacity = 1.0;
2518 
2520  bool mVertexMarkerOnlyForSelection = false;
2521 
2522  QStringList mCommitErrors;
2523 
2525  QgsVectorLayerEditBuffer *mEditBuffer = nullptr;
2528 
2529  //stores information about joined layers
2530  QgsVectorLayerJoinBuffer *mJoinBuffer = nullptr;
2531 
2533  QgsExpressionFieldBuffer *mExpressionFieldBuffer = nullptr;
2534 
2535  //diagram rendering object. 0 if diagram drawing is disabled
2536  QgsDiagramRenderer *mDiagramRenderer = nullptr;
2537 
2538  //stores infos about diagram placement (placement type, priority, position distance)
2539  QgsDiagramLayerSettings *mDiagramLayerSettings = nullptr;
2540 
2541  mutable bool mValidExtent = false;
2542  mutable bool mLazyExtent = true;
2543 
2545  std::unique_ptr<QgsAuxiliaryLayer> mAuxiliaryLayer;
2546 
2548  QString mAuxiliaryLayerKey;
2549 
2550  // Features in renderer classes counted
2551  bool mSymbolFeatureCounted = false;
2552 
2553  // Feature counts for each renderer legend key
2554  QHash<QString, long> mSymbolFeatureCountMap;
2555 
2557  bool mEditCommandActive = false;
2558 
2559  bool mReadExtentFromXml;
2560  QgsRectangle mXmlExtent;
2561 
2562  QgsFeatureIds mDeletedFids;
2563 
2564  QgsAttributeTableConfig mAttributeTableConfig;
2565 
2566  mutable QMutex mFeatureSourceConstructorMutex;
2567 
2568  QgsVectorLayerFeatureCounter *mFeatureCounter = nullptr;
2569 
2570  std::unique_ptr<QgsGeometryOptions> mGeometryOptions;
2571 
2572  bool mAllowCommit = true;
2573 
2575 };
2576 
2577 
2578 
2579 // clazy:excludeall=qstring-allocations
2580 
2581 #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:40
Base class for all map layer types.
Definition: qgsmaplayer.h:63
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:570
OperationResult
Success or failure of a geometry operation.
Definition: qgsgeometry.h:115
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:36
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:208
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