QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgsvectorlayer.h
Go to the documentation of this file.
1 
2 /***************************************************************************
3  qgsvectorlayer.h - description
4  -------------------
5  begin : Oct 29, 2003
6  copyright : (C) 2003 by Gary E.Sherman
7  email : sherman at mrcc.com
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 #ifndef QGSVECTORLAYER_H
20 #define QGSVECTORLAYER_H
21 
22 #include <QMap>
23 #include <QSet>
24 #include <QList>
25 #include <QStringList>
26 #include <QFont>
27 
28 #include "qgis.h"
29 #include "qgsmaplayer.h"
30 #include "qgsfeature.h"
31 #include "qgsfeatureiterator.h"
32 #include "qgseditorwidgetconfig.h"
33 #include "qgsfield.h"
34 #include "qgssnapper.h"
36 #include "qgseditformconfig.h"
38 #include "qgsaggregatecalculator.h"
39 
40 class QPainter;
41 class QImage;
42 
44 class QgsActionManager;
47 class QgsCurveV2;
53 class QgsFeatureRequest;
54 class QgsGeometry;
55 class QgsGeometryCache;
56 class QgsGeometryVertexIndex;
57 class QgsLabel;
58 class QgsMapToPixel;
59 class QgsRectangle;
60 class QgsRectangle;
61 class QgsRelation;
62 class QgsRelationManager;
64 class QgsSymbolV2;
69 class QgsPointV2;
70 
74 
75 
76 struct CORE_EXPORT QgsVectorJoinInfo
77 {
79  : memoryCache( false )
80  , cacheDirty( true )
81  , targetFieldIndex( -1 )
82  , joinFieldIndex( -1 )
83  {}
84 
94  bool cacheDirty;
95 
100 
105 
110 
111  bool operator==( const QgsVectorJoinInfo& other ) const
112  {
113  return targetFieldName == other.targetFieldName &&
114  joinLayerId == other.joinLayerId &&
115  joinFieldName == other.joinFieldName &&
116  joinFieldsSubset == other.joinFieldsSubset &&
117  memoryCache == other.memoryCache &&
118  prefix == other.prefix;
119  }
120 
123  void setJoinFieldNamesSubset( QStringList* fieldNamesSubset ) { joinFieldsSubset = QSharedPointer<QStringList>( fieldNamesSubset ); }
126  QStringList* joinFieldNamesSubset() const { return joinFieldsSubset.data(); }
127 
128 protected:
131 };
132 
133 
134 
408 class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
409 {
410  Q_OBJECT
411 
412  public:
413 
416 
418  {
419  GeneratedLayout = 0,
420  TabLayout = 1,
421  UiFileLayout = 2
422  };
423 
424  struct RangeData
425  {
427  Q_DECL_DEPRECATED RangeData() { mMin = QVariant( 0 ); mMax = QVariant( 5 ); mStep = QVariant( 1 );}
429  Q_DECL_DEPRECATED RangeData( const QVariant& theMin, const QVariant& theMax, const QVariant& theStep )
430  : mMin( theMin )
431  , mMax( theMax )
432  , mStep( theStep )
433  {}
434 
438  };
439 
441  {
443  : mAllowNull( false )
444  , mOrderByValue( false )
445  , mAllowMulti( false )
446  {}
447  ValueRelationData( const QString& layer, const QString& key, const QString& value, bool allowNull, bool orderByValue,
448  bool allowMulti = false,
449  const QString& filterExpression = QString::null )
450  : mLayer( layer )
451  , mKey( key )
452  , mValue( value )
453  , mFilterExpression( filterExpression )
454  , mAllowNull( allowNull )
455  , mOrderByValue( orderByValue )
456  , mAllowMulti( allowMulti )
457  {}
458 
465  bool mAllowMulti; /* allow selection of multiple keys */
466  };
467 
474  {
475  SuppressDefault = 0, // use the application-wide setting
476  SuppressOn = 1,
477  SuppressOff = 2
478  };
479 
483  enum EditType
484  {
506  };
507 
510  {
511  Success = 0,
512  EmptyGeometry = 1,
513  EditFailed = 2,
514  FetchFeatureFailed = 3,
515  InvalidLayer = 4,
516  };
517 
520  {
525  };
526 
540  QgsVectorLayer( const QString& path = QString::null, const QString& baseName = QString::null,
541  const QString& providerLib = QString::null, bool loadDefaultStyleFlag = true );
542 
544  virtual ~QgsVectorLayer();
545 
547  QString storageType() const;
548 
550  QString capabilitiesString() const;
551 
553  QString dataComment() const;
554 
556  void setDisplayField( const QString& fldName = "" );
557 
559  QString displayField() const;
560 
567  void setDisplayExpression( const QString &displayExpression );
568 
575  QString displayExpression() const;
576 
578  QgsVectorDataProvider* dataProvider();
579 
583  const QgsVectorDataProvider* dataProvider() const;
584 
586  void setProviderEncoding( const QString& encoding );
587 
589  void setCoordinateSystem();
590 
594  bool addJoin( const QgsVectorJoinInfo& joinInfo );
595 
598  bool removeJoin( const QString& joinLayerId );
599 
604  QgsVectorLayerJoinBuffer* joinBuffer() { return mJoinBuffer; }
605  const QList<QgsVectorJoinInfo> vectorJoins() const;
606 
610  virtual QSet<QString> layerDependencies() const;
611 
622  int addExpressionField( const QString& exp, const QgsField& fld );
623 
631  void removeExpressionField( int index );
632 
642  QString expressionField( int index );
643 
653  void updateExpressionField( int index, const QString& exp );
654 
656  QgsLabel *label();
657 
661  const QgsLabel *label() const;
662 
669  QgsActionManager* actions() { return mActions; }
670 
676  int selectedFeatureCount();
677 
688  Q_DECL_DEPRECATED void select( QgsRectangle & rect, bool addToSelection );
689 
699  void selectByRect( QgsRectangle & rect, SelectBehaviour behaviour = SetSelection );
700 
709  void selectByExpression( const QString& expression, SelectBehaviour behaviour = SetSelection );
710 
720  void selectByIds( const QgsFeatureIds &ids, SelectBehaviour behaviour = SetSelection );
721 
734  void modifySelection( QgsFeatureIds selectIds, QgsFeatureIds deselectIds );
735 
737  void invertSelection();
738 
740  void selectAll();
741 
743  QgsFeatureIds allFeatureIds();
744 
752  void invertSelectionInRectangle( QgsRectangle & rect );
753 
762  QgsFeatureList selectedFeatures();
763 
775  QgsFeatureIterator selectedFeaturesIterator( QgsFeatureRequest request = QgsFeatureRequest() );
776 
783  const QgsFeatureIds &selectedFeaturesIds() const;
784 
793  Q_DECL_DEPRECATED void setSelectedFeatures( const QgsFeatureIds &ids );
794 
796  QgsRectangle boundingBoxOfSelected();
797 
802  bool labelsEnabled() const;
803 
808  bool diagramsEnabled() const;
809 
811  void setDiagramRenderer( QgsDiagramRendererV2* r );
812  const QgsDiagramRendererV2* diagramRenderer() const { return mDiagramRenderer; }
813 
814  void setDiagramLayerSettings( const QgsDiagramLayerSettings& s );
815  const QgsDiagramLayerSettings *diagramLayerSettings() const { return mDiagramLayerSettings; }
816 
818  QgsFeatureRendererV2* rendererV2() { return mRendererV2; }
819 
823  const QgsFeatureRendererV2* rendererV2() const { return mRendererV2; }
824 
829  void setRendererV2( QgsFeatureRendererV2* r );
830 
832  QGis::GeometryType geometryType() const;
833 
835  bool hasGeometryType() const;
836 
838  QGis::WkbType wkbType() const;
839 
841  QString providerType() const;
842 
846  virtual bool readXml( const QDomNode& layer_node ) override;
847 
851  virtual bool writeXml( QDomNode & layer_node, QDomDocument & doc ) override;
852 
861  virtual void saveStyleToDatabase( const QString& name, const QString& description,
862  bool useAsDefault, const QString& uiFileContent,
863  QString &msgError );
864 
873  virtual int listStylesInDatabase( QStringList &ids, QStringList &names,
874  QStringList &descriptions, QString &msgError );
875 
879  virtual QString getStyleFromDatabase( const QString& styleId, QString &msgError );
880 
887  virtual QString loadNamedStyle( const QString &theURI, bool &theResultFlag, bool loadFromLocalDb );
888 
893  virtual QString loadNamedStyle( const QString &theURI, bool &theResultFlag ) override;
894 
905  Q_DECL_DEPRECATED virtual bool applyNamedStyle( const QString& namedStyle, QString &errorMsg );
906 
911  QgsAttributeEditorElement* attributeEditorElementFromDomElement( QDomElement &elem, QObject* parent ) { return mEditFormConfig->attributeEditorElementFromDomElement( elem, parent ); }
912 
918  bool readSymbology( const QDomNode& node, QString& errorMessage ) override;
919 
925  bool readStyle( const QDomNode& node, QString& errorMessage ) override;
926 
933  bool writeSymbology( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const override;
934 
941  bool writeStyle( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const override;
942 
943 
951  bool writeSld( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const;
952 
961  bool writeSld( QDomNode& node, QDomDocument& doc, QString& errorMessage, const QgsStringMap& props ) const;
962 
970  bool readSld( const QDomNode& node, QString& errorMessage ) override;
971 
978  long featureCount( QgsSymbolV2* symbol );
979 
990  void setDataSource( const QString& dataSource, const QString& baseName, const QString& provider, bool loadDefaultStyleFlag = false );
991 
997  bool countSymbolFeatures( bool showProgress = true );
998 
1006  virtual bool setSubsetString( const QString& subset );
1007 
1012  virtual QString subsetString();
1013 
1017  QgsFeatureIterator getFeatures( const QgsFeatureRequest& request = QgsFeatureRequest() );
1018 
1024  bool addFeature( QgsFeature& feature, bool alsoUpdateExtent = true );
1025 
1032  bool updateFeature( QgsFeature &f );
1033 
1038  bool insertVertex( double x, double y, QgsFeatureId atFeatureId, int beforeVertex );
1039 
1044  bool moveVertex( double x, double y, QgsFeatureId atFeatureId, int atVertex );
1045 
1051  bool moveVertex( const QgsPointV2& p, QgsFeatureId atFeatureId, int atVertex );
1052 
1056  Q_DECL_DEPRECATED bool deleteVertex( QgsFeatureId atFeatureId, int atVertex );
1057 
1063  //TODO QGIS 3.0 - rename back to deleteVertex
1064  EditResult deleteVertexV2( QgsFeatureId featureId, int vertex );
1065 
1069  bool deleteSelectedFeatures( int *deletedCount = nullptr );
1070 
1083  // TODO QGIS 3.0 returns an enum instead of a magic constant
1084  int addRing( const QList<QgsPoint>& ring, QgsFeatureId* featureId = nullptr );
1085 
1096  // TODO QGIS 3.0 returns an enum instead of a magic constant
1097  int addRing( QgsCurveV2* ring, QgsFeatureId* featureId = nullptr );
1098 
1110  // TODO QGIS 3.0 returns an enum instead of a magic constant
1111  int addPart( const QList<QgsPoint>& ring );
1112 
1125  // TODO QGIS 3.0 returns an enum instead of a magic constant
1126  int addPart( const QgsPointSequenceV2 &ring );
1127 
1129  int addPart( QgsCurveV2* ring );
1130 
1137  int translateFeature( QgsFeatureId featureId, double dx, double dy );
1138 
1146  // TODO QGIS 3.0 returns an enum instead of a magic constant
1147  int splitParts( const QList<QgsPoint>& splitLine, bool topologicalEditing = false );
1148 
1156  // TODO QGIS 3.0 returns an enum instead of a magic constant
1157  int splitFeatures( const QList<QgsPoint>& splitLine, bool topologicalEditing = false );
1158 
1167  Q_DECL_DEPRECATED int removePolygonIntersections( QgsGeometry* geom, const QgsFeatureIds& ignoreFeatures = QgsFeatureIds() );
1168 
1174  int addTopologicalPoints( const QgsGeometry* geom );
1175 
1183  int addTopologicalPoints( const QgsPoint& p );
1184 
1190  int insertSegmentVerticesForSnap( const QList<QgsSnappingResult>& snapResults );
1191 
1195  Q_DECL_DEPRECATED void enableLabels( bool on );
1196 
1200  Q_DECL_DEPRECATED bool hasLabelsEnabled() const;
1201 
1206  const QgsAbstractVectorLayerLabeling* labeling() const { return mLabeling; }
1207 
1212  void setLabeling( QgsAbstractVectorLayerLabeling* labeling );
1213 
1215  virtual bool isEditable() const override;
1216 
1217  virtual bool isSpatial() const override;
1218 
1226  Q_DECL_DEPRECATED virtual bool isReadOnly() const override;
1227 
1229  virtual bool isModified() const;
1230 
1237  bool snapPoint( QgsPoint& point, double tolerance );
1238 
1246  int snapWithContext( const QgsPoint& startPoint,
1247  double snappingTolerance,
1248  QMultiMap < double, QgsSnappingResult > &snappingResults,
1249  QgsSnapper::SnappingType snap_to );
1250 
1252  virtual void reload() override;
1253 
1257  virtual QgsMapLayerRenderer* createMapRenderer( QgsRenderContext& rendererContext ) override;
1258 
1262  bool draw( QgsRenderContext& rendererContext ) override;
1263 
1267  Q_DECL_DEPRECATED void drawLabels( QgsRenderContext& rendererContext ) override;
1268 
1270  QgsRectangle extent() override;
1271 
1278  inline QgsFields fields() const { return mUpdatedFields; }
1279 
1287  inline QgsFields pendingFields() const { return mUpdatedFields; }
1288 
1293  inline QgsAttributeList pendingAllAttributesList() const { return mUpdatedFields.allAttributesList(); }
1294 
1299  inline QgsAttributeList attributeList() const { return mUpdatedFields.allAttributesList(); }
1300 
1305  inline QgsAttributeList pendingPkAttributesList() const { return pkAttributeList(); }
1306 
1308  QgsAttributeList pkAttributeList() const;
1309 
1314  inline long pendingFeatureCount() const { return featureCount(); }
1315 
1320  long featureCount() const;
1321 
1325  bool setReadOnly( bool readonly = true );
1326 
1328  bool changeGeometry( QgsFeatureId fid, QgsGeometry* geom );
1329 
1336  Q_DECL_DEPRECATED bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant& value, bool emitSignal );
1337 
1348  bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant() );
1349 
1381  bool changeAttributeValues( QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues );
1382 
1386  bool addAttribute( const QgsField &field );
1387 
1389  void addAttributeAlias( int attIndex, const QString& aliasString );
1390 
1392  void remAttributeAlias( int attIndex );
1393 
1399  bool renameAttribute( int attIndex, const QString& newName );
1400 
1406  Q_DECL_DEPRECATED void addAttributeEditorWidget( QgsAttributeEditorElement* data ) {mEditFormConfig->addTab( data );}
1407 
1417  Q_DECL_DEPRECATED const QString editorWidgetV2( int fieldIdx ) const { return mEditFormConfig->widgetType( fieldIdx ); }
1418 
1430  Q_DECL_DEPRECATED const QString editorWidgetV2( const QString& fieldName ) const { return mEditFormConfig->widgetType( fieldName ); }
1431 
1441  Q_DECL_DEPRECATED const QgsEditorWidgetConfig editorWidgetV2Config( int fieldIdx ) const { return mEditFormConfig->widgetConfig( fieldIdx ); }
1442 
1454  Q_DECL_DEPRECATED const QgsEditorWidgetConfig editorWidgetV2Config( const QString& fieldName ) const { return mEditFormConfig->widgetConfig( fieldName ); }
1455 
1461  Q_DECL_DEPRECATED QList< QgsAttributeEditorElement* > attributeEditorElements() { return mEditFormConfig->tabs(); }
1462 
1471  QgsEditFormConfig* editFormConfig() const { return mEditFormConfig; }
1472 
1476  void clearAttributeEditorWidgets() { mEditFormConfig->clearTabs(); }
1477 
1484  QString attributeAlias( int attributeIndex ) const;
1485 
1487  QString attributeDisplayName( int attributeIndex ) const;
1488 
1490  QgsStringMap attributeAliases() const;
1491 
1492  const QSet<QString>& excludeAttributesWMS() const { return mExcludeAttributesWMS; }
1493  void setExcludeAttributesWMS( const QSet<QString>& att ) { mExcludeAttributesWMS = att; }
1494 
1495  const QSet<QString>& excludeAttributesWFS() const { return mExcludeAttributesWFS; }
1496  void setExcludeAttributesWFS( const QSet<QString>& att ) { mExcludeAttributesWFS = att; }
1497 
1499  bool deleteAttribute( int attr );
1500 
1508  bool deleteAttributes( QList<int> attrs );
1509 
1511  bool addFeatures( QgsFeatureList features, bool makeSelected = true );
1512 
1514  bool deleteFeature( QgsFeatureId fid );
1515 
1523  bool deleteFeatures( const QgsFeatureIds& fids );
1524 
1540  bool commitChanges();
1541  const QStringList &commitErrors();
1542 
1546  bool rollBack( bool deleteBuffer = true );
1547 
1553  Q_DECL_DEPRECATED EditType editType( int idx );
1554 
1560  Q_DECL_DEPRECATED void setEditType( int idx, EditType edit );
1561 
1566  Q_DECL_DEPRECATED EditorLayout editorLayout() { return static_cast< EditorLayout >( mEditFormConfig->layout() ); }
1567 
1572  Q_DECL_DEPRECATED void setEditorLayout( EditorLayout editorLayout ) { mEditFormConfig->setLayout( static_cast< QgsEditFormConfig::EditorLayout >( editorLayout ) ); }
1573 
1604  Q_DECL_DEPRECATED void setEditorWidgetV2( int attrIdx, const QString& widgetType ) { mEditFormConfig->setWidgetType( attrIdx, widgetType ); }
1605 
1623  Q_DECL_DEPRECATED void setEditorWidgetV2Config( int attrIdx, const QgsEditorWidgetConfig& config ) { mEditFormConfig->setWidgetConfig( attrIdx, config ); }
1624 
1630  Q_DECL_DEPRECATED void setCheckedState( int idx, const QString& checked, const QString& notChecked );
1631 
1637  Q_DECL_DEPRECATED QString editForm() const { return mEditFormConfig->uiForm(); }
1638 
1643  Q_DECL_DEPRECATED void setEditForm( const QString& ui ) { mEditFormConfig->setUiForm( ui ); }
1644 
1649  Q_DECL_DEPRECATED QgsVectorLayer::FeatureFormSuppress featureFormSuppress() const { return static_cast< FeatureFormSuppress >( mEditFormConfig->suppress() ); }
1650 
1655  Q_DECL_DEPRECATED void setFeatureFormSuppress( QgsVectorLayer::FeatureFormSuppress s ) { mEditFormConfig->setSuppress( static_cast< QgsEditFormConfig::FeatureFormSuppress >( s ) ); }
1656 
1658  QString annotationForm() const { return mAnnotationForm; }
1659 
1661  void setAnnotationForm( const QString& ui );
1662 
1668  Q_DECL_DEPRECATED QString editFormInit() const { return mEditFormConfig->initFunction(); }
1669 
1675  Q_DECL_DEPRECATED void setEditFormInit( const QString& function ) { mEditFormConfig->setInitFunction( function ); }
1676 
1681  Q_DECL_DEPRECATED QMap<QString, QVariant> valueMap( int idx );
1682 
1688  Q_DECL_DEPRECATED RangeData range( int idx );
1689 
1691  ValueRelationData valueRelation( int idx );
1692 
1699  QList<QgsRelation> referencingRelations( int idx );
1700 
1706  Q_DECL_DEPRECATED QString dateFormat( int idx );
1707 
1713  Q_DECL_DEPRECATED QSize widgetSize( int idx );
1714 
1720  Q_DECL_DEPRECATED bool fieldEditable( int idx ) { return !mEditFormConfig->readOnly( idx ); }
1721 
1726  Q_DECL_DEPRECATED bool labelOnTop( int idx ) { return mEditFormConfig->labelOnTop( idx ); }
1727 
1732  Q_DECL_DEPRECATED void setFieldEditable( int idx, bool editable ) { mEditFormConfig->setReadOnly( idx, !editable ); }
1733 
1738  Q_DECL_DEPRECATED void setLabelOnTop( int idx, bool onTop ) { mEditFormConfig->setLabelOnTop( idx, onTop ); }
1739 
1741  QgsVectorLayerEditBuffer* editBuffer() { return mEditBuffer; }
1742 
1747  void beginEditCommand( const QString& text );
1748 
1750  void endEditCommand();
1751 
1753  void destroyEditCommand();
1754 
1756  int fieldNameIndex( const QString& fieldName ) const;
1757 
1760  {
1763  NoMarker
1764  };
1765 
1767  static void drawVertexMarker( double x, double y, QPainter& p, QgsVectorLayer::VertexMarkerType type, int vertexSize );
1768 
1770  void updateFields();
1771 
1773  void createJoinCaches();
1774 
1788  QVariant defaultValue( int index, const QgsFeature& feature = QgsFeature(),
1789  QgsExpressionContext* context = nullptr ) const;
1790 
1799  void setDefaultValueExpression( int index, const QString& expression );
1800 
1809  QString defaultValueExpression( int index ) const;
1810 
1822  void uniqueValues( int index, QList<QVariant> &uniqueValues, int limit = -1 );
1823 
1831  QVariant minimumValue( int index );
1832 
1840  QVariant maximumValue( int index );
1841 
1851  QVariant aggregate( QgsAggregateCalculator::Aggregate aggregate,
1852  const QString& fieldOrExpression,
1854  QgsExpressionContext* context = nullptr,
1855  bool* ok = nullptr );
1856 
1865  QList< QVariant > getValues( const QString &fieldOrExpression, bool &ok, bool selectedOnly = false );
1866 
1877  QList< double > getDoubleValues( const QString &fieldOrExpression, bool &ok, bool selectedOnly = false, int* nullCount = nullptr );
1878 
1880  void setFeatureBlendMode( QPainter::CompositionMode blendMode );
1882  QPainter::CompositionMode featureBlendMode() const;
1883 
1885  void setLayerTransparency( int layerTransparency );
1887  int layerTransparency() const;
1888 
1889  QString metadata() override;
1890 
1892  inline QgsGeometryCache* cache() { return mCache; }
1893 
1897  void setSimplifyMethod( const QgsVectorSimplifyMethod& simplifyMethod ) { mSimplifyMethod = simplifyMethod; }
1901  inline const QgsVectorSimplifyMethod& simplifyMethod() const { return mSimplifyMethod; }
1902 
1907  bool simplifyDrawingCanbeApplied( const QgsRenderContext& renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint ) const;
1908 
1916  QgsConditionalLayerStyles *conditionalStyles() const;
1917 
1922  QgsAttributeTableConfig attributeTableConfig() const;
1923 
1928  void setAttributeTableConfig( const QgsAttributeTableConfig& attributeTableConfig );
1929 
1930  public slots:
1938  void select( QgsFeatureId featureId );
1939 
1947  void select( const QgsFeatureIds& featureIds );
1948 
1956  void deselect( const QgsFeatureId featureId );
1957 
1965  void deselect( const QgsFeatureIds& featureIds );
1966 
1972  void removeSelection();
1973 
1977  virtual void updateExtents();
1978 
1980  void checkJoinLayerRemove( const QString& theLayerId );
1981 
1988  bool startEditing();
1989 
1990 
1991  protected slots:
1992  void invalidateSymbolCountedFlag();
1993 
1994  signals:
1995 
2003  void selectionChanged( const QgsFeatureIds& selected, const QgsFeatureIds& deselected, const bool clearAndSelect );
2004 
2006  void selectionChanged();
2007 
2009  void layerModified();
2010 
2012  void beforeModifiedCheck() const;
2013 
2015  void beforeEditingStarted();
2016 
2018  void editingStarted();
2019 
2021  void editingStopped();
2022 
2024  void beforeCommitChanges();
2025 
2027  void beforeRollBack();
2028 
2037  void attributeAdded( int idx );
2038 
2045  void beforeAddingExpressionField( const QString& fieldName );
2046 
2055  void attributeDeleted( int idx );
2056 
2063  void beforeRemovingExpressionField( int idx );
2064 
2070  void featureAdded( QgsFeatureId fid );
2071 
2080  void featureDeleted( QgsFeatureId fid );
2081 
2091  void featuresDeleted( const QgsFeatureIds& fids );
2092 
2097  void updatedFields();
2098 
2102  void layerDeleted();
2103 
2112  void attributeValueChanged( QgsFeatureId fid, int idx, const QVariant& value );
2113 
2121  void geometryChanged( QgsFeatureId fid, QgsGeometry& geometry );
2122 
2124  void committedAttributesDeleted( const QString& layerId, const QgsAttributeList& deletedAttributes );
2126  void committedAttributesAdded( const QString& layerId, const QList<QgsField>& addedAttributes );
2128  void committedFeaturesAdded( const QString& layerId, const QgsFeatureList& addedFeatures );
2130  void committedFeaturesRemoved( const QString& layerId, const QgsFeatureIds& deletedFeatureIds );
2132  void committedAttributeValuesChanges( const QString& layerId, const QgsChangedAttributesMap& changedAttributesValues );
2134  void committedGeometriesChanges( const QString& layerId, const QgsGeometryMap& changedGeometries );
2135 
2137  Q_DECL_DEPRECATED void saveLayerToProject();
2138 
2140  void labelingFontNotFound( QgsVectorLayer* layer, const QString& fontfamily );
2141 
2143  void featureBlendModeChanged( QPainter::CompositionMode blendMode );
2144 
2146  void layerTransparencyChanged( int layerTransparency );
2147 
2153  void editCommandStarted( const QString& text );
2154 
2160  void editCommandEnded();
2161 
2167  void editCommandDestroyed();
2168 
2178  void readCustomSymbology( const QDomElement& element, QString& errorMessage );
2179 
2189  void writeCustomSymbology( QDomElement& element, QDomDocument& doc, QString& errorMessage ) const;
2190 
2194  void raiseError( const QString& msg );
2195 
2196  private slots:
2197  void onJoinedFieldsChanged();
2198  void onFeatureDeleted( QgsFeatureId fid );
2199 
2200  protected:
2202  void setExtent( const QgsRectangle &rect ) override;
2203 
2204  private: // Private methods
2205 
2207  QgsVectorLayer( const QgsVectorLayer & rhs );
2208 
2210  QgsVectorLayer & operator=( QgsVectorLayer const & rhs );
2211 
2212 
2217  bool setDataProvider( QString const & provider );
2218 
2220  QgsFeatureId findFreeId();
2221 
2230  void snapToGeometry( const QgsPoint& startPoint,
2231  QgsFeatureId featureId,
2232  const QgsGeometry *geom,
2233  double sqrSnappingTolerance,
2234  QMultiMap<double, QgsSnappingResult>& snappingResults,
2235  QgsSnapper::SnappingType snap_to ) const;
2236 
2238  //void addJoinedAttributes( QgsFeature& f, bool all = false );
2239 
2241  void readSldLabeling( const QDomNode& node );
2242 
2243  private: // Private attributes
2244 
2245  QgsConditionalLayerStyles * mConditionalStyles;
2246 
2248  QgsVectorDataProvider *mDataProvider;
2249 
2251  QString mDisplayField;
2252 
2254  QString mDisplayExpression;
2255 
2257  QString mProviderKey;
2258 
2260  QgsActionManager* mActions;
2261 
2263  bool mReadOnly;
2264 
2269  QgsFeatureIds mSelectedFeatureIds;
2270 
2272  QgsFields mUpdatedFields;
2273 
2275  QgsStringMap mAttributeAliasMap;
2276 
2278  QgsStringMap mDefaultExpressionMap;
2279 
2281  QgsEditFormConfig* mEditFormConfig;
2282 
2284  QSet<QString> mExcludeAttributesWMS;
2285 
2287  QSet<QString> mExcludeAttributesWFS;
2288 
2290  QGis::WkbType mWkbType;
2291 
2293  QgsFeatureRendererV2 *mRendererV2;
2294 
2296  QgsVectorSimplifyMethod mSimplifyMethod;
2297 
2299  QgsLabel *mLabel;
2300 
2302  bool mLabelOn;
2303 
2305  QgsAbstractVectorLayerLabeling* mLabeling;
2306 
2308  bool mLabelFontNotFoundNotified;
2309 
2311  QPainter::CompositionMode mFeatureBlendMode;
2312 
2314  int mLayerTransparency;
2315 
2317  bool mVertexMarkerOnlyForSelection;
2318 
2319  QStringList mCommitErrors;
2320 
2322  QString mAnnotationForm;
2323 
2325  QgsGeometryCache* mCache;
2326 
2328  QgsVectorLayerEditBuffer* mEditBuffer;
2330 
2331  //stores information about joined layers
2332  QgsVectorLayerJoinBuffer* mJoinBuffer;
2333 
2335  QgsExpressionFieldBuffer* mExpressionFieldBuffer;
2336 
2337  //diagram rendering object. 0 if diagram drawing is disabled
2338  QgsDiagramRendererV2* mDiagramRenderer;
2339 
2340  //stores infos about diagram placement (placement type, priority, position distance)
2341  QgsDiagramLayerSettings *mDiagramLayerSettings;
2342 
2343  bool mValidExtent;
2344  bool mLazyExtent;
2345 
2346  // Features in renderer classes counted
2347  bool mSymbolFeatureCounted;
2348 
2349  // Feature counts for each renderer symbol
2350  QMap<QgsSymbolV2*, long> mSymbolFeatureCountMap;
2351 
2353  bool mEditCommandActive;
2354 
2355  QgsFeatureIds mDeletedFids;
2356 
2357  QgsAttributeTableConfig mAttributeTableConfig;
2358 
2359  QMutex mFeatureSourceConstructorMutex;
2360 
2362 };
2363 
2364 #endif
const QSet< QString > & excludeAttributesWMS() const
QgsActionManager * actions()
Get all layer actions defined on this layer.
bool cacheDirty
True if the cached join attributes need to be updated.
Wrapper for iterator of features from vector data provider or vector layer.
static unsigned index
A rectangle specified with double values.
Definition: qgsrectangle.h:35
Base class for all map layer types.
Definition: qgsmaplayer.h:49
QString joinFieldName
Join field in the source layer.
void clearAttributeEditorWidgets()
Clears all the tabs for the attribute editor form.
void setExcludeAttributesWFS(const QSet< QString > &att)
This is an abstract base class for any elements of a drag and drop form.
QString targetFieldName
Join field in the target layer.
GeometryType
Definition: qgis.h:115
ValueRelationData(const QString &layer, const QString &key, const QString &value, bool allowNull, bool orderByValue, bool allowMulti=false, const QString &filterExpression=QString::null)
Modify current selection to include only select features which match.
QgsEditFormConfig::GroupData GroupData
The attribute value should not be changed in the attribute form.
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:439
const QgsFeatureRendererV2 * rendererV2() const
Return const renderer V2.
Manages an editor widget Widget and wrapper share the same parent.
Q_DECL_DEPRECATED void addAttributeEditorWidget(QgsAttributeEditorElement *data)
Adds a tab (for the attribute editor form) holding groups and fields.
void setExcludeAttributesWMS(const QSet< QString > &att)
int joinFieldIndex
Join field index in the source layer.
VertexMarkerType
Editing vertex markers.
SimplifyHint
Simplification flags for fast rendering of features.
Container of fields for a vector layer.
Definition: qgsfield.h:252
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:76
const QSet< QString > & excludeAttributesWFS() const
Q_DECL_DEPRECATED void setEditForm(const QString &ui)
Set edit form.
WkbType
Used for symbology operations.
Definition: qgis.h:61
Set selection, removing any existing selection.
bool memoryCache
True if the join is cached in virtual memory.
int targetFieldIndex
Join field index in the target layer.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:187
Q_DECL_DEPRECATED void setFieldEditable(int idx, bool editable)
Set edit widget editable.
Q_DECL_DEPRECATED const QString editorWidgetV2(const QString &fieldName) const
Get the id for the editor widget used to represent the field at the given index.
QgsAttributeList pendingPkAttributesList() const
Returns list of attributes making up the primary key Alias for pkAttributeList(). ...
Q_DECL_DEPRECATED const QgsEditorWidgetConfig editorWidgetV2Config(int fieldIdx) const
Get the configuration for the editor widget used to represent the field at the given index...
QgsGeometryCache * cache()
Evaluates and returns the diagram settings relating to a diagram for a specific feature.
QgsEditFormConfig * editFormConfig() const
Get the configuration of the form used to represent this vector layer.
Manages joined fields for a vector layer.
QgsFields fields() const
Returns the list of fields of this layer.
Q_DECL_DEPRECATED void setEditorWidgetV2(int attrIdx, const QString &widgetType)
Set the editor widget type for a field.
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:34
SnappingType
Snap to vertex, to segment or both.
Definition: qgssnapper.h:67
QString prefix
An optional prefix.
QgsFeatureRendererV2 * rendererV2()
Return renderer V2.
QgsVectorLayerEditBuffer * editBuffer()
Buffer with uncommitted editing operations. Only valid after editing has been turned on...
void setJoinFieldNamesSubset(QStringList *fieldNamesSubset)
Set subset of fields to be used from joined layer.
QVariantMap QgsEditorWidgetConfig
Holds a set of configuration parameters for a editor widget wrapper.
Q_DECL_DEPRECATED void setLabelOnTop(int idx, bool onTop)
Label widget on top.
Q_DECL_DEPRECATED QList< QgsAttributeEditorElement *> attributeEditorElements()
Returns a list of tabs holding groups and fields.
The attribute value should not be shown in the attribute form.
Q_DECL_DEPRECATED RangeData(const QVariant &theMin, const QVariant &theMax, const QVariant &theStep)
Q_DECL_DEPRECATED void setFeatureFormSuppress(QgsVectorLayer::FeatureFormSuppress s)
Set type of feature form pop-up suppression after feature creation (overrides app setting) ...
Point geometry type, with support for z-dimension and m-values.
Definition: qgspointv2.h:34
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Q_DECL_DEPRECATED const QgsEditorWidgetConfig editorWidgetV2Config(const QString &fieldName) const
Get the configuration for the editor widget used to represent the field with the given name...
const QgsDiagramRendererV2 * diagramRenderer() const
Q_DECL_DEPRECATED void setEditFormInit(const QString &function)
Set python function for edit form initialization.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QgsAttributeEditorElement * attributeEditorElementFromDomElement(QDomElement &elem, QObject *parent)
Convert a saved attribute editor element into a AttributeEditor structure as it&#39;s used internally...
Q_DECL_DEPRECATED bool fieldEditable(int idx)
Is edit widget editable.
Q_DECL_DEPRECATED QgsVectorLayer::FeatureFormSuppress featureFormSuppress() const
Type of feature form pop-up suppression after feature creation (overrides app setting) ...
Storage and management of actions associated with a layer.
QSharedPointer< QStringList > joinFieldsSubset
Subset of fields to use from joined layer.
QgsAttributeList attributeList() const
Returns list of attribute indexes.
QgsAttributeList pendingAllAttributesList() const
Returns list of attribute indexes.
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:44
Q_DECL_DEPRECATED bool labelOnTop(int idx)
Label widget on top.
const QgsAbstractVectorLayerLabeling * labeling() const
Access to labeling configuration.
Q_DECL_DEPRECATED QString editForm() const
Get edit form.
QString annotationForm() const
Get annotation form.
A class to represent a point.
Definition: qgspoint.h:117
Q_DECL_DEPRECATED void setEditorWidgetV2Config(int attrIdx, const QgsEditorWidgetConfig &config)
Set the editor widget config for a field.
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings for fast rendering of features.
QgsVectorLayerJoinBuffer * joinBuffer()
Acccessor to the join buffer object.
Partial snapshot of vector layer&#39;s state (only the members necessary for access to features) ...
A class to render labels.
Definition: qgslabel.h:51
Stores the settings for rendering of all diagrams for a layer.
long pendingFeatureCount() const
Returns feature count including changes which have not yet been committed Alias for featureCount()...
uuid generator - readonly and automatically intialized
SelectBehaviour
Selection behaviour.
Q_DECL_DEPRECATED QString editFormInit() const
Get python function for edit form initialization.
Add selection to current selection.
This class contains information how to simplify geometries fetched from a vector layer.
Contains information about the context of a rendering operation.
Buffers information about expression fields for a vector layer.
QHash< QString, QgsAttributes > cachedAttributes
Cache for joined attributes to provide fast lookup (size is 0 if no memory caching) ...
const QgsDiagramLayerSettings * diagramLayerSettings() const
This class manages a set of relations between layers.
The QgsConditionalLayerStyles class holds conditional style information for a layer.
Q_DECL_DEPRECATED EditorLayout editorLayout()
Get the active layout for the attribute editor for this layer.
Abstract base class - its implementations define different approaches to the labeling of a vector lay...
Class for doing transforms between two map coordinate systems.
void setSimplifyMethod(const QgsVectorSimplifyMethod &simplifyMethod)
Set the simplification settings for fast rendering of features.
qint64 QgsFeatureId
Definition: qgsfeature.h:31
QgsFields pendingFields() const
Returns the list of fields of this layer.
Base class for utility classes that encapsulate information necessary for rendering of map layers...
Remove from current selection.
Q_DECL_DEPRECATED const QString editorWidgetV2(int fieldIdx) const
Get the id for the editor widget used to represent the field at the given index.
QSet< int > QgsAttributeIds
This is a container for configuration of the attribute table.
FeatureFormSuppress
Types of feature form suppression after feature creation.
This is the base class for vector data providers.
Abstract base class for curved geometry type.
Definition: qgscurvev2.h:32
QList< int > QgsAttributeList
Represents a vector layer which manages a vector based data sets.
modularized edit widgets
EditResult
Result of an edit operation.
QString joinLayerId
Source layer.
QStringList * joinFieldNamesSubset() const
Get subset of fields to be used from joined layer.
Q_DECL_DEPRECATED void setEditorLayout(EditorLayout editorLayout)
Set the active layout for the attribute editor for this layer.
value map from an table
Abstract base class for simplify geometries using a specific algorithm.
Aggregate
Available aggregates to calculate.
QgsEditFormConfig::TabData TabData
QList< QgsPointV2 > QgsPointSequenceV2
bool operator==(const QgsVectorJoinInfo &other) const
A bundle of parameters controlling aggregate calculation.
Q_DECL_DEPRECATED RangeData()