QGIS API Documentation  2.14.7-Essen
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"
37 
38 class QPainter;
39 class QImage;
40 
42 class QgsAttributeAction;
45 class QgsCurveV2;
51 class QgsFeatureRequest;
52 class QgsGeometry;
53 class QgsGeometryCache;
54 class QgsGeometryVertexIndex;
55 class QgsLabel;
56 class QgsMapToPixel;
57 class QgsRectangle;
58 class QgsRectangle;
59 class QgsRelation;
60 class QgsRelationManager;
62 class QgsSymbolV2;
67 class QgsPointV2;
68 
72 
73 
74 struct CORE_EXPORT QgsVectorJoinInfo
75 {
88 
93 
98 
99  bool operator==( const QgsVectorJoinInfo& other ) const
100  {
101  return targetFieldName == other.targetFieldName &&
102  joinLayerId == other.joinLayerId &&
103  joinFieldName == other.joinFieldName &&
104  joinFieldsSubset == other.joinFieldsSubset &&
105  memoryCache == other.memoryCache &&
106  prefix == other.prefix;
107  }
108 
111  void setJoinFieldNamesSubset( QStringList* fieldNamesSubset ) { joinFieldsSubset = QSharedPointer<QStringList>( fieldNamesSubset ); }
114  QStringList* joinFieldNamesSubset() const { return joinFieldsSubset.data(); }
115 
116 protected:
119 };
120 
121 
122 
386 class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
387 {
388  Q_OBJECT
389 
390  public:
391 
394 
396  {
397  GeneratedLayout = 0,
398  TabLayout = 1,
399  UiFileLayout = 2
400  };
401 
402  struct RangeData
403  {
405  Q_DECL_DEPRECATED RangeData() { mMin = QVariant( 0 ); mMax = QVariant( 5 ); mStep = QVariant( 1 );}
407  Q_DECL_DEPRECATED RangeData( const QVariant& theMin, const QVariant& theMax, const QVariant& theStep )
408  : mMin( theMin ), mMax( theMax ), mStep( theStep ) {}
409 
413  };
414 
416  {
417  ValueRelationData() : mAllowNull( false ), mOrderByValue( false ), mAllowMulti( false ) {}
418  ValueRelationData( const QString& layer, const QString& key, const QString& value, bool allowNull, bool orderByValue,
419  bool allowMulti = false,
420  const QString& filterExpression = QString::null )
421  : mLayer( layer )
422  , mKey( key )
423  , mValue( value )
424  , mFilterExpression( filterExpression )
425  , mAllowNull( allowNull )
426  , mOrderByValue( orderByValue )
427  , mAllowMulti( allowMulti )
428  {}
429 
436  bool mAllowMulti; /* allow selection of multiple keys */
437  };
438 
445  {
446  SuppressDefault = 0, // use the application-wide setting
447  SuppressOn = 1,
448  SuppressOff = 2
449  };
450 
454  enum EditType
455  {
477  };
478 
481  {
482  Success = 0,
483  EmptyGeometry = 1,
484  EditFailed = 2,
485  FetchFeatureFailed = 3,
486  InvalidLayer = 4,
487  };
488 
502  QgsVectorLayer( const QString& path = QString::null, const QString& baseName = QString::null,
503  const QString& providerLib = QString::null, bool loadDefaultStyleFlag = true );
504 
506  virtual ~QgsVectorLayer();
507 
509  QString storageType() const;
510 
512  QString capabilitiesString() const;
513 
515  QString dataComment() const;
516 
518  void setDisplayField( const QString& fldName = "" );
519 
521  const QString displayField() const;
522 
529  void setDisplayExpression( const QString &displayExpression );
530 
537  const QString displayExpression();
538 
540  QgsVectorDataProvider* dataProvider();
541 
545  const QgsVectorDataProvider* dataProvider() const;
546 
548  void setProviderEncoding( const QString& encoding );
549 
551  void setCoordinateSystem();
552 
556  bool addJoin( const QgsVectorJoinInfo& joinInfo );
557 
560  bool removeJoin( const QString& joinLayerId );
561 
562  const QList<QgsVectorJoinInfo> vectorJoins() const;
563 
567  virtual QSet<QString> layerDependencies() const;
568 
579  int addExpressionField( const QString& exp, const QgsField& fld );
580 
588  void removeExpressionField( int index );
589 
599  QString expressionField( int index );
600 
610  void updateExpressionField( int index, const QString& exp );
611 
613  QgsLabel *label();
614 
618  const QgsLabel *label() const;
619 
620  QgsAttributeAction *actions() { return mActions; }
621 
627  int selectedFeatureCount();
628 
637  void select( QgsRectangle & rect, bool addToSelection );
638 
650  void modifySelection( QgsFeatureIds selectIds, QgsFeatureIds deselectIds );
651 
653  void invertSelection();
654 
656  void selectAll();
657 
659  QgsFeatureIds allFeatureIds();
660 
668  void invertSelectionInRectangle( QgsRectangle & rect );
669 
678  QgsFeatureList selectedFeatures();
679 
691  QgsFeatureIterator selectedFeaturesIterator( QgsFeatureRequest request = QgsFeatureRequest() );
692 
699  const QgsFeatureIds &selectedFeaturesIds() const;
700 
708  void setSelectedFeatures( const QgsFeatureIds &ids );
709 
711  QgsRectangle boundingBoxOfSelected();
712 
717  bool labelsEnabled() const;
718 
723  bool diagramsEnabled() const;
724 
726  void setDiagramRenderer( QgsDiagramRendererV2* r );
727  const QgsDiagramRendererV2* diagramRenderer() const { return mDiagramRenderer; }
728 
729  void setDiagramLayerSettings( const QgsDiagramLayerSettings& s );
730  const QgsDiagramLayerSettings *diagramLayerSettings() const { return mDiagramLayerSettings; }
731 
733  QgsFeatureRendererV2* rendererV2() { return mRendererV2; }
734 
738  const QgsFeatureRendererV2* rendererV2() const { return mRendererV2; }
739 
744  void setRendererV2( QgsFeatureRendererV2* r );
745 
747  QGis::GeometryType geometryType() const;
748 
750  bool hasGeometryType() const;
751 
753  QGis::WkbType wkbType() const;
754 
756  QString providerType() const;
757 
761  virtual bool readXml( const QDomNode& layer_node ) override;
762 
766  virtual bool writeXml( QDomNode & layer_node, QDomDocument & doc ) override;
767 
776  virtual void saveStyleToDatabase( const QString& name, const QString& description,
777  bool useAsDefault, const QString& uiFileContent,
778  QString &msgError );
779 
788  virtual int listStylesInDatabase( QStringList &ids, QStringList &names,
789  QStringList &descriptions, QString &msgError );
790 
794  virtual QString getStyleFromDatabase( const QString& styleId, QString &msgError );
795 
802  virtual QString loadNamedStyle( const QString &theURI, bool &theResultFlag, bool loadFromLocalDb );
803 
808  virtual QString loadNamedStyle( const QString &theURI, bool &theResultFlag ) override;
809 
820  Q_DECL_DEPRECATED virtual bool applyNamedStyle( const QString& namedStyle, QString &errorMsg );
821 
826  QgsAttributeEditorElement* attributeEditorElementFromDomElement( QDomElement &elem, QObject* parent ) { return mEditFormConfig->attributeEditorElementFromDomElement( elem, parent ); }
827 
833  bool readSymbology( const QDomNode& node, QString& errorMessage ) override;
834 
841  bool writeSymbology( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const override;
842 
843  bool writeSld( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const;
844  bool readSld( const QDomNode& node, QString& errorMessage ) override;
845 
852  long featureCount( QgsSymbolV2* symbol );
853 
864  void setDataSource( const QString& dataSource, const QString& baseName, const QString& provider, bool loadDefaultStyleFlag = false );
865 
871  bool countSymbolFeatures( bool showProgress = true );
872 
880  virtual bool setSubsetString( const QString& subset );
881 
886  virtual QString subsetString();
887 
891  QgsFeatureIterator getFeatures( const QgsFeatureRequest& request = QgsFeatureRequest() );
892 
898  bool addFeature( QgsFeature& f, bool alsoUpdateExtent = true );
899 
906  bool updateFeature( QgsFeature &f );
907 
912  bool insertVertex( double x, double y, QgsFeatureId atFeatureId, int beforeVertex );
913 
918  bool moveVertex( double x, double y, QgsFeatureId atFeatureId, int atVertex );
919 
925  bool moveVertex( const QgsPointV2& p, QgsFeatureId atFeatureId, int atVertex );
926 
930  Q_DECL_DEPRECATED bool deleteVertex( QgsFeatureId atFeatureId, int atVertex );
931 
937  //TODO QGIS 3.0 - rename back to deleteVertex
938  EditResult deleteVertexV2( QgsFeatureId featureId, int vertex );
939 
943  bool deleteSelectedFeatures( int *deletedCount = nullptr );
944 
957  // TODO QGIS 3.0 returns an enum instead of a magic constant
958  int addRing( const QList<QgsPoint>& ring, QgsFeatureId* featureId = nullptr );
959 
970  // TODO QGIS 3.0 returns an enum instead of a magic constant
971  int addRing( QgsCurveV2* ring, QgsFeatureId* featureId = nullptr );
972 
984  // TODO QGIS 3.0 returns an enum instead of a magic constant
985  int addPart( const QList<QgsPoint>& ring );
986 
999  // TODO QGIS 3.0 returns an enum instead of a magic constant
1000  int addPart( const QgsPointSequenceV2 &ring );
1001 
1003  int addPart( QgsCurveV2* ring );
1004 
1011  int translateFeature( QgsFeatureId featureId, double dx, double dy );
1012 
1020  // TODO QGIS 3.0 returns an enum instead of a magic constant
1021  int splitParts( const QList<QgsPoint>& splitLine, bool topologicalEditing = false );
1022 
1030  // TODO QGIS 3.0 returns an enum instead of a magic constant
1031  int splitFeatures( const QList<QgsPoint>& splitLine, bool topologicalEditing = false );
1032 
1041  Q_DECL_DEPRECATED int removePolygonIntersections( QgsGeometry* geom, const QgsFeatureIds& ignoreFeatures = QgsFeatureIds() );
1042 
1048  int addTopologicalPoints( const QgsGeometry* geom );
1049 
1057  int addTopologicalPoints( const QgsPoint& p );
1058 
1064  int insertSegmentVerticesForSnap( const QList<QgsSnappingResult>& snapResults );
1065 
1069  Q_DECL_DEPRECATED void enableLabels( bool on );
1070 
1074  Q_DECL_DEPRECATED bool hasLabelsEnabled() const;
1075 
1080  const QgsAbstractVectorLayerLabeling* labeling() const { return mLabeling; }
1081 
1086  void setLabeling( QgsAbstractVectorLayerLabeling* labeling );
1087 
1089  virtual bool isEditable() const override;
1090 
1092  virtual bool isReadOnly() const;
1093 
1095  virtual bool isModified() const;
1096 
1103  bool snapPoint( QgsPoint& point, double tolerance );
1104 
1112  int snapWithContext( const QgsPoint& startPoint,
1113  double snappingTolerance,
1114  QMultiMap < double, QgsSnappingResult > &snappingResults,
1115  QgsSnapper::SnappingType snap_to );
1116 
1118  virtual void reload() override;
1119 
1123  virtual QgsMapLayerRenderer* createMapRenderer( QgsRenderContext& rendererContext ) override;
1124 
1128  bool draw( QgsRenderContext& rendererContext ) override;
1129 
1133  Q_DECL_DEPRECATED void drawLabels( QgsRenderContext& rendererContext ) override;
1134 
1136  QgsRectangle extent() override;
1137 
1144  inline QgsFields fields() const { return mUpdatedFields; }
1145 
1153  inline QgsFields pendingFields() const { return mUpdatedFields; }
1154 
1159  inline QgsAttributeList pendingAllAttributesList() const { return mUpdatedFields.allAttributesList(); }
1160 
1165  inline QgsAttributeList attributeList() const { return mUpdatedFields.allAttributesList(); }
1166 
1171  inline QgsAttributeList pendingPkAttributesList() const { return pkAttributeList(); }
1172 
1174  QgsAttributeList pkAttributeList() const;
1175 
1180  inline long pendingFeatureCount() const { return featureCount(); }
1181 
1186  long featureCount() const;
1187 
1191  bool setReadOnly( bool readonly = true );
1192 
1194  bool changeGeometry( QgsFeatureId fid, QgsGeometry* geom );
1195 
1202  Q_DECL_DEPRECATED bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant& value, bool emitSignal );
1203 
1214  bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant() );
1215 
1219  bool addAttribute( const QgsField &field );
1220 
1222  void addAttributeAlias( int attIndex, const QString& aliasString );
1223 
1225  void remAttributeAlias( int attIndex );
1226 
1232  Q_DECL_DEPRECATED void addAttributeEditorWidget( QgsAttributeEditorElement* data ) {mEditFormConfig->addTab( data );}
1233 
1243  Q_DECL_DEPRECATED const QString editorWidgetV2( int fieldIdx ) const { return mEditFormConfig->widgetType( fieldIdx ); }
1244 
1256  Q_DECL_DEPRECATED const QString editorWidgetV2( const QString& fieldName ) const { return mEditFormConfig->widgetType( fieldName ); }
1257 
1267  Q_DECL_DEPRECATED const QgsEditorWidgetConfig editorWidgetV2Config( int fieldIdx ) const { return mEditFormConfig->widgetConfig( fieldIdx ); }
1268 
1280  Q_DECL_DEPRECATED const QgsEditorWidgetConfig editorWidgetV2Config( const QString& fieldName ) const { return mEditFormConfig->widgetConfig( fieldName ); }
1281 
1287  Q_DECL_DEPRECATED QList< QgsAttributeEditorElement* > attributeEditorElements() { return mEditFormConfig->tabs(); }
1288 
1295  QgsEditFormConfig* editFormConfig() const { return mEditFormConfig; }
1296 
1300  void clearAttributeEditorWidgets() { mEditFormConfig->clearTabs(); }
1301 
1303  QString attributeAlias( int attributeIndex ) const;
1304 
1306  QString attributeDisplayName( int attributeIndex ) const;
1307 
1308  const QMap< QString, QString >& attributeAliases() const { return mAttributeAliasMap; }
1309 
1310  const QSet<QString>& excludeAttributesWMS() const { return mExcludeAttributesWMS; }
1311  void setExcludeAttributesWMS( const QSet<QString>& att ) { mExcludeAttributesWMS = att; }
1312 
1313  const QSet<QString>& excludeAttributesWFS() const { return mExcludeAttributesWFS; }
1314  void setExcludeAttributesWFS( const QSet<QString>& att ) { mExcludeAttributesWFS = att; }
1315 
1317  bool deleteAttribute( int attr );
1318 
1326  bool deleteAttributes( QList<int> attrs );
1327 
1329  bool addFeatures( QgsFeatureList features, bool makeSelected = true );
1330 
1332  bool deleteFeature( QgsFeatureId fid );
1333 
1341  bool deleteFeatures( const QgsFeatureIds& fids );
1342 
1358  bool commitChanges();
1359  const QStringList &commitErrors();
1360 
1364  bool rollBack( bool deleteBuffer = true );
1365 
1371  Q_DECL_DEPRECATED EditType editType( int idx );
1372 
1378  Q_DECL_DEPRECATED void setEditType( int idx, EditType edit );
1379 
1384  Q_DECL_DEPRECATED EditorLayout editorLayout() { return static_cast< EditorLayout >( mEditFormConfig->layout() ); }
1385 
1390  Q_DECL_DEPRECATED void setEditorLayout( EditorLayout editorLayout ) { mEditFormConfig->setLayout( static_cast< QgsEditFormConfig::EditorLayout >( editorLayout ) ); }
1391 
1422  Q_DECL_DEPRECATED void setEditorWidgetV2( int attrIdx, const QString& widgetType ) { mEditFormConfig->setWidgetType( attrIdx, widgetType ); }
1423 
1441  Q_DECL_DEPRECATED void setEditorWidgetV2Config( int attrIdx, const QgsEditorWidgetConfig& config ) { mEditFormConfig->setWidgetConfig( attrIdx, config ); }
1442 
1448  Q_DECL_DEPRECATED void setCheckedState( int idx, const QString& checked, const QString& notChecked );
1449 
1455  Q_DECL_DEPRECATED QString editForm() const { return mEditFormConfig->uiForm(); }
1456 
1461  Q_DECL_DEPRECATED void setEditForm( const QString& ui ) { mEditFormConfig->setUiForm( ui ); }
1462 
1467  Q_DECL_DEPRECATED QgsVectorLayer::FeatureFormSuppress featureFormSuppress() const { return static_cast< FeatureFormSuppress >( mEditFormConfig->suppress() ); }
1468 
1473  Q_DECL_DEPRECATED void setFeatureFormSuppress( QgsVectorLayer::FeatureFormSuppress s ) { mEditFormConfig->setSuppress( static_cast< QgsEditFormConfig::FeatureFormSuppress >( s ) ); }
1474 
1476  QString annotationForm() const { return mAnnotationForm; }
1477 
1479  void setAnnotationForm( const QString& ui );
1480 
1486  Q_DECL_DEPRECATED QString editFormInit() const { return mEditFormConfig->initFunction(); }
1487 
1493  Q_DECL_DEPRECATED void setEditFormInit( const QString& function ) { mEditFormConfig->setInitFunction( function ); }
1494 
1499  Q_DECL_DEPRECATED QMap<QString, QVariant> valueMap( int idx );
1500 
1506  Q_DECL_DEPRECATED RangeData range( int idx );
1507 
1509  ValueRelationData valueRelation( int idx );
1510 
1517  QList<QgsRelation> referencingRelations( int idx );
1518 
1524  Q_DECL_DEPRECATED QString dateFormat( int idx );
1525 
1531  Q_DECL_DEPRECATED QSize widgetSize( int idx );
1532 
1538  Q_DECL_DEPRECATED bool fieldEditable( int idx ) { return !mEditFormConfig->readOnly( idx ); }
1539 
1544  Q_DECL_DEPRECATED bool labelOnTop( int idx ) { return mEditFormConfig->labelOnTop( idx ); }
1545 
1550  Q_DECL_DEPRECATED void setFieldEditable( int idx, bool editable ) { mEditFormConfig->setReadOnly( idx, !editable ); }
1551 
1556  Q_DECL_DEPRECATED void setLabelOnTop( int idx, bool onTop ) { mEditFormConfig->setLabelOnTop( idx, onTop ); }
1557 
1559  QgsVectorLayerEditBuffer* editBuffer() { return mEditBuffer; }
1560 
1565  void beginEditCommand( const QString& text );
1566 
1568  void endEditCommand();
1569 
1571  void destroyEditCommand();
1572 
1574  int fieldNameIndex( const QString& fieldName ) const;
1575 
1578  {
1581  NoMarker
1582  };
1583 
1585  static void drawVertexMarker( double x, double y, QPainter& p, QgsVectorLayer::VertexMarkerType type, int vertexSize );
1586 
1588  void updateFields();
1589 
1591  void createJoinCaches();
1592 
1604  void uniqueValues( int index, QList<QVariant> &uniqueValues, int limit = -1 );
1605 
1613  QVariant minimumValue( int index );
1614 
1622  QVariant maximumValue( int index );
1623 
1632  QList< QVariant > getValues( const QString &fieldOrExpression, bool &ok, bool selectedOnly = false );
1633 
1644  QList< double > getDoubleValues( const QString &fieldOrExpression, bool &ok, bool selectedOnly = false, int* nullCount = nullptr );
1645 
1647  void setFeatureBlendMode( QPainter::CompositionMode blendMode );
1649  QPainter::CompositionMode featureBlendMode() const;
1650 
1652  void setLayerTransparency( int layerTransparency );
1654  int layerTransparency() const;
1655 
1656  QString metadata() override;
1657 
1659  inline QgsGeometryCache* cache() { return mCache; }
1660 
1664  void setSimplifyMethod( const QgsVectorSimplifyMethod& simplifyMethod ) { mSimplifyMethod = simplifyMethod; }
1668  inline const QgsVectorSimplifyMethod& simplifyMethod() const { return mSimplifyMethod; }
1669 
1674  bool simplifyDrawingCanbeApplied( const QgsRenderContext& renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint ) const;
1675 
1683  QgsConditionalLayerStyles *conditionalStyles() const;
1684 
1685  public slots:
1693  void select( QgsFeatureId featureId );
1694 
1702  void select( const QgsFeatureIds& featureIds );
1703 
1711  void deselect( const QgsFeatureId featureId );
1712 
1720  void deselect( const QgsFeatureIds& featureIds );
1721 
1727  void removeSelection();
1728 
1732  virtual void updateExtents();
1733 
1735  void checkJoinLayerRemove( const QString& theLayerId );
1736 
1743  bool startEditing();
1744 
1745 
1746  protected slots:
1747  void invalidateSymbolCountedFlag();
1748 
1749  signals:
1750 
1758  void selectionChanged( const QgsFeatureIds& selected, const QgsFeatureIds& deselected, const bool clearAndSelect );
1759 
1761  void selectionChanged();
1762 
1764  void layerModified();
1765 
1767  void beforeModifiedCheck() const;
1768 
1770  void beforeEditingStarted();
1771 
1773  void editingStarted();
1774 
1776  void editingStopped();
1777 
1779  void beforeCommitChanges();
1780 
1782  void beforeRollBack();
1783 
1792  void attributeAdded( int idx );
1793 
1800  void beforeAddingExpressionField( const QString& fieldName );
1801 
1810  void attributeDeleted( int idx );
1811 
1818  void beforeRemovingExpressionField( int idx );
1819 
1825  void featureAdded( QgsFeatureId fid );
1826 
1835  void featureDeleted( QgsFeatureId fid );
1836 
1846  void featuresDeleted( const QgsFeatureIds& fids );
1847 
1852  void updatedFields();
1853 
1857  void layerDeleted();
1858 
1859  void attributeValueChanged( QgsFeatureId fid, int idx, const QVariant & );
1860  void geometryChanged( QgsFeatureId fid, QgsGeometry &geom );
1861 
1863  void committedAttributesDeleted( const QString& layerId, const QgsAttributeList& deletedAttributes );
1864  void committedAttributesAdded( const QString& layerId, const QList<QgsField>& addedAttributes );
1865  void committedFeaturesAdded( const QString& layerId, const QgsFeatureList& addedFeatures );
1866  void committedFeaturesRemoved( const QString& layerId, const QgsFeatureIds& deletedFeatureIds );
1867  void committedAttributeValuesChanges( const QString& layerId, const QgsChangedAttributesMap& changedAttributesValues );
1868  void committedGeometriesChanges( const QString& layerId, const QgsGeometryMap& changedGeometries );
1869 
1870  void saveLayerToProject();
1871 
1873  void labelingFontNotFound( QgsVectorLayer* layer, const QString& fontfamily );
1874 
1876  void featureBlendModeChanged( QPainter::CompositionMode blendMode );
1877 
1879  void layerTransparencyChanged( int layerTransparency );
1880 
1886  void editCommandStarted( const QString& text );
1887 
1893  void editCommandEnded();
1894 
1900  void editCommandDestroyed();
1901 
1911  void readCustomSymbology( const QDomElement& element, QString& errorMessage );
1912 
1922  void writeCustomSymbology( QDomElement& element, QDomDocument& doc, QString& errorMessage ) const;
1923 
1927  void raiseError( const QString& msg );
1928 
1929  private slots:
1930  void onJoinedFieldsChanged();
1931  void onFeatureDeleted( QgsFeatureId fid );
1932 
1933  protected:
1935  void setExtent( const QgsRectangle &rect ) override;
1936 
1937  private: // Private methods
1938 
1940  QgsVectorLayer( const QgsVectorLayer & rhs );
1941 
1943  QgsVectorLayer & operator=( QgsVectorLayer const & rhs );
1944 
1945 
1950  bool setDataProvider( QString const & provider );
1951 
1953  QgsFeatureId findFreeId();
1954 
1963  void snapToGeometry( const QgsPoint& startPoint,
1964  QgsFeatureId featureId,
1965  const QgsGeometry *geom,
1966  double sqrSnappingTolerance,
1967  QMultiMap<double, QgsSnappingResult>& snappingResults,
1968  QgsSnapper::SnappingType snap_to ) const;
1969 
1971  //void addJoinedAttributes( QgsFeature& f, bool all = false );
1972 
1974  void readSldLabeling( const QDomNode& node );
1975 
1976  private: // Private attributes
1977 
1978  QgsConditionalLayerStyles * mConditionalStyles;
1979 
1981  QgsVectorDataProvider *mDataProvider;
1982 
1984  QString mDisplayField;
1985 
1987  QString mDisplayExpression;
1988 
1990  QString mProviderKey;
1991 
1993  QgsAttributeAction* mActions;
1994 
1996  bool mReadOnly;
1997 
2002  QgsFeatureIds mSelectedFeatureIds;
2003 
2005  QgsFields mUpdatedFields;
2006 
2008  QMap< QString, QString > mAttributeAliasMap;
2009 
2011  QgsEditFormConfig* mEditFormConfig;
2012 
2014  QSet<QString> mExcludeAttributesWMS;
2015 
2017  QSet<QString> mExcludeAttributesWFS;
2018 
2020  QGis::WkbType mWkbType;
2021 
2023  QgsFeatureRendererV2 *mRendererV2;
2024 
2026  QgsVectorSimplifyMethod mSimplifyMethod;
2027 
2029  QgsLabel *mLabel;
2030 
2032  bool mLabelOn;
2033 
2035  QgsAbstractVectorLayerLabeling* mLabeling;
2036 
2038  bool mLabelFontNotFoundNotified;
2039 
2041  QPainter::CompositionMode mFeatureBlendMode;
2042 
2044  int mLayerTransparency;
2045 
2047  bool mVertexMarkerOnlyForSelection;
2048 
2049  QStringList mCommitErrors;
2050 
2052  QString mAnnotationForm;
2053 
2055  QgsGeometryCache* mCache;
2056 
2058  QgsVectorLayerEditBuffer* mEditBuffer;
2060 
2061  //stores information about joined layers
2062  QgsVectorLayerJoinBuffer* mJoinBuffer;
2063 
2065  QgsExpressionFieldBuffer* mExpressionFieldBuffer;
2066 
2067  //diagram rendering object. 0 if diagram drawing is disabled
2068  QgsDiagramRendererV2* mDiagramRenderer;
2069 
2070  //stores infos about diagram placement (placement type, priority, position distance)
2071  QgsDiagramLayerSettings *mDiagramLayerSettings;
2072 
2073  bool mValidExtent;
2074  bool mLazyExtent;
2075 
2076  // Features in renderer classes counted
2077  bool mSymbolFeatureCounted;
2078 
2079  // Feature counts for each renderer symbol
2080  QMap<QgsSymbolV2*, long> mSymbolFeatureCountMap;
2081 
2083  bool mEditCommandActive;
2084 
2085  QgsFeatureIds mDeletedFids;
2086 
2088 };
2089 
2090 #endif
const QSet< QString > & excludeAttributesWMS() const
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:111
QgsAttributeAction * actions()
ValueRelationData(const QString &layer, const QString &key, const QString &value, bool allowNull, bool orderByValue, bool allowMulti=false, const QString &filterExpression=QString::null)
QgsEditFormConfig::GroupData GroupData
The attribute value should not be changed in the attribute form.
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:433
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.
Storage and management of actions associated with Qgis layer attributes.
VertexMarkerType
Editing vertex markers.
SimplifyHint
Simplification flags for fast rendering of features.
Container of fields for a vector layer.
Definition: qgsfield.h:187
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:57
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()
Returns diagram settings for a 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:66
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.
const QMap< QString, QString > & attributeAliases() 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.
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
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) ...
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:65
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
long pendingFeatureCount() const
Returns feature count including changes which have not yet been committed Alias for featureCount()...
uuid generator - readonly and automatically intialized
Q_DECL_DEPRECATED QString editFormInit() const
Get python function for edit form initialization.
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...
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
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.
QgsEditFormConfig::TabData TabData
QList< QgsPointV2 > QgsPointSequenceV2
bool operator==(const QgsVectorJoinInfo &other) const
Q_DECL_DEPRECATED RangeData()