QGIS API Documentation
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 
394 class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
395 {
396  Q_OBJECT
397 
398  public:
399 
402 
404  {
405  GeneratedLayout = 0,
406  TabLayout = 1,
407  UiFileLayout = 2
408  };
409 
410  struct RangeData
411  {
413  Q_DECL_DEPRECATED RangeData() { mMin = QVariant( 0 ); mMax = QVariant( 5 ); mStep = QVariant( 1 );}
415  Q_DECL_DEPRECATED RangeData( const QVariant& theMin, const QVariant& theMax, const QVariant& theStep )
416  : mMin( theMin ), mMax( theMax ), mStep( theStep ) {}
417 
421  };
422 
424  {
425  ValueRelationData() : mAllowNull( false ), mOrderByValue( false ), mAllowMulti( false ) {}
426  ValueRelationData( const QString& layer, const QString& key, const QString& value, bool allowNull, bool orderByValue,
427  bool allowMulti = false,
428  const QString& filterExpression = QString::null )
429  : mLayer( layer )
430  , mKey( key )
431  , mValue( value )
432  , mFilterExpression( filterExpression )
433  , mAllowNull( allowNull )
434  , mOrderByValue( orderByValue )
435  , mAllowMulti( allowMulti )
436  {}
437 
444  bool mAllowMulti; /* allow selection of multiple keys */
445  };
446 
453  {
454  SuppressDefault = 0, // use the application-wide setting
455  SuppressOn = 1,
456  SuppressOff = 2
457  };
458 
462  enum EditType
463  {
485  };
486 
489  {
490  Success = 0,
491  EmptyGeometry = 1,
492  EditFailed = 2,
493  FetchFeatureFailed = 3,
494  InvalidLayer = 4,
495  };
496 
510  QgsVectorLayer( const QString& path = QString::null, const QString& baseName = QString::null,
511  const QString& providerLib = QString::null, bool loadDefaultStyleFlag = true );
512 
514  virtual ~QgsVectorLayer();
515 
517  QString storageType() const;
518 
520  QString capabilitiesString() const;
521 
523  QString dataComment() const;
524 
526  void setDisplayField( const QString& fldName = "" );
527 
529  const QString displayField() const;
530 
537  void setDisplayExpression( const QString &displayExpression );
538 
545  const QString displayExpression();
546 
548  QgsVectorDataProvider* dataProvider();
549 
553  const QgsVectorDataProvider* dataProvider() const;
554 
556  void setProviderEncoding( const QString& encoding );
557 
559  void setCoordinateSystem();
560 
564  bool addJoin( const QgsVectorJoinInfo& joinInfo );
565 
568  bool removeJoin( const QString& joinLayerId );
569 
570  const QList<QgsVectorJoinInfo> vectorJoins() const;
571 
575  virtual QSet<QString> layerDependencies() const;
576 
587  int addExpressionField( const QString& exp, const QgsField& fld );
588 
596  void removeExpressionField( int index );
597 
607  QString expressionField( int index );
608 
618  void updateExpressionField( int index, const QString& exp );
619 
621  QgsLabel *label();
622 
626  const QgsLabel *label() const;
627 
628  QgsAttributeAction *actions() { return mActions; }
629 
635  int selectedFeatureCount();
636 
645  void select( QgsRectangle & rect, bool addToSelection );
646 
658  void modifySelection( QgsFeatureIds selectIds, QgsFeatureIds deselectIds );
659 
661  void invertSelection();
662 
664  void selectAll();
665 
667  QgsFeatureIds allFeatureIds();
668 
676  void invertSelectionInRectangle( QgsRectangle & rect );
677 
686  QgsFeatureList selectedFeatures();
687 
699  QgsFeatureIterator selectedFeaturesIterator( QgsFeatureRequest request = QgsFeatureRequest() );
700 
707  const QgsFeatureIds &selectedFeaturesIds() const;
708 
716  void setSelectedFeatures( const QgsFeatureIds &ids );
717 
719  QgsRectangle boundingBoxOfSelected();
720 
725  bool labelsEnabled() const;
726 
731  bool diagramsEnabled() const;
732 
734  void setDiagramRenderer( QgsDiagramRendererV2* r );
735  const QgsDiagramRendererV2* diagramRenderer() const { return mDiagramRenderer; }
736 
737  void setDiagramLayerSettings( const QgsDiagramLayerSettings& s );
738  const QgsDiagramLayerSettings *diagramLayerSettings() const { return mDiagramLayerSettings; }
739 
741  QgsFeatureRendererV2* rendererV2() { return mRendererV2; }
742 
746  const QgsFeatureRendererV2* rendererV2() const { return mRendererV2; }
747 
752  void setRendererV2( QgsFeatureRendererV2* r );
753 
755  QGis::GeometryType geometryType() const;
756 
758  bool hasGeometryType() const;
759 
761  QGis::WkbType wkbType() const;
762 
764  QString providerType() const;
765 
769  virtual bool readXml( const QDomNode& layer_node ) override;
770 
774  virtual bool writeXml( QDomNode & layer_node, QDomDocument & doc ) override;
775 
784  virtual void saveStyleToDatabase( const QString& name, const QString& description,
785  bool useAsDefault, const QString& uiFileContent,
786  QString &msgError );
787 
796  virtual int listStylesInDatabase( QStringList &ids, QStringList &names,
797  QStringList &descriptions, QString &msgError );
798 
802  virtual QString getStyleFromDatabase( const QString& styleId, QString &msgError );
803 
810  virtual QString loadNamedStyle( const QString &theURI, bool &theResultFlag, bool loadFromLocalDb );
811 
816  virtual QString loadNamedStyle( const QString &theURI, bool &theResultFlag ) override;
817 
828  Q_DECL_DEPRECATED virtual bool applyNamedStyle( const QString& namedStyle, QString &errorMsg );
829 
834  QgsAttributeEditorElement* attributeEditorElementFromDomElement( QDomElement &elem, QObject* parent ) { return mEditFormConfig->attributeEditorElementFromDomElement( elem, parent ); }
835 
841  bool readSymbology( const QDomNode& node, QString& errorMessage ) override;
842 
849  bool writeSymbology( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const override;
850 
851  bool writeSld( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const;
852  bool readSld( const QDomNode& node, QString& errorMessage ) override;
853 
860  long featureCount( QgsSymbolV2* symbol );
861 
872  void setDataSource( const QString& dataSource, const QString& baseName, const QString& provider, bool loadDefaultStyleFlag = false );
873 
879  bool countSymbolFeatures( bool showProgress = true );
880 
888  virtual bool setSubsetString( const QString& subset );
889 
894  virtual QString subsetString();
895 
899  QgsFeatureIterator getFeatures( const QgsFeatureRequest& request = QgsFeatureRequest() );
900 
906  bool addFeature( QgsFeature& f, bool alsoUpdateExtent = true );
907 
914  bool updateFeature( QgsFeature &f );
915 
920  bool insertVertex( double x, double y, QgsFeatureId atFeatureId, int beforeVertex );
921 
926  bool moveVertex( double x, double y, QgsFeatureId atFeatureId, int atVertex );
927 
933  bool moveVertex( const QgsPointV2& p, QgsFeatureId atFeatureId, int atVertex );
934 
938  Q_DECL_DEPRECATED bool deleteVertex( QgsFeatureId atFeatureId, int atVertex );
939 
945  //TODO QGIS 3.0 - rename back to deleteVertex
946  EditResult deleteVertexV2( QgsFeatureId featureId, int vertex );
947 
951  bool deleteSelectedFeatures( int *deletedCount = nullptr );
952 
965  // TODO QGIS 3.0 returns an enum instead of a magic constant
966  int addRing( const QList<QgsPoint>& ring, QgsFeatureId* featureId = nullptr );
967 
978  // TODO QGIS 3.0 returns an enum instead of a magic constant
979  int addRing( QgsCurveV2* ring, QgsFeatureId* featureId = nullptr );
980 
992  // TODO QGIS 3.0 returns an enum instead of a magic constant
993  int addPart( const QList<QgsPoint>& ring );
994 
1007  // TODO QGIS 3.0 returns an enum instead of a magic constant
1008  int addPart( const QgsPointSequenceV2 &ring );
1009 
1011  int addPart( QgsCurveV2* ring );
1012 
1019  int translateFeature( QgsFeatureId featureId, double dx, double dy );
1020 
1028  // TODO QGIS 3.0 returns an enum instead of a magic constant
1029  int splitParts( const QList<QgsPoint>& splitLine, bool topologicalEditing = false );
1030 
1038  // TODO QGIS 3.0 returns an enum instead of a magic constant
1039  int splitFeatures( const QList<QgsPoint>& splitLine, bool topologicalEditing = false );
1040 
1049  Q_DECL_DEPRECATED int removePolygonIntersections( QgsGeometry* geom, const QgsFeatureIds& ignoreFeatures = QgsFeatureIds() );
1050 
1056  int addTopologicalPoints( const QgsGeometry* geom );
1057 
1065  int addTopologicalPoints( const QgsPoint& p );
1066 
1072  int insertSegmentVerticesForSnap( const QList<QgsSnappingResult>& snapResults );
1073 
1077  Q_DECL_DEPRECATED void enableLabels( bool on );
1078 
1082  Q_DECL_DEPRECATED bool hasLabelsEnabled() const;
1083 
1088  const QgsAbstractVectorLayerLabeling* labeling() const { return mLabeling; }
1089 
1094  void setLabeling( QgsAbstractVectorLayerLabeling* labeling );
1095 
1097  virtual bool isEditable() const override;
1098 
1099  virtual bool isSpatial() const override;
1100 
1108  Q_DECL_DEPRECATED virtual bool isReadOnly() const override;
1109 
1111  virtual bool isModified() const;
1112 
1119  bool snapPoint( QgsPoint& point, double tolerance );
1120 
1128  int snapWithContext( const QgsPoint& startPoint,
1129  double snappingTolerance,
1130  QMultiMap < double, QgsSnappingResult > &snappingResults,
1131  QgsSnapper::SnappingType snap_to );
1132 
1134  virtual void reload() override;
1135 
1139  virtual QgsMapLayerRenderer* createMapRenderer( QgsRenderContext& rendererContext ) override;
1140 
1144  bool draw( QgsRenderContext& rendererContext ) override;
1145 
1149  Q_DECL_DEPRECATED void drawLabels( QgsRenderContext& rendererContext ) override;
1150 
1152  QgsRectangle extent() override;
1153 
1160  inline QgsFields fields() const { return mUpdatedFields; }
1161 
1169  inline QgsFields pendingFields() const { return mUpdatedFields; }
1170 
1175  inline QgsAttributeList pendingAllAttributesList() const { return mUpdatedFields.allAttributesList(); }
1176 
1181  inline QgsAttributeList attributeList() const { return mUpdatedFields.allAttributesList(); }
1182 
1187  inline QgsAttributeList pendingPkAttributesList() const { return pkAttributeList(); }
1188 
1190  QgsAttributeList pkAttributeList() const;
1191 
1196  inline long pendingFeatureCount() const { return featureCount(); }
1197 
1202  long featureCount() const;
1203 
1207  bool setReadOnly( bool readonly = true );
1208 
1210  bool changeGeometry( QgsFeatureId fid, QgsGeometry* geom );
1211 
1218  Q_DECL_DEPRECATED bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant& value, bool emitSignal );
1219 
1230  bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant() );
1231 
1235  bool addAttribute( const QgsField &field );
1236 
1238  void addAttributeAlias( int attIndex, const QString& aliasString );
1239 
1241  void remAttributeAlias( int attIndex );
1242 
1248  Q_DECL_DEPRECATED void addAttributeEditorWidget( QgsAttributeEditorElement* data ) {mEditFormConfig->addTab( data );}
1249 
1259  Q_DECL_DEPRECATED const QString editorWidgetV2( int fieldIdx ) const { return mEditFormConfig->widgetType( fieldIdx ); }
1260 
1272  Q_DECL_DEPRECATED const QString editorWidgetV2( const QString& fieldName ) const { return mEditFormConfig->widgetType( fieldName ); }
1273 
1283  Q_DECL_DEPRECATED const QgsEditorWidgetConfig editorWidgetV2Config( int fieldIdx ) const { return mEditFormConfig->widgetConfig( fieldIdx ); }
1284 
1296  Q_DECL_DEPRECATED const QgsEditorWidgetConfig editorWidgetV2Config( const QString& fieldName ) const { return mEditFormConfig->widgetConfig( fieldName ); }
1297 
1303  Q_DECL_DEPRECATED QList< QgsAttributeEditorElement* > attributeEditorElements() { return mEditFormConfig->tabs(); }
1304 
1311  QgsEditFormConfig* editFormConfig() const { return mEditFormConfig; }
1312 
1316  void clearAttributeEditorWidgets() { mEditFormConfig->clearTabs(); }
1317 
1319  QString attributeAlias( int attributeIndex ) const;
1320 
1322  QString attributeDisplayName( int attributeIndex ) const;
1323 
1324  const QMap< QString, QString >& attributeAliases() const { return mAttributeAliasMap; }
1325 
1326  const QSet<QString>& excludeAttributesWMS() const { return mExcludeAttributesWMS; }
1327  void setExcludeAttributesWMS( const QSet<QString>& att ) { mExcludeAttributesWMS = att; }
1328 
1329  const QSet<QString>& excludeAttributesWFS() const { return mExcludeAttributesWFS; }
1330  void setExcludeAttributesWFS( const QSet<QString>& att ) { mExcludeAttributesWFS = att; }
1331 
1333  bool deleteAttribute( int attr );
1334 
1342  bool deleteAttributes( QList<int> attrs );
1343 
1345  bool addFeatures( QgsFeatureList features, bool makeSelected = true );
1346 
1348  bool deleteFeature( QgsFeatureId fid );
1349 
1357  bool deleteFeatures( const QgsFeatureIds& fids );
1358 
1374  bool commitChanges();
1375  const QStringList &commitErrors();
1376 
1380  bool rollBack( bool deleteBuffer = true );
1381 
1387  Q_DECL_DEPRECATED EditType editType( int idx );
1388 
1394  Q_DECL_DEPRECATED void setEditType( int idx, EditType edit );
1395 
1400  Q_DECL_DEPRECATED EditorLayout editorLayout() { return static_cast< EditorLayout >( mEditFormConfig->layout() ); }
1401 
1406  Q_DECL_DEPRECATED void setEditorLayout( EditorLayout editorLayout ) { mEditFormConfig->setLayout( static_cast< QgsEditFormConfig::EditorLayout >( editorLayout ) ); }
1407 
1438  Q_DECL_DEPRECATED void setEditorWidgetV2( int attrIdx, const QString& widgetType ) { mEditFormConfig->setWidgetType( attrIdx, widgetType ); }
1439 
1457  Q_DECL_DEPRECATED void setEditorWidgetV2Config( int attrIdx, const QgsEditorWidgetConfig& config ) { mEditFormConfig->setWidgetConfig( attrIdx, config ); }
1458 
1464  Q_DECL_DEPRECATED void setCheckedState( int idx, const QString& checked, const QString& notChecked );
1465 
1471  Q_DECL_DEPRECATED QString editForm() const { return mEditFormConfig->uiForm(); }
1472 
1477  Q_DECL_DEPRECATED void setEditForm( const QString& ui ) { mEditFormConfig->setUiForm( ui ); }
1478 
1483  Q_DECL_DEPRECATED QgsVectorLayer::FeatureFormSuppress featureFormSuppress() const { return static_cast< FeatureFormSuppress >( mEditFormConfig->suppress() ); }
1484 
1489  Q_DECL_DEPRECATED void setFeatureFormSuppress( QgsVectorLayer::FeatureFormSuppress s ) { mEditFormConfig->setSuppress( static_cast< QgsEditFormConfig::FeatureFormSuppress >( s ) ); }
1490 
1492  QString annotationForm() const { return mAnnotationForm; }
1493 
1495  void setAnnotationForm( const QString& ui );
1496 
1502  Q_DECL_DEPRECATED QString editFormInit() const { return mEditFormConfig->initFunction(); }
1503 
1509  Q_DECL_DEPRECATED void setEditFormInit( const QString& function ) { mEditFormConfig->setInitFunction( function ); }
1510 
1515  Q_DECL_DEPRECATED QMap<QString, QVariant> valueMap( int idx );
1516 
1522  Q_DECL_DEPRECATED RangeData range( int idx );
1523 
1525  ValueRelationData valueRelation( int idx );
1526 
1533  QList<QgsRelation> referencingRelations( int idx );
1534 
1540  Q_DECL_DEPRECATED QString dateFormat( int idx );
1541 
1547  Q_DECL_DEPRECATED QSize widgetSize( int idx );
1548 
1554  Q_DECL_DEPRECATED bool fieldEditable( int idx ) { return !mEditFormConfig->readOnly( idx ); }
1555 
1560  Q_DECL_DEPRECATED bool labelOnTop( int idx ) { return mEditFormConfig->labelOnTop( idx ); }
1561 
1566  Q_DECL_DEPRECATED void setFieldEditable( int idx, bool editable ) { mEditFormConfig->setReadOnly( idx, !editable ); }
1567 
1572  Q_DECL_DEPRECATED void setLabelOnTop( int idx, bool onTop ) { mEditFormConfig->setLabelOnTop( idx, onTop ); }
1573 
1575  QgsVectorLayerEditBuffer* editBuffer() { return mEditBuffer; }
1576 
1581  void beginEditCommand( const QString& text );
1582 
1584  void endEditCommand();
1585 
1587  void destroyEditCommand();
1588 
1590  int fieldNameIndex( const QString& fieldName ) const;
1591 
1594  {
1597  NoMarker
1598  };
1599 
1601  static void drawVertexMarker( double x, double y, QPainter& p, QgsVectorLayer::VertexMarkerType type, int vertexSize );
1602 
1604  void updateFields();
1605 
1607  void createJoinCaches();
1608 
1614  void uniqueValues( int index, QList<QVariant> &uniqueValues, int limit = -1 );
1615 
1617  QVariant minimumValue( int index );
1618 
1620  QVariant maximumValue( int index );
1621 
1630  QList< QVariant > getValues( const QString &fieldOrExpression, bool &ok, bool selectedOnly = false );
1631 
1642  QList< double > getDoubleValues( const QString &fieldOrExpression, bool &ok, bool selectedOnly = false, int* nullCount = nullptr );
1643 
1645  void setFeatureBlendMode( QPainter::CompositionMode blendMode );
1647  QPainter::CompositionMode featureBlendMode() const;
1648 
1650  void setLayerTransparency( int layerTransparency );
1652  int layerTransparency() const;
1653 
1654  QString metadata() override;
1655 
1657  inline QgsGeometryCache* cache() { return mCache; }
1658 
1662  void setSimplifyMethod( const QgsVectorSimplifyMethod& simplifyMethod ) { mSimplifyMethod = simplifyMethod; }
1666  inline const QgsVectorSimplifyMethod& simplifyMethod() const { return mSimplifyMethod; }
1667 
1672  bool simplifyDrawingCanbeApplied( const QgsRenderContext& renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint ) const;
1673 
1681  QgsConditionalLayerStyles *conditionalStyles() const;
1682 
1683  public slots:
1691  void select( QgsFeatureId featureId );
1692 
1700  void select( const QgsFeatureIds& featureIds );
1701 
1709  void deselect( const QgsFeatureId featureId );
1710 
1718  void deselect( const QgsFeatureIds& featureIds );
1719 
1725  void removeSelection();
1726 
1730  virtual void updateExtents();
1731 
1733  void checkJoinLayerRemove( const QString& theLayerId );
1734 
1741  bool startEditing();
1742 
1743 
1744  protected slots:
1745  void invalidateSymbolCountedFlag();
1746 
1747  signals:
1748 
1756  void selectionChanged( const QgsFeatureIds& selected, const QgsFeatureIds& deselected, const bool clearAndSelect );
1757 
1759  void selectionChanged();
1760 
1762  void layerModified();
1763 
1765  void beforeModifiedCheck() const;
1766 
1768  void beforeEditingStarted();
1769 
1771  void editingStarted();
1772 
1774  void editingStopped();
1775 
1777  void beforeCommitChanges();
1778 
1780  void beforeRollBack();
1781 
1790  void attributeAdded( int idx );
1791 
1798  void beforeAddingExpressionField( const QString& fieldName );
1799 
1808  void attributeDeleted( int idx );
1809 
1816  void beforeRemovingExpressionField( int idx );
1817 
1823  void featureAdded( QgsFeatureId fid );
1824 
1833  void featureDeleted( QgsFeatureId fid );
1834 
1844  void featuresDeleted( const QgsFeatureIds& fids );
1845 
1850  void updatedFields();
1851 
1855  void layerDeleted();
1856 
1857  void attributeValueChanged( QgsFeatureId fid, int idx, const QVariant & );
1858  void geometryChanged( QgsFeatureId fid, QgsGeometry &geom );
1859 
1861  void committedAttributesDeleted( const QString& layerId, const QgsAttributeList& deletedAttributes );
1862  void committedAttributesAdded( const QString& layerId, const QList<QgsField>& addedAttributes );
1863  void committedFeaturesAdded( const QString& layerId, const QgsFeatureList& addedFeatures );
1864  void committedFeaturesRemoved( const QString& layerId, const QgsFeatureIds& deletedFeatureIds );
1865  void committedAttributeValuesChanges( const QString& layerId, const QgsChangedAttributesMap& changedAttributesValues );
1866  void committedGeometriesChanges( const QString& layerId, const QgsGeometryMap& changedGeometries );
1867 
1868  void saveLayerToProject();
1869 
1871  void labelingFontNotFound( QgsVectorLayer* layer, const QString& fontfamily );
1872 
1874  void featureBlendModeChanged( QPainter::CompositionMode blendMode );
1875 
1877  void layerTransparencyChanged( int layerTransparency );
1878 
1884  void editCommandStarted( const QString& text );
1885 
1891  void editCommandEnded();
1892 
1898  void editCommandDestroyed();
1899 
1909  void readCustomSymbology( const QDomElement& element, QString& errorMessage );
1910 
1920  void writeCustomSymbology( QDomElement& element, QDomDocument& doc, QString& errorMessage ) const;
1921 
1925  void raiseError( const QString& msg );
1926 
1927  private slots:
1928  void onJoinedFieldsChanged();
1929  void onFeatureDeleted( QgsFeatureId fid );
1930 
1931  protected:
1933  void setExtent( const QgsRectangle &rect ) override;
1934 
1935  private: // Private methods
1936 
1938  QgsVectorLayer( const QgsVectorLayer & rhs );
1939 
1941  QgsVectorLayer & operator=( QgsVectorLayer const & rhs );
1942 
1943 
1948  bool setDataProvider( QString const & provider );
1949 
1951  QgsFeatureId findFreeId();
1952 
1961  void snapToGeometry( const QgsPoint& startPoint,
1962  QgsFeatureId featureId,
1963  const QgsGeometry *geom,
1964  double sqrSnappingTolerance,
1965  QMultiMap<double, QgsSnappingResult>& snappingResults,
1966  QgsSnapper::SnappingType snap_to ) const;
1967 
1969  //void addJoinedAttributes( QgsFeature& f, bool all = false );
1970 
1972  void readSldLabeling( const QDomNode& node );
1973 
1974  private: // Private attributes
1975 
1976  QgsConditionalLayerStyles * mConditionalStyles;
1977 
1979  QgsVectorDataProvider *mDataProvider;
1980 
1982  QString mDisplayField;
1983 
1985  QString mDisplayExpression;
1986 
1988  QString mProviderKey;
1989 
1991  QgsAttributeAction* mActions;
1992 
1994  bool mReadOnly;
1995 
2000  QgsFeatureIds mSelectedFeatureIds;
2001 
2003  QgsFields mUpdatedFields;
2004 
2006  QMap< QString, QString > mAttributeAliasMap;
2007 
2009  QgsEditFormConfig* mEditFormConfig;
2010 
2012  QSet<QString> mExcludeAttributesWMS;
2013 
2015  QSet<QString> mExcludeAttributesWFS;
2016 
2018  QGis::WkbType mWkbType;
2019 
2021  QgsFeatureRendererV2 *mRendererV2;
2022 
2024  QgsVectorSimplifyMethod mSimplifyMethod;
2025 
2027  QgsLabel *mLabel;
2028 
2030  bool mLabelOn;
2031 
2033  QgsAbstractVectorLayerLabeling* mLabeling;
2034 
2036  bool mLabelFontNotFoundNotified;
2037 
2039  QPainter::CompositionMode mFeatureBlendMode;
2040 
2042  int mLayerTransparency;
2043 
2045  bool mVertexMarkerOnlyForSelection;
2046 
2047  QStringList mCommitErrors;
2048 
2050  QString mAnnotationForm;
2051 
2053  QgsGeometryCache* mCache;
2054 
2056  QgsVectorLayerEditBuffer* mEditBuffer;
2058 
2059  //stores information about joined layers
2060  QgsVectorLayerJoinBuffer* mJoinBuffer;
2061 
2063  QgsExpressionFieldBuffer* mExpressionFieldBuffer;
2064 
2065  //diagram rendering object. 0 if diagram drawing is disabled
2066  QgsDiagramRendererV2* mDiagramRenderer;
2067 
2068  //stores infos about diagram placement (placement type, priority, position distance)
2069  QgsDiagramLayerSettings *mDiagramLayerSettings;
2070 
2071  bool mValidExtent;
2072  bool mLazyExtent;
2073 
2074  // Features in renderer classes counted
2075  bool mSymbolFeatureCounted;
2076 
2077  // Feature counts for each renderer symbol
2078  QMap<QgsSymbolV2*, long> mSymbolFeatureCountMap;
2079 
2081  bool mEditCommandActive;
2082 
2083  QgsFeatureIds mDeletedFids;
2084 
2086 };
2087 
2088 #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()
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: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: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
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()