QGIS API Documentation  3.4.15-Madeira (e83d02e274)
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 
1699  Q_DECL_DEPRECATED static void drawVertexMarker( double x, double y, QPainter &p, QgsVectorLayer::VertexMarkerType type, int vertexSize );
1700 
1709  void updateFields();
1710 
1725  QVariant defaultValue( int index, const QgsFeature &feature = QgsFeature(),
1726  QgsExpressionContext *context = nullptr ) const;
1727 
1739  void setDefaultValueDefinition( int index, const QgsDefaultValue &definition );
1740 
1751  QgsDefaultValue defaultValueDefinition( int index ) const;
1752 
1760  QgsFieldConstraints::Constraints fieldConstraints( int fieldIndex ) const;
1761 
1767  QMap< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrength> fieldConstraintsAndStrength( int fieldIndex ) const;
1768 
1778 
1786  void removeFieldConstraint( int index, QgsFieldConstraints::Constraint constraint );
1787 
1795  QString constraintExpression( int index ) const;
1796 
1804  QString constraintDescription( int index ) const;
1805 
1814  void setConstraintExpression( int index, const QString &expression, const QString &description = QString() );
1815 
1819  void setEditorWidgetSetup( int index, const QgsEditorWidgetSetup &setup );
1820 
1827  QgsEditorWidgetSetup editorWidgetSetup( int index ) const;
1828 
1840  QSet<QVariant> uniqueValues( int fieldIndex, int limit = -1 ) const FINAL;
1841 
1855  QStringList uniqueStringsMatching( int index, const QString &substring, int limit = -1,
1856  QgsFeedback *feedback = nullptr ) const;
1857 
1866  QVariant minimumValue( int index ) const FINAL;
1867 
1876  QVariant maximumValue( int index ) const FINAL;
1877 
1888  QVariant aggregate( QgsAggregateCalculator::Aggregate aggregate,
1889  const QString &fieldOrExpression,
1890  const QgsAggregateCalculator::AggregateParameters &parameters = QgsAggregateCalculator::AggregateParameters(),
1891  QgsExpressionContext *context = nullptr,
1892  bool *ok = nullptr ) const;
1893 
1895  void setFeatureBlendMode( QPainter::CompositionMode blendMode );
1897  QPainter::CompositionMode featureBlendMode() const;
1898 
1906  void setOpacity( double opacity );
1907 
1915  double opacity() const;
1916 
1917  QString htmlMetadata() const FINAL;
1918 
1923  void setSimplifyMethod( const QgsVectorSimplifyMethod &simplifyMethod ) { mSimplifyMethod = simplifyMethod; }
1924 
1929  inline const QgsVectorSimplifyMethod &simplifyMethod() const { return mSimplifyMethod; }
1930 
1936  bool simplifyDrawingCanbeApplied( const QgsRenderContext &renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint ) const;
1937 
1945  QgsConditionalLayerStyles *conditionalStyles() const;
1946 
1951  QgsAttributeTableConfig attributeTableConfig() const;
1952 
1957  void setAttributeTableConfig( const QgsAttributeTableConfig &attributeTableConfig );
1958 
1966  QString mapTipTemplate() const;
1967 
1975  void setMapTipTemplate( const QString &mapTipTemplate );
1976 
1977  QgsExpressionContext createExpressionContext() const FINAL;
1978 
1979  QgsExpressionContextScope *createExpressionContextScope() const FINAL SIP_FACTORY;
1980 
1988  QgsEditFormConfig editFormConfig() const;
1989 
1996  void setEditFormConfig( const QgsEditFormConfig &editFormConfig );
1997 
2005  void setReadExtentFromXml( bool readExtentFromXml );
2006 
2014  bool readExtentFromXml() const;
2015 
2021  bool isEditCommandActive() const { return mEditCommandActive; }
2022 
2028  QgsGeometryOptions *geometryOptions() const;
2029 
2048  bool allowCommit() const SIP_SKIP;
2049 
2068  void setAllowCommit( bool allowCommit ) SIP_SKIP;
2069 
2070  public slots:
2071 
2079  void select( QgsFeatureId featureId );
2080 
2088  void select( const QgsFeatureIds &featureIds );
2089 
2097  void deselect( QgsFeatureId featureId );
2098 
2106  void deselect( const QgsFeatureIds &featureIds );
2107 
2113  void removeSelection();
2114 
2121  virtual void updateExtents( bool force = false );
2122 
2137  bool startEditing();
2138 
2139  signals:
2140 
2148  void dataSourceChanged();
2149 
2157  void selectionChanged( const QgsFeatureIds &selected, const QgsFeatureIds &deselected, bool clearAndSelect );
2158 
2160  void layerModified();
2161 
2167  void allowCommitChanged();
2168 
2170  void beforeModifiedCheck() const;
2171 
2173  void beforeEditingStarted();
2174 
2176  void editingStarted();
2177 
2179  void editingStopped();
2180 
2182  void beforeCommitChanges();
2183 
2185  void beforeRollBack();
2186 
2191  void afterRollBack();
2192 
2201  void attributeAdded( int idx );
2202 
2209  void beforeAddingExpressionField( const QString &fieldName );
2210 
2219  void attributeDeleted( int idx );
2220 
2227  void beforeRemovingExpressionField( int idx );
2228 
2234  void featureAdded( QgsFeatureId fid );
2235 
2244  void featureDeleted( QgsFeatureId fid );
2245 
2255  void featuresDeleted( const QgsFeatureIds &fids );
2256 
2261  void updatedFields();
2262 
2267  void subsetStringChanged();
2268 
2277  void attributeValueChanged( QgsFeatureId fid, int idx, const QVariant &value );
2278 
2286  void geometryChanged( QgsFeatureId fid, const QgsGeometry &geometry );
2287 
2289  void committedAttributesDeleted( const QString &layerId, const QgsAttributeList &deletedAttributes );
2291  void committedAttributesAdded( const QString &layerId, const QList<QgsField> &addedAttributes );
2293  void committedFeaturesAdded( const QString &layerId, const QgsFeatureList &addedFeatures );
2295  void committedFeaturesRemoved( const QString &layerId, const QgsFeatureIds &deletedFeatureIds );
2297  void committedAttributeValuesChanges( const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues );
2299  void committedGeometriesChanges( const QString &layerId, const QgsGeometryMap &changedGeometries );
2300 
2302  void labelingFontNotFound( QgsVectorLayer *layer, const QString &fontfamily );
2303 
2305  void featureBlendModeChanged( QPainter::CompositionMode blendMode );
2306 
2314  void opacityChanged( double opacity );
2315 
2321  void editCommandStarted( const QString &text );
2322 
2328  void editCommandEnded();
2329 
2335  void editCommandDestroyed();
2336 
2346  void readCustomSymbology( const QDomElement &element, QString &errorMessage );
2347 
2357  void writeCustomSymbology( QDomElement &element, QDomDocument &doc, QString &errorMessage ) const;
2358 
2364  void mapTipTemplateChanged();
2365 
2371  void displayExpressionChanged();
2372 
2376  void raiseError( const QString &msg );
2377 
2383  void editFormConfigChanged();
2384 
2391  void readOnlyChanged();
2392 
2398  void symbolFeatureCountMapChanged();
2399 
2400  protected:
2402  void setExtent( const QgsRectangle &rect ) FINAL;
2403 
2404  private slots:
2405  void invalidateSymbolCountedFlag();
2406  void onFeatureCounterCompleted();
2407  void onFeatureCounterTerminated();
2408  void onJoinedFieldsChanged();
2409  void onFeatureDeleted( QgsFeatureId fid );
2410  void onRelationsLoaded();
2411  void onSymbolsCounted();
2412  void onDirtyTransaction( const QString &sql, const QString &name );
2413 
2414  private:
2415  void updateDefaultValues( QgsFeatureId fid, QgsFeature feature = QgsFeature() );
2416 
2420  bool isReadOnly() const FINAL;
2421 
2427  bool setDataProvider( QString const &provider, const QgsDataProvider::ProviderOptions &options );
2428 
2430  void readSldLabeling( const QDomNode &node );
2431 
2433  QgsAbstractVectorLayerLabeling *readLabelingFromCustomProperties();
2434 
2435 #ifdef SIP_RUN
2436  QgsVectorLayer( const QgsVectorLayer &rhs );
2437 #endif
2438 
2439  private: // Private attributes
2440  QgsConditionalLayerStyles *mConditionalStyles = nullptr;
2441 
2443  QgsVectorDataProvider *mDataProvider = nullptr;
2444 
2446  QString mDisplayExpression;
2447 
2448  QString mMapTipTemplate;
2449 
2451  QString mProviderKey;
2452 
2454  QgsActionManager *mActions = nullptr;
2455 
2457  bool mReadOnly = false;
2458 
2464  QgsFeatureIds mSelectedFeatureIds;
2465 
2467  QgsFields mFields;
2468 
2470  QgsStringMap mAttributeAliasMap;
2471 
2473  QMap<QString, QgsDefaultValue> mDefaultExpressionMap;
2474 
2476  QSet<int> mDefaultValueOnUpdateFields;
2477 
2479  QMap< QString, QgsFieldConstraints::Constraints > mFieldConstraints;
2480 
2482  QMap< QPair< QString, QgsFieldConstraints::Constraint >, QgsFieldConstraints::ConstraintStrength > mFieldConstraintStrength;
2483 
2485  QMap< QString, QPair< QString, QString > > mFieldConstraintExpressions;
2486 
2487  QMap< QString, QgsEditorWidgetSetup > mFieldWidgetSetups;
2488 
2490  QgsEditFormConfig mEditFormConfig;
2491 
2493  QSet<QString> mExcludeAttributesWMS;
2494 
2496  QSet<QString> mExcludeAttributesWFS;
2497 
2500 
2502  QgsFeatureRenderer *mRenderer = nullptr;
2503 
2505  QgsVectorSimplifyMethod mSimplifyMethod;
2506 
2508  QgsAbstractVectorLayerLabeling *mLabeling = nullptr;
2509 
2511  bool mLabelsEnabled = false;
2512 
2514  bool mLabelFontNotFoundNotified = false;
2515 
2517  QPainter::CompositionMode mFeatureBlendMode = QPainter::CompositionMode_SourceOver;
2518 
2520  double mLayerOpacity = 1.0;
2521 
2523  bool mVertexMarkerOnlyForSelection = false;
2524 
2525  QStringList mCommitErrors;
2526 
2528  QgsVectorLayerEditBuffer *mEditBuffer = nullptr;
2531 
2532  //stores information about joined layers
2533  QgsVectorLayerJoinBuffer *mJoinBuffer = nullptr;
2534 
2536  QgsExpressionFieldBuffer *mExpressionFieldBuffer = nullptr;
2537 
2538  //diagram rendering object. 0 if diagram drawing is disabled
2539  QgsDiagramRenderer *mDiagramRenderer = nullptr;
2540 
2541  //stores infos about diagram placement (placement type, priority, position distance)
2542  QgsDiagramLayerSettings *mDiagramLayerSettings = nullptr;
2543 
2544  mutable bool mValidExtent = false;
2545  mutable bool mLazyExtent = true;
2546 
2548  std::unique_ptr<QgsAuxiliaryLayer> mAuxiliaryLayer;
2549 
2551  QString mAuxiliaryLayerKey;
2552 
2553  // Features in renderer classes counted
2554  bool mSymbolFeatureCounted = false;
2555 
2556  // Feature counts for each renderer legend key
2557  QHash<QString, long> mSymbolFeatureCountMap;
2558 
2560  bool mEditCommandActive = false;
2561 
2562  bool mReadExtentFromXml;
2563  QgsRectangle mXmlExtent;
2564 
2565  QgsFeatureIds mDeletedFids;
2566 
2567  QgsAttributeTableConfig mAttributeTableConfig;
2568 
2569  mutable QMutex mFeatureSourceConstructorMutex;
2570 
2571  QgsVectorLayerFeatureCounter *mFeatureCounter = nullptr;
2572 
2573  std::unique_ptr<QgsGeometryOptions> mGeometryOptions;
2574 
2575  bool mAllowCommit = true;
2576 
2578 };
2579 
2580 
2581 
2582 // clazy:excludeall=qstring-allocations
2583 
2584 #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
QgsAttributeList attributeList() const
Returns list of attribute indexes.
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.
QSet< QString > excludeAttributesWfs() const
A set of attributes that are not advertised in WFS 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
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.
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
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings for fast rendering of features.
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
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:55
const QgsDiagramLayerSettings * diagramLayerSettings() const
const QgsVectorLayerEditBuffer * editBuffer() const
Buffer with uncommitted editing operations.
QMap< QString, QString > QgsStringMap
Definition: qgis.h:577
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 cancellation of something running in a worker thread...
Definition: qgsfeedback.h:44
const QgsFeatureRenderer * renderer() const
Returns const renderer.
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...
QgsFeature getFeature(QgsFeatureId fid) const
Query the layer for the feature with the given id.
Type
The WKB type describes the number of dimensions a geometry has.
Definition: qgswkbtypes.h:68
const QgsAbstractVectorLayerLabeling * labeling() const
Access to const labeling configuration.
#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.
const QgsActionManager * actions() const
Returns all layer actions defined on this layer.
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
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
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.
const QgsDiagramRenderer * diagramRenderer() const
Buffers information about expression fields for a vector layer.
#define FINAL
Definition: qgis_sip.h:216
QSet< QString > excludeAttributesWms() const
A set of attributes that are not advertised in WMS requests with QGIS server.
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.
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...
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
Represents a vector layer which manages a vector based data sets.
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
bool isEditCommandActive() const
Test if an edit command is active.