QGIS API Documentation  2.14.0-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 
1598  void uniqueValues( int index, QList<QVariant> &uniqueValues, int limit = -1 );
1599 
1601  QVariant minimumValue( int index );
1602 
1604  QVariant maximumValue( int index );
1605 
1614  QList< QVariant > getValues( const QString &fieldOrExpression, bool &ok, bool selectedOnly = false );
1615 
1626  QList< double > getDoubleValues( const QString &fieldOrExpression, bool &ok, bool selectedOnly = false, int* nullCount = nullptr );
1627 
1629  void setFeatureBlendMode( QPainter::CompositionMode blendMode );
1631  QPainter::CompositionMode featureBlendMode() const;
1632 
1634  void setLayerTransparency( int layerTransparency );
1636  int layerTransparency() const;
1637 
1638  QString metadata() override;
1639 
1641  inline QgsGeometryCache* cache() { return mCache; }
1642 
1646  void setSimplifyMethod( const QgsVectorSimplifyMethod& simplifyMethod ) { mSimplifyMethod = simplifyMethod; }
1650  inline const QgsVectorSimplifyMethod& simplifyMethod() const { return mSimplifyMethod; }
1651 
1656  bool simplifyDrawingCanbeApplied( const QgsRenderContext& renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint ) const;
1657 
1665  QgsConditionalLayerStyles *conditionalStyles() const;
1666 
1667  public slots:
1675  void select( QgsFeatureId featureId );
1676 
1684  void select( const QgsFeatureIds& featureIds );
1685 
1693  void deselect( const QgsFeatureId featureId );
1694 
1702  void deselect( const QgsFeatureIds& featureIds );
1703 
1709  void removeSelection();
1710 
1714  virtual void updateExtents();
1715 
1717  void checkJoinLayerRemove( const QString& theLayerId );
1718 
1725  bool startEditing();
1726 
1727 
1728  protected slots:
1729  void invalidateSymbolCountedFlag();
1730 
1731  signals:
1732 
1740  void selectionChanged( const QgsFeatureIds& selected, const QgsFeatureIds& deselected, const bool clearAndSelect );
1741 
1743  void selectionChanged();
1744 
1746  void layerModified();
1747 
1749  void beforeModifiedCheck() const;
1750 
1752  void beforeEditingStarted();
1753 
1755  void editingStarted();
1756 
1758  void editingStopped();
1759 
1761  void beforeCommitChanges();
1762 
1764  void beforeRollBack();
1765 
1774  void attributeAdded( int idx );
1775 
1782  void beforeAddingExpressionField( const QString& fieldName );
1783 
1792  void attributeDeleted( int idx );
1793 
1800  void beforeRemovingExpressionField( int idx );
1801 
1807  void featureAdded( QgsFeatureId fid );
1808 
1817  void featureDeleted( QgsFeatureId fid );
1818 
1828  void featuresDeleted( const QgsFeatureIds& fids );
1829 
1834  void updatedFields();
1835 
1839  void layerDeleted();
1840 
1841  void attributeValueChanged( QgsFeatureId fid, int idx, const QVariant & );
1842  void geometryChanged( QgsFeatureId fid, QgsGeometry &geom );
1843 
1845  void committedAttributesDeleted( const QString& layerId, const QgsAttributeList& deletedAttributes );
1846  void committedAttributesAdded( const QString& layerId, const QList<QgsField>& addedAttributes );
1847  void committedFeaturesAdded( const QString& layerId, const QgsFeatureList& addedFeatures );
1848  void committedFeaturesRemoved( const QString& layerId, const QgsFeatureIds& deletedFeatureIds );
1849  void committedAttributeValuesChanges( const QString& layerId, const QgsChangedAttributesMap& changedAttributesValues );
1850  void committedGeometriesChanges( const QString& layerId, const QgsGeometryMap& changedGeometries );
1851 
1852  void saveLayerToProject();
1853 
1855  void labelingFontNotFound( QgsVectorLayer* layer, const QString& fontfamily );
1856 
1858  void featureBlendModeChanged( QPainter::CompositionMode blendMode );
1859 
1861  void layerTransparencyChanged( int layerTransparency );
1862 
1868  void editCommandStarted( const QString& text );
1869 
1875  void editCommandEnded();
1876 
1882  void editCommandDestroyed();
1883 
1893  void readCustomSymbology( const QDomElement& element, QString& errorMessage );
1894 
1904  void writeCustomSymbology( QDomElement& element, QDomDocument& doc, QString& errorMessage ) const;
1905 
1909  void raiseError( const QString& msg );
1910 
1911  private slots:
1912  void onJoinedFieldsChanged();
1913  void onFeatureDeleted( QgsFeatureId fid );
1914 
1915  protected:
1917  void setExtent( const QgsRectangle &rect ) override;
1918 
1919  private: // Private methods
1920 
1922  QgsVectorLayer( const QgsVectorLayer & rhs );
1923 
1925  QgsVectorLayer & operator=( QgsVectorLayer const & rhs );
1926 
1927 
1932  bool setDataProvider( QString const & provider );
1933 
1935  QgsFeatureId findFreeId();
1936 
1945  void snapToGeometry( const QgsPoint& startPoint,
1946  QgsFeatureId featureId,
1947  const QgsGeometry *geom,
1948  double sqrSnappingTolerance,
1949  QMultiMap<double, QgsSnappingResult>& snappingResults,
1950  QgsSnapper::SnappingType snap_to ) const;
1951 
1953  //void addJoinedAttributes( QgsFeature& f, bool all = false );
1954 
1956  void readSldLabeling( const QDomNode& node );
1957 
1958  private: // Private attributes
1959 
1960  QgsConditionalLayerStyles * mConditionalStyles;
1961 
1963  QgsVectorDataProvider *mDataProvider;
1964 
1966  QString mDisplayField;
1967 
1969  QString mDisplayExpression;
1970 
1972  QString mProviderKey;
1973 
1975  QgsAttributeAction* mActions;
1976 
1978  bool mReadOnly;
1979 
1984  QgsFeatureIds mSelectedFeatureIds;
1985 
1987  QgsFields mUpdatedFields;
1988 
1990  QMap< QString, QString > mAttributeAliasMap;
1991 
1993  QgsEditFormConfig* mEditFormConfig;
1994 
1996  QSet<QString> mExcludeAttributesWMS;
1997 
1999  QSet<QString> mExcludeAttributesWFS;
2000 
2002  QGis::WkbType mWkbType;
2003 
2005  QgsFeatureRendererV2 *mRendererV2;
2006 
2008  QgsVectorSimplifyMethod mSimplifyMethod;
2009 
2011  QgsLabel *mLabel;
2012 
2014  bool mLabelOn;
2015 
2017  QgsAbstractVectorLayerLabeling* mLabeling;
2018 
2020  bool mLabelFontNotFoundNotified;
2021 
2023  QPainter::CompositionMode mFeatureBlendMode;
2024 
2026  int mLayerTransparency;
2027 
2029  bool mVertexMarkerOnlyForSelection;
2030 
2031  QStringList mCommitErrors;
2032 
2034  QString mAnnotationForm;
2035 
2037  QgsGeometryCache* mCache;
2038 
2040  QgsVectorLayerEditBuffer* mEditBuffer;
2042 
2043  //stores information about joined layers
2044  QgsVectorLayerJoinBuffer* mJoinBuffer;
2045 
2047  QgsExpressionFieldBuffer* mExpressionFieldBuffer;
2048 
2049  //diagram rendering object. 0 if diagram drawing is disabled
2050  QgsDiagramRendererV2* mDiagramRenderer;
2051 
2052  //stores infos about diagram placement (placement type, priority, position distance)
2053  QgsDiagramLayerSettings *mDiagramLayerSettings;
2054 
2055  bool mValidExtent;
2056  bool mLazyExtent;
2057 
2058  // Features in renderer classes counted
2059  bool mSymbolFeatureCounted;
2060 
2061  // Feature counts for each renderer symbol
2062  QMap<QgsSymbolV2*, long> mSymbolFeatureCountMap;
2063 
2065  bool mEditCommandActive;
2066 
2067  QgsFeatureIds mDeletedFids;
2068 
2070 };
2071 
2072 #endif
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: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)
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:433
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.
Storage and management of actions associated with Qgis layer attributes.
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:187
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: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
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()
Returns diagram settings for a 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:66
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.
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
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.
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:65
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
uuid generator - readonly and automatically intialized
long pendingFeatureCount() const
Returns feature count including changes which have not yet been committed Alias for featureCount()...
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...
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.
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.
QgsEditFormConfig::TabData TabData
QList< QgsPointV2 > QgsPointSequenceV2
Q_DECL_DEPRECATED RangeData()