QGIS API Documentation  2.17.0-Master (0497e4a)
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 
600  const QList<QgsVectorJoinInfo> vectorJoins() const;
601 
605  virtual QSet<QString> layerDependencies() const;
606 
617  int addExpressionField( const QString& exp, const QgsField& fld );
618 
626  void removeExpressionField( int index );
627 
637  QString expressionField( int index );
638 
648  void updateExpressionField( int index, const QString& exp );
649 
651  QgsLabel *label();
652 
656  const QgsLabel *label() const;
657 
664  QgsActionManager* actions() { return mActions; }
665 
671  int selectedFeatureCount();
672 
683  Q_DECL_DEPRECATED void select( QgsRectangle & rect, bool addToSelection );
684 
694  void selectByRect( QgsRectangle & rect, SelectBehaviour behaviour = SetSelection );
695 
704  void selectByExpression( const QString& expression, SelectBehaviour behaviour = SetSelection );
705 
715  void selectByIds( const QgsFeatureIds &ids, SelectBehaviour behaviour = SetSelection );
716 
729  void modifySelection( QgsFeatureIds selectIds, QgsFeatureIds deselectIds );
730 
732  void invertSelection();
733 
735  void selectAll();
736 
738  QgsFeatureIds allFeatureIds();
739 
747  void invertSelectionInRectangle( QgsRectangle & rect );
748 
757  QgsFeatureList selectedFeatures();
758 
770  QgsFeatureIterator selectedFeaturesIterator( QgsFeatureRequest request = QgsFeatureRequest() );
771 
778  const QgsFeatureIds &selectedFeaturesIds() const;
779 
788  Q_DECL_DEPRECATED void setSelectedFeatures( const QgsFeatureIds &ids );
789 
791  QgsRectangle boundingBoxOfSelected();
792 
797  bool labelsEnabled() const;
798 
803  bool diagramsEnabled() const;
804 
806  void setDiagramRenderer( QgsDiagramRendererV2* r );
807  const QgsDiagramRendererV2* diagramRenderer() const { return mDiagramRenderer; }
808 
809  void setDiagramLayerSettings( const QgsDiagramLayerSettings& s );
810  const QgsDiagramLayerSettings *diagramLayerSettings() const { return mDiagramLayerSettings; }
811 
813  QgsFeatureRendererV2* rendererV2() { return mRendererV2; }
814 
818  const QgsFeatureRendererV2* rendererV2() const { return mRendererV2; }
819 
824  void setRendererV2( QgsFeatureRendererV2* r );
825 
827  QGis::GeometryType geometryType() const;
828 
830  bool hasGeometryType() const;
831 
833  QGis::WkbType wkbType() const;
834 
836  QString providerType() const;
837 
841  virtual bool readXml( const QDomNode& layer_node ) override;
842 
846  virtual bool writeXml( QDomNode & layer_node, QDomDocument & doc ) override;
847 
856  virtual void saveStyleToDatabase( const QString& name, const QString& description,
857  bool useAsDefault, const QString& uiFileContent,
858  QString &msgError );
859 
868  virtual int listStylesInDatabase( QStringList &ids, QStringList &names,
869  QStringList &descriptions, QString &msgError );
870 
874  virtual QString getStyleFromDatabase( const QString& styleId, QString &msgError );
875 
882  virtual QString loadNamedStyle( const QString &theURI, bool &theResultFlag, bool loadFromLocalDb );
883 
888  virtual QString loadNamedStyle( const QString &theURI, bool &theResultFlag ) override;
889 
900  Q_DECL_DEPRECATED virtual bool applyNamedStyle( const QString& namedStyle, QString &errorMsg );
901 
906  QgsAttributeEditorElement* attributeEditorElementFromDomElement( QDomElement &elem, QObject* parent ) { return mEditFormConfig->attributeEditorElementFromDomElement( elem, parent ); }
907 
913  bool readSymbology( const QDomNode& node, QString& errorMessage ) override;
914 
920  bool readStyle( const QDomNode& node, QString& errorMessage ) override;
921 
928  bool writeSymbology( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const override;
929 
936  bool writeStyle( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const override;
937 
938 
946  bool writeSld( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const;
947 
956  bool writeSld( QDomNode& node, QDomDocument& doc, QString& errorMessage, const QgsStringMap& props ) const;
957 
965  bool readSld( const QDomNode& node, QString& errorMessage ) override;
966 
973  long featureCount( QgsSymbolV2* symbol );
974 
985  void setDataSource( const QString& dataSource, const QString& baseName, const QString& provider, bool loadDefaultStyleFlag = false );
986 
992  bool countSymbolFeatures( bool showProgress = true );
993 
1001  virtual bool setSubsetString( const QString& subset );
1002 
1007  virtual QString subsetString();
1008 
1012  QgsFeatureIterator getFeatures( const QgsFeatureRequest& request = QgsFeatureRequest() );
1013 
1019  bool addFeature( QgsFeature& feature, bool alsoUpdateExtent = true );
1020 
1027  bool updateFeature( QgsFeature &f );
1028 
1033  bool insertVertex( double x, double y, QgsFeatureId atFeatureId, int beforeVertex );
1034 
1039  bool moveVertex( double x, double y, QgsFeatureId atFeatureId, int atVertex );
1040 
1046  bool moveVertex( const QgsPointV2& p, QgsFeatureId atFeatureId, int atVertex );
1047 
1051  Q_DECL_DEPRECATED bool deleteVertex( QgsFeatureId atFeatureId, int atVertex );
1052 
1058  //TODO QGIS 3.0 - rename back to deleteVertex
1059  EditResult deleteVertexV2( QgsFeatureId featureId, int vertex );
1060 
1064  bool deleteSelectedFeatures( int *deletedCount = nullptr );
1065 
1078  // TODO QGIS 3.0 returns an enum instead of a magic constant
1079  int addRing( const QList<QgsPoint>& ring, QgsFeatureId* featureId = nullptr );
1080 
1091  // TODO QGIS 3.0 returns an enum instead of a magic constant
1092  int addRing( QgsCurveV2* ring, QgsFeatureId* featureId = nullptr );
1093 
1105  // TODO QGIS 3.0 returns an enum instead of a magic constant
1106  int addPart( const QList<QgsPoint>& ring );
1107 
1120  // TODO QGIS 3.0 returns an enum instead of a magic constant
1121  int addPart( const QgsPointSequenceV2 &ring );
1122 
1124  int addPart( QgsCurveV2* ring );
1125 
1132  int translateFeature( QgsFeatureId featureId, double dx, double dy );
1133 
1141  // TODO QGIS 3.0 returns an enum instead of a magic constant
1142  int splitParts( const QList<QgsPoint>& splitLine, bool topologicalEditing = false );
1143 
1151  // TODO QGIS 3.0 returns an enum instead of a magic constant
1152  int splitFeatures( const QList<QgsPoint>& splitLine, bool topologicalEditing = false );
1153 
1162  Q_DECL_DEPRECATED int removePolygonIntersections( QgsGeometry* geom, const QgsFeatureIds& ignoreFeatures = QgsFeatureIds() );
1163 
1169  int addTopologicalPoints( const QgsGeometry* geom );
1170 
1178  int addTopologicalPoints( const QgsPoint& p );
1179 
1185  int insertSegmentVerticesForSnap( const QList<QgsSnappingResult>& snapResults );
1186 
1190  Q_DECL_DEPRECATED void enableLabels( bool on );
1191 
1195  Q_DECL_DEPRECATED bool hasLabelsEnabled() const;
1196 
1201  const QgsAbstractVectorLayerLabeling* labeling() const { return mLabeling; }
1202 
1207  void setLabeling( QgsAbstractVectorLayerLabeling* labeling );
1208 
1210  virtual bool isEditable() const override;
1211 
1212  virtual bool isSpatial() const override;
1213 
1221  Q_DECL_DEPRECATED virtual bool isReadOnly() const override;
1222 
1224  virtual bool isModified() const;
1225 
1232  bool snapPoint( QgsPoint& point, double tolerance );
1233 
1241  int snapWithContext( const QgsPoint& startPoint,
1242  double snappingTolerance,
1243  QMultiMap < double, QgsSnappingResult > &snappingResults,
1244  QgsSnapper::SnappingType snap_to );
1245 
1247  virtual void reload() override;
1248 
1252  virtual QgsMapLayerRenderer* createMapRenderer( QgsRenderContext& rendererContext ) override;
1253 
1257  bool draw( QgsRenderContext& rendererContext ) override;
1258 
1262  Q_DECL_DEPRECATED void drawLabels( QgsRenderContext& rendererContext ) override;
1263 
1265  QgsRectangle extent() override;
1266 
1273  inline QgsFields fields() const { return mUpdatedFields; }
1274 
1282  inline QgsFields pendingFields() const { return mUpdatedFields; }
1283 
1288  inline QgsAttributeList pendingAllAttributesList() const { return mUpdatedFields.allAttributesList(); }
1289 
1294  inline QgsAttributeList attributeList() const { return mUpdatedFields.allAttributesList(); }
1295 
1300  inline QgsAttributeList pendingPkAttributesList() const { return pkAttributeList(); }
1301 
1303  QgsAttributeList pkAttributeList() const;
1304 
1309  inline long pendingFeatureCount() const { return featureCount(); }
1310 
1315  long featureCount() const;
1316 
1320  bool setReadOnly( bool readonly = true );
1321 
1323  bool changeGeometry( QgsFeatureId fid, QgsGeometry* geom );
1324 
1331  Q_DECL_DEPRECATED bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant& value, bool emitSignal );
1332 
1343  bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant() );
1344 
1348  bool addAttribute( const QgsField &field );
1349 
1351  void addAttributeAlias( int attIndex, const QString& aliasString );
1352 
1354  void remAttributeAlias( int attIndex );
1355 
1361  bool renameAttribute( int attIndex, const QString& newName );
1362 
1368  Q_DECL_DEPRECATED void addAttributeEditorWidget( QgsAttributeEditorElement* data ) {mEditFormConfig->addTab( data );}
1369 
1379  Q_DECL_DEPRECATED const QString editorWidgetV2( int fieldIdx ) const { return mEditFormConfig->widgetType( fieldIdx ); }
1380 
1392  Q_DECL_DEPRECATED const QString editorWidgetV2( const QString& fieldName ) const { return mEditFormConfig->widgetType( fieldName ); }
1393 
1403  Q_DECL_DEPRECATED const QgsEditorWidgetConfig editorWidgetV2Config( int fieldIdx ) const { return mEditFormConfig->widgetConfig( fieldIdx ); }
1404 
1416  Q_DECL_DEPRECATED const QgsEditorWidgetConfig editorWidgetV2Config( const QString& fieldName ) const { return mEditFormConfig->widgetConfig( fieldName ); }
1417 
1423  Q_DECL_DEPRECATED QList< QgsAttributeEditorElement* > attributeEditorElements() { return mEditFormConfig->tabs(); }
1424 
1433  QgsEditFormConfig* editFormConfig() const { return mEditFormConfig; }
1434 
1438  void clearAttributeEditorWidgets() { mEditFormConfig->clearTabs(); }
1439 
1446  QString attributeAlias( int attributeIndex ) const;
1447 
1449  QString attributeDisplayName( int attributeIndex ) const;
1450 
1452  QgsStringMap attributeAliases() const;
1453 
1454  const QSet<QString>& excludeAttributesWMS() const { return mExcludeAttributesWMS; }
1455  void setExcludeAttributesWMS( const QSet<QString>& att ) { mExcludeAttributesWMS = att; }
1456 
1457  const QSet<QString>& excludeAttributesWFS() const { return mExcludeAttributesWFS; }
1458  void setExcludeAttributesWFS( const QSet<QString>& att ) { mExcludeAttributesWFS = att; }
1459 
1461  bool deleteAttribute( int attr );
1462 
1470  bool deleteAttributes( QList<int> attrs );
1471 
1473  bool addFeatures( QgsFeatureList features, bool makeSelected = true );
1474 
1476  bool deleteFeature( QgsFeatureId fid );
1477 
1485  bool deleteFeatures( const QgsFeatureIds& fids );
1486 
1502  bool commitChanges();
1503  const QStringList &commitErrors();
1504 
1508  bool rollBack( bool deleteBuffer = true );
1509 
1515  Q_DECL_DEPRECATED EditType editType( int idx );
1516 
1522  Q_DECL_DEPRECATED void setEditType( int idx, EditType edit );
1523 
1528  Q_DECL_DEPRECATED EditorLayout editorLayout() { return static_cast< EditorLayout >( mEditFormConfig->layout() ); }
1529 
1534  Q_DECL_DEPRECATED void setEditorLayout( EditorLayout editorLayout ) { mEditFormConfig->setLayout( static_cast< QgsEditFormConfig::EditorLayout >( editorLayout ) ); }
1535 
1566  Q_DECL_DEPRECATED void setEditorWidgetV2( int attrIdx, const QString& widgetType ) { mEditFormConfig->setWidgetType( attrIdx, widgetType ); }
1567 
1585  Q_DECL_DEPRECATED void setEditorWidgetV2Config( int attrIdx, const QgsEditorWidgetConfig& config ) { mEditFormConfig->setWidgetConfig( attrIdx, config ); }
1586 
1592  Q_DECL_DEPRECATED void setCheckedState( int idx, const QString& checked, const QString& notChecked );
1593 
1599  Q_DECL_DEPRECATED QString editForm() const { return mEditFormConfig->uiForm(); }
1600 
1605  Q_DECL_DEPRECATED void setEditForm( const QString& ui ) { mEditFormConfig->setUiForm( ui ); }
1606 
1611  Q_DECL_DEPRECATED QgsVectorLayer::FeatureFormSuppress featureFormSuppress() const { return static_cast< FeatureFormSuppress >( mEditFormConfig->suppress() ); }
1612 
1617  Q_DECL_DEPRECATED void setFeatureFormSuppress( QgsVectorLayer::FeatureFormSuppress s ) { mEditFormConfig->setSuppress( static_cast< QgsEditFormConfig::FeatureFormSuppress >( s ) ); }
1618 
1620  QString annotationForm() const { return mAnnotationForm; }
1621 
1623  void setAnnotationForm( const QString& ui );
1624 
1630  Q_DECL_DEPRECATED QString editFormInit() const { return mEditFormConfig->initFunction(); }
1631 
1637  Q_DECL_DEPRECATED void setEditFormInit( const QString& function ) { mEditFormConfig->setInitFunction( function ); }
1638 
1643  Q_DECL_DEPRECATED QMap<QString, QVariant> valueMap( int idx );
1644 
1650  Q_DECL_DEPRECATED RangeData range( int idx );
1651 
1653  ValueRelationData valueRelation( int idx );
1654 
1661  QList<QgsRelation> referencingRelations( int idx );
1662 
1668  Q_DECL_DEPRECATED QString dateFormat( int idx );
1669 
1675  Q_DECL_DEPRECATED QSize widgetSize( int idx );
1676 
1682  Q_DECL_DEPRECATED bool fieldEditable( int idx ) { return !mEditFormConfig->readOnly( idx ); }
1683 
1688  Q_DECL_DEPRECATED bool labelOnTop( int idx ) { return mEditFormConfig->labelOnTop( idx ); }
1689 
1694  Q_DECL_DEPRECATED void setFieldEditable( int idx, bool editable ) { mEditFormConfig->setReadOnly( idx, !editable ); }
1695 
1700  Q_DECL_DEPRECATED void setLabelOnTop( int idx, bool onTop ) { mEditFormConfig->setLabelOnTop( idx, onTop ); }
1701 
1703  QgsVectorLayerEditBuffer* editBuffer() { return mEditBuffer; }
1704 
1709  void beginEditCommand( const QString& text );
1710 
1712  void endEditCommand();
1713 
1715  void destroyEditCommand();
1716 
1718  int fieldNameIndex( const QString& fieldName ) const;
1719 
1722  {
1725  NoMarker
1726  };
1727 
1729  static void drawVertexMarker( double x, double y, QPainter& p, QgsVectorLayer::VertexMarkerType type, int vertexSize );
1730 
1732  void updateFields();
1733 
1735  void createJoinCaches();
1736 
1750  QVariant defaultValue( int index, const QgsFeature& feature = QgsFeature(),
1751  QgsExpressionContext* context = nullptr ) const;
1752 
1761  void setDefaultValueExpression( int index, const QString& expression );
1762 
1771  QString defaultValueExpression( int index ) const;
1772 
1784  void uniqueValues( int index, QList<QVariant> &uniqueValues, int limit = -1 );
1785 
1793  QVariant minimumValue( int index );
1794 
1802  QVariant maximumValue( int index );
1803 
1813  QVariant aggregate( QgsAggregateCalculator::Aggregate aggregate,
1814  const QString& fieldOrExpression,
1816  QgsExpressionContext* context = nullptr,
1817  bool* ok = nullptr );
1818 
1827  QList< QVariant > getValues( const QString &fieldOrExpression, bool &ok, bool selectedOnly = false );
1828 
1839  QList< double > getDoubleValues( const QString &fieldOrExpression, bool &ok, bool selectedOnly = false, int* nullCount = nullptr );
1840 
1842  void setFeatureBlendMode( QPainter::CompositionMode blendMode );
1844  QPainter::CompositionMode featureBlendMode() const;
1845 
1847  void setLayerTransparency( int layerTransparency );
1849  int layerTransparency() const;
1850 
1851  QString metadata() override;
1852 
1854  inline QgsGeometryCache* cache() { return mCache; }
1855 
1859  void setSimplifyMethod( const QgsVectorSimplifyMethod& simplifyMethod ) { mSimplifyMethod = simplifyMethod; }
1863  inline const QgsVectorSimplifyMethod& simplifyMethod() const { return mSimplifyMethod; }
1864 
1869  bool simplifyDrawingCanbeApplied( const QgsRenderContext& renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint ) const;
1870 
1878  QgsConditionalLayerStyles *conditionalStyles() const;
1879 
1884  QgsAttributeTableConfig attributeTableConfig() const;
1885 
1890  void setAttributeTableConfig( const QgsAttributeTableConfig& attributeTableConfig );
1891 
1892  public slots:
1900  void select( QgsFeatureId featureId );
1901 
1909  void select( const QgsFeatureIds& featureIds );
1910 
1918  void deselect( const QgsFeatureId featureId );
1919 
1927  void deselect( const QgsFeatureIds& featureIds );
1928 
1934  void removeSelection();
1935 
1939  virtual void updateExtents();
1940 
1942  void checkJoinLayerRemove( const QString& theLayerId );
1943 
1950  bool startEditing();
1951 
1952 
1953  protected slots:
1954  void invalidateSymbolCountedFlag();
1955 
1956  signals:
1957 
1965  void selectionChanged( const QgsFeatureIds& selected, const QgsFeatureIds& deselected, const bool clearAndSelect );
1966 
1968  void selectionChanged();
1969 
1971  void layerModified();
1972 
1974  void beforeModifiedCheck() const;
1975 
1977  void beforeEditingStarted();
1978 
1980  void editingStarted();
1981 
1983  void editingStopped();
1984 
1986  void beforeCommitChanges();
1987 
1989  void beforeRollBack();
1990 
1999  void attributeAdded( int idx );
2000 
2007  void beforeAddingExpressionField( const QString& fieldName );
2008 
2017  void attributeDeleted( int idx );
2018 
2025  void beforeRemovingExpressionField( int idx );
2026 
2032  void featureAdded( QgsFeatureId fid );
2033 
2042  void featureDeleted( QgsFeatureId fid );
2043 
2053  void featuresDeleted( const QgsFeatureIds& fids );
2054 
2059  void updatedFields();
2060 
2064  void layerDeleted();
2065 
2074  void attributeValueChanged( QgsFeatureId fid, int idx, const QVariant& value );
2075 
2083  void geometryChanged( QgsFeatureId fid, QgsGeometry& geometry );
2084 
2086  void committedAttributesDeleted( const QString& layerId, const QgsAttributeList& deletedAttributes );
2088  void committedAttributesAdded( const QString& layerId, const QList<QgsField>& addedAttributes );
2090  void committedFeaturesAdded( const QString& layerId, const QgsFeatureList& addedFeatures );
2092  void committedFeaturesRemoved( const QString& layerId, const QgsFeatureIds& deletedFeatureIds );
2094  void committedAttributeValuesChanges( const QString& layerId, const QgsChangedAttributesMap& changedAttributesValues );
2096  void committedGeometriesChanges( const QString& layerId, const QgsGeometryMap& changedGeometries );
2097 
2099  Q_DECL_DEPRECATED void saveLayerToProject();
2100 
2102  void labelingFontNotFound( QgsVectorLayer* layer, const QString& fontfamily );
2103 
2105  void featureBlendModeChanged( QPainter::CompositionMode blendMode );
2106 
2108  void layerTransparencyChanged( int layerTransparency );
2109 
2115  void editCommandStarted( const QString& text );
2116 
2122  void editCommandEnded();
2123 
2129  void editCommandDestroyed();
2130 
2140  void readCustomSymbology( const QDomElement& element, QString& errorMessage );
2141 
2151  void writeCustomSymbology( QDomElement& element, QDomDocument& doc, QString& errorMessage ) const;
2152 
2156  void raiseError( const QString& msg );
2157 
2158  private slots:
2159  void onJoinedFieldsChanged();
2160  void onFeatureDeleted( QgsFeatureId fid );
2161 
2162  protected:
2164  void setExtent( const QgsRectangle &rect ) override;
2165 
2166  private: // Private methods
2167 
2169  QgsVectorLayer( const QgsVectorLayer & rhs );
2170 
2172  QgsVectorLayer & operator=( QgsVectorLayer const & rhs );
2173 
2174 
2179  bool setDataProvider( QString const & provider );
2180 
2182  QgsFeatureId findFreeId();
2183 
2192  void snapToGeometry( const QgsPoint& startPoint,
2193  QgsFeatureId featureId,
2194  const QgsGeometry *geom,
2195  double sqrSnappingTolerance,
2196  QMultiMap<double, QgsSnappingResult>& snappingResults,
2197  QgsSnapper::SnappingType snap_to ) const;
2198 
2200  //void addJoinedAttributes( QgsFeature& f, bool all = false );
2201 
2203  void readSldLabeling( const QDomNode& node );
2204 
2205  private: // Private attributes
2206 
2207  QgsConditionalLayerStyles * mConditionalStyles;
2208 
2210  QgsVectorDataProvider *mDataProvider;
2211 
2213  QString mDisplayField;
2214 
2216  QString mDisplayExpression;
2217 
2219  QString mProviderKey;
2220 
2222  QgsActionManager* mActions;
2223 
2225  bool mReadOnly;
2226 
2231  QgsFeatureIds mSelectedFeatureIds;
2232 
2234  QgsFields mUpdatedFields;
2235 
2237  QgsStringMap mAttributeAliasMap;
2238 
2240  QgsStringMap mDefaultExpressionMap;
2241 
2243  QgsEditFormConfig* mEditFormConfig;
2244 
2246  QSet<QString> mExcludeAttributesWMS;
2247 
2249  QSet<QString> mExcludeAttributesWFS;
2250 
2252  QGis::WkbType mWkbType;
2253 
2255  QgsFeatureRendererV2 *mRendererV2;
2256 
2258  QgsVectorSimplifyMethod mSimplifyMethod;
2259 
2261  QgsLabel *mLabel;
2262 
2264  bool mLabelOn;
2265 
2267  QgsAbstractVectorLayerLabeling* mLabeling;
2268 
2270  bool mLabelFontNotFoundNotified;
2271 
2273  QPainter::CompositionMode mFeatureBlendMode;
2274 
2276  int mLayerTransparency;
2277 
2279  bool mVertexMarkerOnlyForSelection;
2280 
2281  QStringList mCommitErrors;
2282 
2284  QString mAnnotationForm;
2285 
2287  QgsGeometryCache* mCache;
2288 
2290  QgsVectorLayerEditBuffer* mEditBuffer;
2292 
2293  //stores information about joined layers
2294  QgsVectorLayerJoinBuffer* mJoinBuffer;
2295 
2297  QgsExpressionFieldBuffer* mExpressionFieldBuffer;
2298 
2299  //diagram rendering object. 0 if diagram drawing is disabled
2300  QgsDiagramRendererV2* mDiagramRenderer;
2301 
2302  //stores infos about diagram placement (placement type, priority, position distance)
2303  QgsDiagramLayerSettings *mDiagramLayerSettings;
2304 
2305  bool mValidExtent;
2306  bool mLazyExtent;
2307 
2308  // Features in renderer classes counted
2309  bool mSymbolFeatureCounted;
2310 
2311  // Feature counts for each renderer symbol
2312  QMap<QgsSymbolV2*, long> mSymbolFeatureCountMap;
2313 
2315  bool mEditCommandActive;
2316 
2317  QgsFeatureIds mDeletedFids;
2318 
2319  QgsAttributeTableConfig mAttributeTableConfig;
2320 
2321  QMutex mFeatureSourceConstructorMutex;
2322 
2324 };
2325 
2326 #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.
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()