QGIS API Documentation  2.17.0-Master (bf77d09)
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  const QString displayField() const;
560 
567  void setDisplayExpression( const QString &displayExpression );
568 
575  const QString displayExpression();
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  bool writeSld( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const;
939  bool readSld( const QDomNode& node, QString& errorMessage ) override;
940 
947  long featureCount( QgsSymbolV2* symbol );
948 
959  void setDataSource( const QString& dataSource, const QString& baseName, const QString& provider, bool loadDefaultStyleFlag = false );
960 
966  bool countSymbolFeatures( bool showProgress = true );
967 
975  virtual bool setSubsetString( const QString& subset );
976 
981  virtual QString subsetString();
982 
986  QgsFeatureIterator getFeatures( const QgsFeatureRequest& request = QgsFeatureRequest() );
987 
993  bool addFeature( QgsFeature& feature, bool alsoUpdateExtent = true );
994 
1001  bool updateFeature( QgsFeature &f );
1002 
1007  bool insertVertex( double x, double y, QgsFeatureId atFeatureId, int beforeVertex );
1008 
1013  bool moveVertex( double x, double y, QgsFeatureId atFeatureId, int atVertex );
1014 
1020  bool moveVertex( const QgsPointV2& p, QgsFeatureId atFeatureId, int atVertex );
1021 
1025  Q_DECL_DEPRECATED bool deleteVertex( QgsFeatureId atFeatureId, int atVertex );
1026 
1032  //TODO QGIS 3.0 - rename back to deleteVertex
1033  EditResult deleteVertexV2( QgsFeatureId featureId, int vertex );
1034 
1038  bool deleteSelectedFeatures( int *deletedCount = nullptr );
1039 
1052  // TODO QGIS 3.0 returns an enum instead of a magic constant
1053  int addRing( const QList<QgsPoint>& ring, QgsFeatureId* featureId = nullptr );
1054 
1065  // TODO QGIS 3.0 returns an enum instead of a magic constant
1066  int addRing( QgsCurveV2* ring, QgsFeatureId* featureId = nullptr );
1067 
1079  // TODO QGIS 3.0 returns an enum instead of a magic constant
1080  int addPart( const QList<QgsPoint>& ring );
1081 
1094  // TODO QGIS 3.0 returns an enum instead of a magic constant
1095  int addPart( const QgsPointSequenceV2 &ring );
1096 
1098  int addPart( QgsCurveV2* ring );
1099 
1106  int translateFeature( QgsFeatureId featureId, double dx, double dy );
1107 
1115  // TODO QGIS 3.0 returns an enum instead of a magic constant
1116  int splitParts( const QList<QgsPoint>& splitLine, bool topologicalEditing = false );
1117 
1125  // TODO QGIS 3.0 returns an enum instead of a magic constant
1126  int splitFeatures( const QList<QgsPoint>& splitLine, bool topologicalEditing = false );
1127 
1136  Q_DECL_DEPRECATED int removePolygonIntersections( QgsGeometry* geom, const QgsFeatureIds& ignoreFeatures = QgsFeatureIds() );
1137 
1143  int addTopologicalPoints( const QgsGeometry* geom );
1144 
1152  int addTopologicalPoints( const QgsPoint& p );
1153 
1159  int insertSegmentVerticesForSnap( const QList<QgsSnappingResult>& snapResults );
1160 
1164  Q_DECL_DEPRECATED void enableLabels( bool on );
1165 
1169  Q_DECL_DEPRECATED bool hasLabelsEnabled() const;
1170 
1175  const QgsAbstractVectorLayerLabeling* labeling() const { return mLabeling; }
1176 
1181  void setLabeling( QgsAbstractVectorLayerLabeling* labeling );
1182 
1184  virtual bool isEditable() const override;
1185 
1186  virtual bool isSpatial() const override;
1187 
1195  Q_DECL_DEPRECATED virtual bool isReadOnly() const override;
1196 
1198  virtual bool isModified() const;
1199 
1206  bool snapPoint( QgsPoint& point, double tolerance );
1207 
1215  int snapWithContext( const QgsPoint& startPoint,
1216  double snappingTolerance,
1217  QMultiMap < double, QgsSnappingResult > &snappingResults,
1218  QgsSnapper::SnappingType snap_to );
1219 
1221  virtual void reload() override;
1222 
1226  virtual QgsMapLayerRenderer* createMapRenderer( QgsRenderContext& rendererContext ) override;
1227 
1231  bool draw( QgsRenderContext& rendererContext ) override;
1232 
1236  Q_DECL_DEPRECATED void drawLabels( QgsRenderContext& rendererContext ) override;
1237 
1239  QgsRectangle extent() override;
1240 
1247  inline QgsFields fields() const { return mUpdatedFields; }
1248 
1256  inline QgsFields pendingFields() const { return mUpdatedFields; }
1257 
1262  inline QgsAttributeList pendingAllAttributesList() const { return mUpdatedFields.allAttributesList(); }
1263 
1268  inline QgsAttributeList attributeList() const { return mUpdatedFields.allAttributesList(); }
1269 
1274  inline QgsAttributeList pendingPkAttributesList() const { return pkAttributeList(); }
1275 
1277  QgsAttributeList pkAttributeList() const;
1278 
1283  inline long pendingFeatureCount() const { return featureCount(); }
1284 
1289  long featureCount() const;
1290 
1294  bool setReadOnly( bool readonly = true );
1295 
1297  bool changeGeometry( QgsFeatureId fid, QgsGeometry* geom );
1298 
1305  Q_DECL_DEPRECATED bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant& value, bool emitSignal );
1306 
1317  bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant() );
1318 
1322  bool addAttribute( const QgsField &field );
1323 
1325  void addAttributeAlias( int attIndex, const QString& aliasString );
1326 
1328  void remAttributeAlias( int attIndex );
1329 
1335  bool renameAttribute( int attIndex, const QString& newName );
1336 
1342  Q_DECL_DEPRECATED void addAttributeEditorWidget( QgsAttributeEditorElement* data ) {mEditFormConfig->addTab( data );}
1343 
1353  Q_DECL_DEPRECATED const QString editorWidgetV2( int fieldIdx ) const { return mEditFormConfig->widgetType( fieldIdx ); }
1354 
1366  Q_DECL_DEPRECATED const QString editorWidgetV2( const QString& fieldName ) const { return mEditFormConfig->widgetType( fieldName ); }
1367 
1377  Q_DECL_DEPRECATED const QgsEditorWidgetConfig editorWidgetV2Config( int fieldIdx ) const { return mEditFormConfig->widgetConfig( fieldIdx ); }
1378 
1390  Q_DECL_DEPRECATED const QgsEditorWidgetConfig editorWidgetV2Config( const QString& fieldName ) const { return mEditFormConfig->widgetConfig( fieldName ); }
1391 
1397  Q_DECL_DEPRECATED QList< QgsAttributeEditorElement* > attributeEditorElements() { return mEditFormConfig->tabs(); }
1398 
1407  QgsEditFormConfig* editFormConfig() const { return mEditFormConfig; }
1408 
1412  void clearAttributeEditorWidgets() { mEditFormConfig->clearTabs(); }
1413 
1420  QString attributeAlias( int attributeIndex ) const;
1421 
1423  QString attributeDisplayName( int attributeIndex ) const;
1424 
1425  const QMap< QString, QString >& attributeAliases() const { return mAttributeAliasMap; }
1426 
1427  const QSet<QString>& excludeAttributesWMS() const { return mExcludeAttributesWMS; }
1428  void setExcludeAttributesWMS( const QSet<QString>& att ) { mExcludeAttributesWMS = att; }
1429 
1430  const QSet<QString>& excludeAttributesWFS() const { return mExcludeAttributesWFS; }
1431  void setExcludeAttributesWFS( const QSet<QString>& att ) { mExcludeAttributesWFS = att; }
1432 
1434  bool deleteAttribute( int attr );
1435 
1443  bool deleteAttributes( QList<int> attrs );
1444 
1446  bool addFeatures( QgsFeatureList features, bool makeSelected = true );
1447 
1449  bool deleteFeature( QgsFeatureId fid );
1450 
1458  bool deleteFeatures( const QgsFeatureIds& fids );
1459 
1475  bool commitChanges();
1476  const QStringList &commitErrors();
1477 
1481  bool rollBack( bool deleteBuffer = true );
1482 
1488  Q_DECL_DEPRECATED EditType editType( int idx );
1489 
1495  Q_DECL_DEPRECATED void setEditType( int idx, EditType edit );
1496 
1501  Q_DECL_DEPRECATED EditorLayout editorLayout() { return static_cast< EditorLayout >( mEditFormConfig->layout() ); }
1502 
1507  Q_DECL_DEPRECATED void setEditorLayout( EditorLayout editorLayout ) { mEditFormConfig->setLayout( static_cast< QgsEditFormConfig::EditorLayout >( editorLayout ) ); }
1508 
1539  Q_DECL_DEPRECATED void setEditorWidgetV2( int attrIdx, const QString& widgetType ) { mEditFormConfig->setWidgetType( attrIdx, widgetType ); }
1540 
1558  Q_DECL_DEPRECATED void setEditorWidgetV2Config( int attrIdx, const QgsEditorWidgetConfig& config ) { mEditFormConfig->setWidgetConfig( attrIdx, config ); }
1559 
1565  Q_DECL_DEPRECATED void setCheckedState( int idx, const QString& checked, const QString& notChecked );
1566 
1572  Q_DECL_DEPRECATED QString editForm() const { return mEditFormConfig->uiForm(); }
1573 
1578  Q_DECL_DEPRECATED void setEditForm( const QString& ui ) { mEditFormConfig->setUiForm( ui ); }
1579 
1584  Q_DECL_DEPRECATED QgsVectorLayer::FeatureFormSuppress featureFormSuppress() const { return static_cast< FeatureFormSuppress >( mEditFormConfig->suppress() ); }
1585 
1590  Q_DECL_DEPRECATED void setFeatureFormSuppress( QgsVectorLayer::FeatureFormSuppress s ) { mEditFormConfig->setSuppress( static_cast< QgsEditFormConfig::FeatureFormSuppress >( s ) ); }
1591 
1593  QString annotationForm() const { return mAnnotationForm; }
1594 
1596  void setAnnotationForm( const QString& ui );
1597 
1603  Q_DECL_DEPRECATED QString editFormInit() const { return mEditFormConfig->initFunction(); }
1604 
1610  Q_DECL_DEPRECATED void setEditFormInit( const QString& function ) { mEditFormConfig->setInitFunction( function ); }
1611 
1616  Q_DECL_DEPRECATED QMap<QString, QVariant> valueMap( int idx );
1617 
1623  Q_DECL_DEPRECATED RangeData range( int idx );
1624 
1626  ValueRelationData valueRelation( int idx );
1627 
1634  QList<QgsRelation> referencingRelations( int idx );
1635 
1641  Q_DECL_DEPRECATED QString dateFormat( int idx );
1642 
1648  Q_DECL_DEPRECATED QSize widgetSize( int idx );
1649 
1655  Q_DECL_DEPRECATED bool fieldEditable( int idx ) { return !mEditFormConfig->readOnly( idx ); }
1656 
1661  Q_DECL_DEPRECATED bool labelOnTop( int idx ) { return mEditFormConfig->labelOnTop( idx ); }
1662 
1667  Q_DECL_DEPRECATED void setFieldEditable( int idx, bool editable ) { mEditFormConfig->setReadOnly( idx, !editable ); }
1668 
1673  Q_DECL_DEPRECATED void setLabelOnTop( int idx, bool onTop ) { mEditFormConfig->setLabelOnTop( idx, onTop ); }
1674 
1676  QgsVectorLayerEditBuffer* editBuffer() { return mEditBuffer; }
1677 
1682  void beginEditCommand( const QString& text );
1683 
1685  void endEditCommand();
1686 
1688  void destroyEditCommand();
1689 
1691  int fieldNameIndex( const QString& fieldName ) const;
1692 
1695  {
1698  NoMarker
1699  };
1700 
1702  static void drawVertexMarker( double x, double y, QPainter& p, QgsVectorLayer::VertexMarkerType type, int vertexSize );
1703 
1705  void updateFields();
1706 
1708  void createJoinCaches();
1709 
1715  void uniqueValues( int index, QList<QVariant> &uniqueValues, int limit = -1 );
1716 
1718  QVariant minimumValue( int index );
1719 
1721  QVariant maximumValue( int index );
1722 
1732  QVariant aggregate( QgsAggregateCalculator::Aggregate aggregate,
1733  const QString& fieldOrExpression,
1735  QgsExpressionContext* context = nullptr,
1736  bool* ok = nullptr );
1737 
1746  QList< QVariant > getValues( const QString &fieldOrExpression, bool &ok, bool selectedOnly = false );
1747 
1758  QList< double > getDoubleValues( const QString &fieldOrExpression, bool &ok, bool selectedOnly = false, int* nullCount = nullptr );
1759 
1761  void setFeatureBlendMode( QPainter::CompositionMode blendMode );
1763  QPainter::CompositionMode featureBlendMode() const;
1764 
1766  void setLayerTransparency( int layerTransparency );
1768  int layerTransparency() const;
1769 
1770  QString metadata() override;
1771 
1773  inline QgsGeometryCache* cache() { return mCache; }
1774 
1778  void setSimplifyMethod( const QgsVectorSimplifyMethod& simplifyMethod ) { mSimplifyMethod = simplifyMethod; }
1782  inline const QgsVectorSimplifyMethod& simplifyMethod() const { return mSimplifyMethod; }
1783 
1788  bool simplifyDrawingCanbeApplied( const QgsRenderContext& renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint ) const;
1789 
1797  QgsConditionalLayerStyles *conditionalStyles() const;
1798 
1803  QgsAttributeTableConfig attributeTableConfig() const;
1804 
1809  void setAttributeTableConfig( const QgsAttributeTableConfig& attributeTableConfig );
1810 
1811  public slots:
1819  void select( QgsFeatureId featureId );
1820 
1828  void select( const QgsFeatureIds& featureIds );
1829 
1837  void deselect( const QgsFeatureId featureId );
1838 
1846  void deselect( const QgsFeatureIds& featureIds );
1847 
1853  void removeSelection();
1854 
1858  virtual void updateExtents();
1859 
1861  void checkJoinLayerRemove( const QString& theLayerId );
1862 
1869  bool startEditing();
1870 
1871 
1872  protected slots:
1873  void invalidateSymbolCountedFlag();
1874 
1875  signals:
1876 
1884  void selectionChanged( const QgsFeatureIds& selected, const QgsFeatureIds& deselected, const bool clearAndSelect );
1885 
1887  void selectionChanged();
1888 
1890  void layerModified();
1891 
1893  void beforeModifiedCheck() const;
1894 
1896  void beforeEditingStarted();
1897 
1899  void editingStarted();
1900 
1902  void editingStopped();
1903 
1905  void beforeCommitChanges();
1906 
1908  void beforeRollBack();
1909 
1918  void attributeAdded( int idx );
1919 
1926  void beforeAddingExpressionField( const QString& fieldName );
1927 
1936  void attributeDeleted( int idx );
1937 
1944  void beforeRemovingExpressionField( int idx );
1945 
1951  void featureAdded( QgsFeatureId fid );
1952 
1961  void featureDeleted( QgsFeatureId fid );
1962 
1972  void featuresDeleted( const QgsFeatureIds& fids );
1973 
1978  void updatedFields();
1979 
1983  void layerDeleted();
1984 
1993  void attributeValueChanged( QgsFeatureId fid, int idx, const QVariant& value );
1994 
2002  void geometryChanged( QgsFeatureId fid, QgsGeometry& geometry );
2003 
2005  void committedAttributesDeleted( const QString& layerId, const QgsAttributeList& deletedAttributes );
2007  void committedAttributesAdded( const QString& layerId, const QList<QgsField>& addedAttributes );
2009  void committedFeaturesAdded( const QString& layerId, const QgsFeatureList& addedFeatures );
2011  void committedFeaturesRemoved( const QString& layerId, const QgsFeatureIds& deletedFeatureIds );
2013  void committedAttributeValuesChanges( const QString& layerId, const QgsChangedAttributesMap& changedAttributesValues );
2015  void committedGeometriesChanges( const QString& layerId, const QgsGeometryMap& changedGeometries );
2016 
2018  Q_DECL_DEPRECATED void saveLayerToProject();
2019 
2021  void labelingFontNotFound( QgsVectorLayer* layer, const QString& fontfamily );
2022 
2024  void featureBlendModeChanged( QPainter::CompositionMode blendMode );
2025 
2027  void layerTransparencyChanged( int layerTransparency );
2028 
2034  void editCommandStarted( const QString& text );
2035 
2041  void editCommandEnded();
2042 
2048  void editCommandDestroyed();
2049 
2059  void readCustomSymbology( const QDomElement& element, QString& errorMessage );
2060 
2070  void writeCustomSymbology( QDomElement& element, QDomDocument& doc, QString& errorMessage ) const;
2071 
2075  void raiseError( const QString& msg );
2076 
2077  private slots:
2078  void onJoinedFieldsChanged();
2079  void onFeatureDeleted( QgsFeatureId fid );
2080 
2081  protected:
2083  void setExtent( const QgsRectangle &rect ) override;
2084 
2085  private: // Private methods
2086 
2088  QgsVectorLayer( const QgsVectorLayer & rhs );
2089 
2091  QgsVectorLayer & operator=( QgsVectorLayer const & rhs );
2092 
2093 
2098  bool setDataProvider( QString const & provider );
2099 
2101  QgsFeatureId findFreeId();
2102 
2111  void snapToGeometry( const QgsPoint& startPoint,
2112  QgsFeatureId featureId,
2113  const QgsGeometry *geom,
2114  double sqrSnappingTolerance,
2115  QMultiMap<double, QgsSnappingResult>& snappingResults,
2116  QgsSnapper::SnappingType snap_to ) const;
2117 
2119  //void addJoinedAttributes( QgsFeature& f, bool all = false );
2120 
2122  void readSldLabeling( const QDomNode& node );
2123 
2124  private: // Private attributes
2125 
2126  QgsConditionalLayerStyles * mConditionalStyles;
2127 
2129  QgsVectorDataProvider *mDataProvider;
2130 
2132  QString mDisplayField;
2133 
2135  QString mDisplayExpression;
2136 
2138  QString mProviderKey;
2139 
2141  QgsActionManager* mActions;
2142 
2144  bool mReadOnly;
2145 
2150  QgsFeatureIds mSelectedFeatureIds;
2151 
2153  QgsFields mUpdatedFields;
2154 
2156  QMap< QString, QString > mAttributeAliasMap;
2157 
2159  QgsEditFormConfig* mEditFormConfig;
2160 
2162  QSet<QString> mExcludeAttributesWMS;
2163 
2165  QSet<QString> mExcludeAttributesWFS;
2166 
2168  QGis::WkbType mWkbType;
2169 
2171  QgsFeatureRendererV2 *mRendererV2;
2172 
2174  QgsVectorSimplifyMethod mSimplifyMethod;
2175 
2177  QgsLabel *mLabel;
2178 
2180  bool mLabelOn;
2181 
2183  QgsAbstractVectorLayerLabeling* mLabeling;
2184 
2186  bool mLabelFontNotFoundNotified;
2187 
2189  QPainter::CompositionMode mFeatureBlendMode;
2190 
2192  int mLayerTransparency;
2193 
2195  bool mVertexMarkerOnlyForSelection;
2196 
2197  QStringList mCommitErrors;
2198 
2200  QString mAnnotationForm;
2201 
2203  QgsGeometryCache* mCache;
2204 
2206  QgsVectorLayerEditBuffer* mEditBuffer;
2208 
2209  //stores information about joined layers
2210  QgsVectorLayerJoinBuffer* mJoinBuffer;
2211 
2213  QgsExpressionFieldBuffer* mExpressionFieldBuffer;
2214 
2215  //diagram rendering object. 0 if diagram drawing is disabled
2216  QgsDiagramRendererV2* mDiagramRenderer;
2217 
2218  //stores infos about diagram placement (placement type, priority, position distance)
2219  QgsDiagramLayerSettings *mDiagramLayerSettings;
2220 
2221  bool mValidExtent;
2222  bool mLazyExtent;
2223 
2224  // Features in renderer classes counted
2225  bool mSymbolFeatureCounted;
2226 
2227  // Feature counts for each renderer symbol
2228  QMap<QgsSymbolV2*, long> mSymbolFeatureCountMap;
2229 
2231  bool mEditCommandActive;
2232 
2233  QgsFeatureIds mDeletedFids;
2234 
2235  QgsAttributeTableConfig mAttributeTableConfig;
2236 
2237  QMutex mFeatureSourceConstructorMutex;
2238 
2240 };
2241 
2242 #endif
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.
QString annotationForm() const
Get annotation form.
static unsigned index
A rectangle specified with double values.
Definition: qgsrectangle.h:35
Base class for all map layer types.
Definition: qgsmaplayer.h:49
QgsAttributeList attributeList() const
Returns list of attribute indexes.
QString joinFieldName
Join field in the source layer.
const QSet< QString > & excludeAttributesWMS() const
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.
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.
QgsEditFormConfig::GroupData GroupData
The attribute value should not be changed in the attribute form.
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:439
QgsFields fields() const
Returns the list of fields of this layer.
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.
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings for fast rendering of features.
QgsAttributeList pendingPkAttributesList() const
Returns list of attributes making up the primary key Alias for pkAttributeList(). ...
VertexMarkerType
Editing vertex markers.
SimplifyHint
Simplification flags for fast rendering of features.
Container of fields for a vector layer.
Definition: qgsfield.h:193
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:76
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
QgsEditFormConfig * editFormConfig() const
Get the configuration of the form used to represent this vector layer.
const QgsDiagramLayerSettings * diagramLayerSettings() const
Q_DECL_DEPRECATED void setFieldEditable(int idx, bool editable)
Set edit widget editable.
QgsGeometryCache * cache()
Evaluates and returns the diagram settings relating to a diagram for a specific feature.
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...
Manages joined fields for a vector layer.
Q_DECL_DEPRECATED void setEditorWidgetV2(int attrIdx, const QString &widgetType)
Set the editor widget type for a field.
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.
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.
QgsFields pendingFields() const
Returns the list of fields of this layer.
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.
bool operator==(const QgsVectorJoinInfo &other) const
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.
const QgsAbstractVectorLayerLabeling * labeling() const
Access to labeling configuration.
The attribute value should not be shown in the attribute form.
const QSet< QString > & excludeAttributesWFS() const
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 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.
Storage and management of actions associated with a layer.
QSharedPointer< QStringList > joinFieldsSubset
Subset of fields to use from joined layer.
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 QgsFeatureRendererV2 * rendererV2() const
Return const renderer V2.
const QMap< QString, QString > & attributeAliases() const
const QgsDiagramRendererV2 * diagramRenderer() const
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.
QgsAttributeList pendingAllAttributesList() const
Returns list of attribute indexes.
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.
uuid generator - readonly and automatically intialized
SelectBehaviour
Selection behaviour.
long pendingFeatureCount() const
Returns feature count including changes which have not yet been committed Alias for featureCount()...
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) ...
Q_DECL_DEPRECATED QString editFormInit() const
Get python function for edit form initialization.
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...
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
Q_DECL_DEPRECATED QgsVectorLayer::FeatureFormSuppress featureFormSuppress() const
Type of feature form pop-up suppression after feature creation (overrides app setting) ...
Base class for utility classes that encapsulate information necessary for rendering of map layers...
Remove from current selection.
QStringList * joinFieldNamesSubset() const
Get subset of fields to be used from joined layer.
QSet< int > QgsAttributeIds
Q_DECL_DEPRECATED QString editForm() const
Get edit form.
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.
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
A bundle of parameters controlling aggregate calculation.
Q_DECL_DEPRECATED RangeData()