QGIS API Documentation  2.15.0-Master (94d88e6)
qgsvectorlayer.h
Go to the documentation of this file.
1 
2 /***************************************************************************
3  qgsvectorlayer.h - description
4  -------------------
5  begin : Oct 29, 2003
6  copyright : (C) 2003 by Gary E.Sherman
7  email : sherman at mrcc.com
8  ***************************************************************************/
9 
10 /***************************************************************************
11  * *
12  * This program is free software; you can redistribute it and/or modify *
13  * it under the terms of the GNU General Public License as published by *
14  * the Free Software Foundation; either version 2 of the License, or *
15  * (at your option) any later version. *
16  * *
17  ***************************************************************************/
18 
19 #ifndef QGSVECTORLAYER_H
20 #define QGSVECTORLAYER_H
21 
22 #include <QMap>
23 #include <QSet>
24 #include <QList>
25 #include <QStringList>
26 #include <QFont>
27 
28 #include "qgis.h"
29 #include "qgsmaplayer.h"
30 #include "qgsfeature.h"
31 #include "qgsfeatureiterator.h"
32 #include "qgseditorwidgetconfig.h"
33 #include "qgsfield.h"
34 #include "qgssnapper.h"
36 #include "qgseditformconfig.h"
38 #include "qgsaggregatecalculator.h"
39 
40 class QPainter;
41 class QImage;
42 
44 class QgsActionManager;
47 class QgsCurveV2;
53 class QgsFeatureRequest;
54 class QgsGeometry;
55 class QgsGeometryCache;
56 class QgsGeometryVertexIndex;
57 class QgsLabel;
58 class QgsMapToPixel;
59 class QgsRectangle;
60 class QgsRectangle;
61 class QgsRelation;
62 class QgsRelationManager;
64 class QgsSymbolV2;
69 class QgsPointV2;
70 
74 
75 
76 struct CORE_EXPORT QgsVectorJoinInfo
77 {
90 
95 
100 
101  bool operator==( const QgsVectorJoinInfo& other ) const
102  {
103  return targetFieldName == other.targetFieldName &&
104  joinLayerId == other.joinLayerId &&
105  joinFieldName == other.joinFieldName &&
106  joinFieldsSubset == other.joinFieldsSubset &&
107  memoryCache == other.memoryCache &&
108  prefix == other.prefix;
109  }
110 
113  void setJoinFieldNamesSubset( QStringList* fieldNamesSubset ) { joinFieldsSubset = QSharedPointer<QStringList>( fieldNamesSubset ); }
116  QStringList* joinFieldNamesSubset() const { return joinFieldsSubset.data(); }
117 
118 protected:
121 };
122 
123 
124 
397 class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
398 {
399  Q_OBJECT
400 
401  public:
402 
405 
407  {
408  GeneratedLayout = 0,
409  TabLayout = 1,
410  UiFileLayout = 2
411  };
412 
413  struct RangeData
414  {
416  Q_DECL_DEPRECATED RangeData() { mMin = QVariant( 0 ); mMax = QVariant( 5 ); mStep = QVariant( 1 );}
418  Q_DECL_DEPRECATED RangeData( const QVariant& theMin, const QVariant& theMax, const QVariant& theStep )
419  : mMin( theMin )
420  , mMax( theMax )
421  , mStep( theStep )
422  {}
423 
427  };
428 
430  {
432  : mAllowNull( false )
433  , mOrderByValue( false )
434  , mAllowMulti( false )
435  {}
436  ValueRelationData( const QString& layer, const QString& key, const QString& value, bool allowNull, bool orderByValue,
437  bool allowMulti = false,
438  const QString& filterExpression = QString::null )
439  : mLayer( layer )
440  , mKey( key )
441  , mValue( value )
442  , mFilterExpression( filterExpression )
443  , mAllowNull( allowNull )
444  , mOrderByValue( orderByValue )
445  , mAllowMulti( allowMulti )
446  {}
447 
454  bool mAllowMulti; /* allow selection of multiple keys */
455  };
456 
463  {
464  SuppressDefault = 0, // use the application-wide setting
465  SuppressOn = 1,
466  SuppressOff = 2
467  };
468 
472  enum EditType
473  {
495  };
496 
499  {
500  Success = 0,
501  EmptyGeometry = 1,
502  EditFailed = 2,
503  FetchFeatureFailed = 3,
504  InvalidLayer = 4,
505  };
506 
509  {
514  };
515 
529  QgsVectorLayer( const QString& path = QString::null, const QString& baseName = QString::null,
530  const QString& providerLib = QString::null, bool loadDefaultStyleFlag = true );
531 
533  virtual ~QgsVectorLayer();
534 
536  QString storageType() const;
537 
539  QString capabilitiesString() const;
540 
542  QString dataComment() const;
543 
545  void setDisplayField( const QString& fldName = "" );
546 
548  const QString displayField() const;
549 
556  void setDisplayExpression( const QString &displayExpression );
557 
564  const QString displayExpression();
565 
567  QgsVectorDataProvider* dataProvider();
568 
572  const QgsVectorDataProvider* dataProvider() const;
573 
575  void setProviderEncoding( const QString& encoding );
576 
578  void setCoordinateSystem();
579 
583  bool addJoin( const QgsVectorJoinInfo& joinInfo );
584 
587  bool removeJoin( const QString& joinLayerId );
588 
589  const QList<QgsVectorJoinInfo> vectorJoins() const;
590 
594  virtual QSet<QString> layerDependencies() const;
595 
606  int addExpressionField( const QString& exp, const QgsField& fld );
607 
615  void removeExpressionField( int index );
616 
626  QString expressionField( int index );
627 
637  void updateExpressionField( int index, const QString& exp );
638 
640  QgsLabel *label();
641 
645  const QgsLabel *label() const;
646 
653  QgsActionManager* actions() { return mActions; }
654 
660  int selectedFeatureCount();
661 
672  Q_DECL_DEPRECATED void select( QgsRectangle & rect, bool addToSelection );
673 
683  void selectByRect( QgsRectangle & rect, SelectBehaviour behaviour = SetSelection );
684 
693  void selectByExpression( const QString& expression, SelectBehaviour behaviour = SetSelection );
694 
704  void selectByIds( const QgsFeatureIds &ids, SelectBehaviour behaviour = SetSelection );
705 
718  void modifySelection( QgsFeatureIds selectIds, QgsFeatureIds deselectIds );
719 
721  void invertSelection();
722 
724  void selectAll();
725 
727  QgsFeatureIds allFeatureIds();
728 
736  void invertSelectionInRectangle( QgsRectangle & rect );
737 
746  QgsFeatureList selectedFeatures();
747 
759  QgsFeatureIterator selectedFeaturesIterator( QgsFeatureRequest request = QgsFeatureRequest() );
760 
767  const QgsFeatureIds &selectedFeaturesIds() const;
768 
777  Q_DECL_DEPRECATED void setSelectedFeatures( const QgsFeatureIds &ids );
778 
780  QgsRectangle boundingBoxOfSelected();
781 
786  bool labelsEnabled() const;
787 
792  bool diagramsEnabled() const;
793 
795  void setDiagramRenderer( QgsDiagramRendererV2* r );
796  const QgsDiagramRendererV2* diagramRenderer() const { return mDiagramRenderer; }
797 
798  void setDiagramLayerSettings( const QgsDiagramLayerSettings& s );
799  const QgsDiagramLayerSettings *diagramLayerSettings() const { return mDiagramLayerSettings; }
800 
802  QgsFeatureRendererV2* rendererV2() { return mRendererV2; }
803 
807  const QgsFeatureRendererV2* rendererV2() const { return mRendererV2; }
808 
813  void setRendererV2( QgsFeatureRendererV2* r );
814 
816  QGis::GeometryType geometryType() const;
817 
819  bool hasGeometryType() const;
820 
822  QGis::WkbType wkbType() const;
823 
825  QString providerType() const;
826 
830  virtual bool readXml( const QDomNode& layer_node ) override;
831 
835  virtual bool writeXml( QDomNode & layer_node, QDomDocument & doc ) override;
836 
845  virtual void saveStyleToDatabase( const QString& name, const QString& description,
846  bool useAsDefault, const QString& uiFileContent,
847  QString &msgError );
848 
857  virtual int listStylesInDatabase( QStringList &ids, QStringList &names,
858  QStringList &descriptions, QString &msgError );
859 
863  virtual QString getStyleFromDatabase( const QString& styleId, QString &msgError );
864 
871  virtual QString loadNamedStyle( const QString &theURI, bool &theResultFlag, bool loadFromLocalDb );
872 
877  virtual QString loadNamedStyle( const QString &theURI, bool &theResultFlag ) override;
878 
889  Q_DECL_DEPRECATED virtual bool applyNamedStyle( const QString& namedStyle, QString &errorMsg );
890 
895  QgsAttributeEditorElement* attributeEditorElementFromDomElement( QDomElement &elem, QObject* parent ) { return mEditFormConfig->attributeEditorElementFromDomElement( elem, parent ); }
896 
902  bool readSymbology( const QDomNode& node, QString& errorMessage ) override;
903 
909  bool readStyle( const QDomNode& node, QString& errorMessage ) override;
910 
917  bool writeSymbology( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const override;
918 
925  bool writeStyle( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const override;
926 
927  bool writeSld( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const;
928  bool readSld( const QDomNode& node, QString& errorMessage ) override;
929 
936  long featureCount( QgsSymbolV2* symbol );
937 
948  void setDataSource( const QString& dataSource, const QString& baseName, const QString& provider, bool loadDefaultStyleFlag = false );
949 
955  bool countSymbolFeatures( bool showProgress = true );
956 
964  virtual bool setSubsetString( const QString& subset );
965 
970  virtual QString subsetString();
971 
975  QgsFeatureIterator getFeatures( const QgsFeatureRequest& request = QgsFeatureRequest() );
976 
982  bool addFeature( QgsFeature& f, bool alsoUpdateExtent = true );
983 
990  bool updateFeature( QgsFeature &f );
991 
996  bool insertVertex( double x, double y, QgsFeatureId atFeatureId, int beforeVertex );
997 
1002  bool moveVertex( double x, double y, QgsFeatureId atFeatureId, int atVertex );
1003 
1009  bool moveVertex( const QgsPointV2& p, QgsFeatureId atFeatureId, int atVertex );
1010 
1014  Q_DECL_DEPRECATED bool deleteVertex( QgsFeatureId atFeatureId, int atVertex );
1015 
1021  //TODO QGIS 3.0 - rename back to deleteVertex
1022  EditResult deleteVertexV2( QgsFeatureId featureId, int vertex );
1023 
1027  bool deleteSelectedFeatures( int *deletedCount = nullptr );
1028 
1041  // TODO QGIS 3.0 returns an enum instead of a magic constant
1042  int addRing( const QList<QgsPoint>& ring, QgsFeatureId* featureId = nullptr );
1043 
1054  // TODO QGIS 3.0 returns an enum instead of a magic constant
1055  int addRing( QgsCurveV2* ring, QgsFeatureId* featureId = nullptr );
1056 
1068  // TODO QGIS 3.0 returns an enum instead of a magic constant
1069  int addPart( const QList<QgsPoint>& ring );
1070 
1083  // TODO QGIS 3.0 returns an enum instead of a magic constant
1084  int addPart( const QgsPointSequenceV2 &ring );
1085 
1087  int addPart( QgsCurveV2* ring );
1088 
1095  int translateFeature( QgsFeatureId featureId, double dx, double dy );
1096 
1104  // TODO QGIS 3.0 returns an enum instead of a magic constant
1105  int splitParts( const QList<QgsPoint>& splitLine, bool topologicalEditing = false );
1106 
1114  // TODO QGIS 3.0 returns an enum instead of a magic constant
1115  int splitFeatures( const QList<QgsPoint>& splitLine, bool topologicalEditing = false );
1116 
1125  Q_DECL_DEPRECATED int removePolygonIntersections( QgsGeometry* geom, const QgsFeatureIds& ignoreFeatures = QgsFeatureIds() );
1126 
1132  int addTopologicalPoints( const QgsGeometry* geom );
1133 
1141  int addTopologicalPoints( const QgsPoint& p );
1142 
1148  int insertSegmentVerticesForSnap( const QList<QgsSnappingResult>& snapResults );
1149 
1153  Q_DECL_DEPRECATED void enableLabels( bool on );
1154 
1158  Q_DECL_DEPRECATED bool hasLabelsEnabled() const;
1159 
1164  const QgsAbstractVectorLayerLabeling* labeling() const { return mLabeling; }
1165 
1170  void setLabeling( QgsAbstractVectorLayerLabeling* labeling );
1171 
1173  virtual bool isEditable() const override;
1174 
1175  virtual bool isSpatial() const override;
1176 
1184  Q_DECL_DEPRECATED virtual bool isReadOnly() const override;
1185 
1187  virtual bool isModified() const;
1188 
1195  bool snapPoint( QgsPoint& point, double tolerance );
1196 
1204  int snapWithContext( const QgsPoint& startPoint,
1205  double snappingTolerance,
1206  QMultiMap < double, QgsSnappingResult > &snappingResults,
1207  QgsSnapper::SnappingType snap_to );
1208 
1210  virtual void reload() override;
1211 
1215  virtual QgsMapLayerRenderer* createMapRenderer( QgsRenderContext& rendererContext ) override;
1216 
1220  bool draw( QgsRenderContext& rendererContext ) override;
1221 
1225  Q_DECL_DEPRECATED void drawLabels( QgsRenderContext& rendererContext ) override;
1226 
1228  QgsRectangle extent() override;
1229 
1236  inline QgsFields fields() const { return mUpdatedFields; }
1237 
1245  inline QgsFields pendingFields() const { return mUpdatedFields; }
1246 
1251  inline QgsAttributeList pendingAllAttributesList() const { return mUpdatedFields.allAttributesList(); }
1252 
1257  inline QgsAttributeList attributeList() const { return mUpdatedFields.allAttributesList(); }
1258 
1263  inline QgsAttributeList pendingPkAttributesList() const { return pkAttributeList(); }
1264 
1266  QgsAttributeList pkAttributeList() const;
1267 
1272  inline long pendingFeatureCount() const { return featureCount(); }
1273 
1278  long featureCount() const;
1279 
1283  bool setReadOnly( bool readonly = true );
1284 
1286  bool changeGeometry( QgsFeatureId fid, QgsGeometry* geom );
1287 
1294  Q_DECL_DEPRECATED bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant& value, bool emitSignal );
1295 
1306  bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant() );
1307 
1311  bool addAttribute( const QgsField &field );
1312 
1314  void addAttributeAlias( int attIndex, const QString& aliasString );
1315 
1317  void remAttributeAlias( int attIndex );
1318 
1324  Q_DECL_DEPRECATED void addAttributeEditorWidget( QgsAttributeEditorElement* data ) {mEditFormConfig->addTab( data );}
1325 
1335  Q_DECL_DEPRECATED const QString editorWidgetV2( int fieldIdx ) const { return mEditFormConfig->widgetType( fieldIdx ); }
1336 
1348  Q_DECL_DEPRECATED const QString editorWidgetV2( const QString& fieldName ) const { return mEditFormConfig->widgetType( fieldName ); }
1349 
1359  Q_DECL_DEPRECATED const QgsEditorWidgetConfig editorWidgetV2Config( int fieldIdx ) const { return mEditFormConfig->widgetConfig( fieldIdx ); }
1360 
1372  Q_DECL_DEPRECATED const QgsEditorWidgetConfig editorWidgetV2Config( const QString& fieldName ) const { return mEditFormConfig->widgetConfig( fieldName ); }
1373 
1379  Q_DECL_DEPRECATED QList< QgsAttributeEditorElement* > attributeEditorElements() { return mEditFormConfig->tabs(); }
1380 
1389  QgsEditFormConfig* editFormConfig() const { return mEditFormConfig; }
1390 
1394  void clearAttributeEditorWidgets() { mEditFormConfig->clearTabs(); }
1395 
1402  QString attributeAlias( int attributeIndex ) const;
1403 
1405  QString attributeDisplayName( int attributeIndex ) const;
1406 
1407  const QMap< QString, QString >& attributeAliases() const { return mAttributeAliasMap; }
1408 
1409  const QSet<QString>& excludeAttributesWMS() const { return mExcludeAttributesWMS; }
1410  void setExcludeAttributesWMS( const QSet<QString>& att ) { mExcludeAttributesWMS = att; }
1411 
1412  const QSet<QString>& excludeAttributesWFS() const { return mExcludeAttributesWFS; }
1413  void setExcludeAttributesWFS( const QSet<QString>& att ) { mExcludeAttributesWFS = att; }
1414 
1416  bool deleteAttribute( int attr );
1417 
1425  bool deleteAttributes( QList<int> attrs );
1426 
1428  bool addFeatures( QgsFeatureList features, bool makeSelected = true );
1429 
1431  bool deleteFeature( QgsFeatureId fid );
1432 
1440  bool deleteFeatures( const QgsFeatureIds& fids );
1441 
1457  bool commitChanges();
1458  const QStringList &commitErrors();
1459 
1463  bool rollBack( bool deleteBuffer = true );
1464 
1470  Q_DECL_DEPRECATED EditType editType( int idx );
1471 
1477  Q_DECL_DEPRECATED void setEditType( int idx, EditType edit );
1478 
1483  Q_DECL_DEPRECATED EditorLayout editorLayout() { return static_cast< EditorLayout >( mEditFormConfig->layout() ); }
1484 
1489  Q_DECL_DEPRECATED void setEditorLayout( EditorLayout editorLayout ) { mEditFormConfig->setLayout( static_cast< QgsEditFormConfig::EditorLayout >( editorLayout ) ); }
1490 
1521  Q_DECL_DEPRECATED void setEditorWidgetV2( int attrIdx, const QString& widgetType ) { mEditFormConfig->setWidgetType( attrIdx, widgetType ); }
1522 
1540  Q_DECL_DEPRECATED void setEditorWidgetV2Config( int attrIdx, const QgsEditorWidgetConfig& config ) { mEditFormConfig->setWidgetConfig( attrIdx, config ); }
1541 
1547  Q_DECL_DEPRECATED void setCheckedState( int idx, const QString& checked, const QString& notChecked );
1548 
1554  Q_DECL_DEPRECATED QString editForm() const { return mEditFormConfig->uiForm(); }
1555 
1560  Q_DECL_DEPRECATED void setEditForm( const QString& ui ) { mEditFormConfig->setUiForm( ui ); }
1561 
1566  Q_DECL_DEPRECATED QgsVectorLayer::FeatureFormSuppress featureFormSuppress() const { return static_cast< FeatureFormSuppress >( mEditFormConfig->suppress() ); }
1567 
1572  Q_DECL_DEPRECATED void setFeatureFormSuppress( QgsVectorLayer::FeatureFormSuppress s ) { mEditFormConfig->setSuppress( static_cast< QgsEditFormConfig::FeatureFormSuppress >( s ) ); }
1573 
1575  QString annotationForm() const { return mAnnotationForm; }
1576 
1578  void setAnnotationForm( const QString& ui );
1579 
1585  Q_DECL_DEPRECATED QString editFormInit() const { return mEditFormConfig->initFunction(); }
1586 
1592  Q_DECL_DEPRECATED void setEditFormInit( const QString& function ) { mEditFormConfig->setInitFunction( function ); }
1593 
1598  Q_DECL_DEPRECATED QMap<QString, QVariant> valueMap( int idx );
1599 
1605  Q_DECL_DEPRECATED RangeData range( int idx );
1606 
1608  ValueRelationData valueRelation( int idx );
1609 
1616  QList<QgsRelation> referencingRelations( int idx );
1617 
1623  Q_DECL_DEPRECATED QString dateFormat( int idx );
1624 
1630  Q_DECL_DEPRECATED QSize widgetSize( int idx );
1631 
1637  Q_DECL_DEPRECATED bool fieldEditable( int idx ) { return !mEditFormConfig->readOnly( idx ); }
1638 
1643  Q_DECL_DEPRECATED bool labelOnTop( int idx ) { return mEditFormConfig->labelOnTop( idx ); }
1644 
1649  Q_DECL_DEPRECATED void setFieldEditable( int idx, bool editable ) { mEditFormConfig->setReadOnly( idx, !editable ); }
1650 
1655  Q_DECL_DEPRECATED void setLabelOnTop( int idx, bool onTop ) { mEditFormConfig->setLabelOnTop( idx, onTop ); }
1656 
1658  QgsVectorLayerEditBuffer* editBuffer() { return mEditBuffer; }
1659 
1664  void beginEditCommand( const QString& text );
1665 
1667  void endEditCommand();
1668 
1670  void destroyEditCommand();
1671 
1673  int fieldNameIndex( const QString& fieldName ) const;
1674 
1677  {
1680  NoMarker
1681  };
1682 
1684  static void drawVertexMarker( double x, double y, QPainter& p, QgsVectorLayer::VertexMarkerType type, int vertexSize );
1685 
1687  void updateFields();
1688 
1690  void createJoinCaches();
1691 
1697  void uniqueValues( int index, QList<QVariant> &uniqueValues, int limit = -1 );
1698 
1700  QVariant minimumValue( int index );
1701 
1703  QVariant maximumValue( int index );
1704 
1714  QVariant aggregate( QgsAggregateCalculator::Aggregate aggregate,
1715  const QString& fieldOrExpression,
1717  QgsExpressionContext* context = nullptr,
1718  bool* ok = nullptr );
1719 
1728  QList< QVariant > getValues( const QString &fieldOrExpression, bool &ok, bool selectedOnly = false );
1729 
1740  QList< double > getDoubleValues( const QString &fieldOrExpression, bool &ok, bool selectedOnly = false, int* nullCount = nullptr );
1741 
1743  void setFeatureBlendMode( QPainter::CompositionMode blendMode );
1745  QPainter::CompositionMode featureBlendMode() const;
1746 
1748  void setLayerTransparency( int layerTransparency );
1750  int layerTransparency() const;
1751 
1752  QString metadata() override;
1753 
1755  inline QgsGeometryCache* cache() { return mCache; }
1756 
1760  void setSimplifyMethod( const QgsVectorSimplifyMethod& simplifyMethod ) { mSimplifyMethod = simplifyMethod; }
1764  inline const QgsVectorSimplifyMethod& simplifyMethod() const { return mSimplifyMethod; }
1765 
1770  bool simplifyDrawingCanbeApplied( const QgsRenderContext& renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint ) const;
1771 
1779  QgsConditionalLayerStyles *conditionalStyles() const;
1780 
1785  QgsAttributeTableConfig attributeTableConfig() const;
1786 
1791  void setAttributeTableConfig( const QgsAttributeTableConfig& attributeTableConfig );
1792 
1793  public slots:
1801  void select( QgsFeatureId featureId );
1802 
1810  void select( const QgsFeatureIds& featureIds );
1811 
1819  void deselect( const QgsFeatureId featureId );
1820 
1828  void deselect( const QgsFeatureIds& featureIds );
1829 
1835  void removeSelection();
1836 
1840  virtual void updateExtents();
1841 
1843  void checkJoinLayerRemove( const QString& theLayerId );
1844 
1851  bool startEditing();
1852 
1853 
1854  protected slots:
1855  void invalidateSymbolCountedFlag();
1856 
1857  signals:
1858 
1866  void selectionChanged( const QgsFeatureIds& selected, const QgsFeatureIds& deselected, const bool clearAndSelect );
1867 
1869  void selectionChanged();
1870 
1872  void layerModified();
1873 
1875  void beforeModifiedCheck() const;
1876 
1878  void beforeEditingStarted();
1879 
1881  void editingStarted();
1882 
1884  void editingStopped();
1885 
1887  void beforeCommitChanges();
1888 
1890  void beforeRollBack();
1891 
1900  void attributeAdded( int idx );
1901 
1908  void beforeAddingExpressionField( const QString& fieldName );
1909 
1918  void attributeDeleted( int idx );
1919 
1926  void beforeRemovingExpressionField( int idx );
1927 
1933  void featureAdded( QgsFeatureId fid );
1934 
1943  void featureDeleted( QgsFeatureId fid );
1944 
1954  void featuresDeleted( const QgsFeatureIds& fids );
1955 
1960  void updatedFields();
1961 
1965  void layerDeleted();
1966 
1967  void attributeValueChanged( QgsFeatureId fid, int idx, const QVariant & );
1968  void geometryChanged( QgsFeatureId fid, QgsGeometry &geom );
1969 
1971  void committedAttributesDeleted( const QString& layerId, const QgsAttributeList& deletedAttributes );
1972  void committedAttributesAdded( const QString& layerId, const QList<QgsField>& addedAttributes );
1973  void committedFeaturesAdded( const QString& layerId, const QgsFeatureList& addedFeatures );
1974  void committedFeaturesRemoved( const QString& layerId, const QgsFeatureIds& deletedFeatureIds );
1975  void committedAttributeValuesChanges( const QString& layerId, const QgsChangedAttributesMap& changedAttributesValues );
1976  void committedGeometriesChanges( const QString& layerId, const QgsGeometryMap& changedGeometries );
1977 
1978  void saveLayerToProject();
1979 
1981  void labelingFontNotFound( QgsVectorLayer* layer, const QString& fontfamily );
1982 
1984  void featureBlendModeChanged( QPainter::CompositionMode blendMode );
1985 
1987  void layerTransparencyChanged( int layerTransparency );
1988 
1994  void editCommandStarted( const QString& text );
1995 
2001  void editCommandEnded();
2002 
2008  void editCommandDestroyed();
2009 
2019  void readCustomSymbology( const QDomElement& element, QString& errorMessage );
2020 
2030  void writeCustomSymbology( QDomElement& element, QDomDocument& doc, QString& errorMessage ) const;
2031 
2035  void raiseError( const QString& msg );
2036 
2037  private slots:
2038  void onJoinedFieldsChanged();
2039  void onFeatureDeleted( QgsFeatureId fid );
2040 
2041  protected:
2043  void setExtent( const QgsRectangle &rect ) override;
2044 
2045  private: // Private methods
2046 
2048  QgsVectorLayer( const QgsVectorLayer & rhs );
2049 
2051  QgsVectorLayer & operator=( QgsVectorLayer const & rhs );
2052 
2053 
2058  bool setDataProvider( QString const & provider );
2059 
2061  QgsFeatureId findFreeId();
2062 
2071  void snapToGeometry( const QgsPoint& startPoint,
2072  QgsFeatureId featureId,
2073  const QgsGeometry *geom,
2074  double sqrSnappingTolerance,
2075  QMultiMap<double, QgsSnappingResult>& snappingResults,
2076  QgsSnapper::SnappingType snap_to ) const;
2077 
2079  //void addJoinedAttributes( QgsFeature& f, bool all = false );
2080 
2082  void readSldLabeling( const QDomNode& node );
2083 
2084  private: // Private attributes
2085 
2086  QgsConditionalLayerStyles * mConditionalStyles;
2087 
2089  QgsVectorDataProvider *mDataProvider;
2090 
2092  QString mDisplayField;
2093 
2095  QString mDisplayExpression;
2096 
2098  QString mProviderKey;
2099 
2101  QgsActionManager* mActions;
2102 
2104  bool mReadOnly;
2105 
2110  QgsFeatureIds mSelectedFeatureIds;
2111 
2113  QgsFields mUpdatedFields;
2114 
2116  QMap< QString, QString > mAttributeAliasMap;
2117 
2119  QgsEditFormConfig* mEditFormConfig;
2120 
2122  QSet<QString> mExcludeAttributesWMS;
2123 
2125  QSet<QString> mExcludeAttributesWFS;
2126 
2128  QGis::WkbType mWkbType;
2129 
2131  QgsFeatureRendererV2 *mRendererV2;
2132 
2134  QgsVectorSimplifyMethod mSimplifyMethod;
2135 
2137  QgsLabel *mLabel;
2138 
2140  bool mLabelOn;
2141 
2143  QgsAbstractVectorLayerLabeling* mLabeling;
2144 
2146  bool mLabelFontNotFoundNotified;
2147 
2149  QPainter::CompositionMode mFeatureBlendMode;
2150 
2152  int mLayerTransparency;
2153 
2155  bool mVertexMarkerOnlyForSelection;
2156 
2157  QStringList mCommitErrors;
2158 
2160  QString mAnnotationForm;
2161 
2163  QgsGeometryCache* mCache;
2164 
2166  QgsVectorLayerEditBuffer* mEditBuffer;
2168 
2169  //stores information about joined layers
2170  QgsVectorLayerJoinBuffer* mJoinBuffer;
2171 
2173  QgsExpressionFieldBuffer* mExpressionFieldBuffer;
2174 
2175  //diagram rendering object. 0 if diagram drawing is disabled
2176  QgsDiagramRendererV2* mDiagramRenderer;
2177 
2178  //stores infos about diagram placement (placement type, priority, position distance)
2179  QgsDiagramLayerSettings *mDiagramLayerSettings;
2180 
2181  bool mValidExtent;
2182  bool mLazyExtent;
2183 
2184  // Features in renderer classes counted
2185  bool mSymbolFeatureCounted;
2186 
2187  // Feature counts for each renderer symbol
2188  QMap<QgsSymbolV2*, long> mSymbolFeatureCountMap;
2189 
2191  bool mEditCommandActive;
2192 
2193  QgsFeatureIds mDeletedFids;
2194 
2195  QgsAttributeTableConfig mAttributeTableConfig;
2196 
2198 };
2199 
2200 #endif
QgsActionManager * actions()
Get all layer actions defined on this layer.
Wrapper for iterator of features from vector data provider or vector layer.
QString annotationForm() const
Get annotation form.
static unsigned index
A rectangle specified with double values.
Definition: qgsrectangle.h:35
Base class for all map layer types.
Definition: qgsmaplayer.h:49
QgsAttributeList attributeList() const
Returns list of attribute indexes.
QString joinFieldName
Join field in the source layer.
const QSet< QString > & excludeAttributesWMS() const
void clearAttributeEditorWidgets()
Clears all the tabs for the attribute editor form.
void setExcludeAttributesWFS(const QSet< QString > &att)
This is an abstract base class for any elements of a drag and drop form.
QString targetFieldName
Join field in the target layer.
GeometryType
Definition: qgis.h:115
ValueRelationData(const QString &layer, const QString &key, const QString &value, bool allowNull, bool orderByValue, bool allowMulti=false, const QString &filterExpression=QString::null)
Modify current selection to include only select features which match.
Q_DECL_DEPRECATED const QString editorWidgetV2(int fieldIdx) const
Get the id for the editor widget used to represent the field at the given index.
QgsEditFormConfig::GroupData GroupData
The attribute value should not be changed in the attribute form.
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:439
QgsFields fields() const
Returns the list of fields of this layer.
Manages an editor widget Widget and wrapper share the same parent.
Q_DECL_DEPRECATED void addAttributeEditorWidget(QgsAttributeEditorElement *data)
Adds a tab (for the attribute editor form) holding groups and fields.
void setExcludeAttributesWMS(const QSet< QString > &att)
int joinFieldIndex
Join field index in the source layer.
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings for fast rendering of features.
QgsAttributeList pendingPkAttributesList() const
Returns list of attributes making up the primary key Alias for pkAttributeList(). ...
VertexMarkerType
Editing vertex markers.
SimplifyHint
Simplification flags for fast rendering of features.
Container of fields for a vector layer.
Definition: qgsfield.h:193
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:76
Q_DECL_DEPRECATED void setEditForm(const QString &ui)
Set edit form.
WkbType
Used for symbology operations.
Definition: qgis.h:61
Set selection, removing any existing selection.
bool memoryCache
True if the join is cached in virtual memory.
int targetFieldIndex
Join field index in the target layer.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:187
QgsEditFormConfig * editFormConfig() const
Get the configuration of the form used to represent this vector layer.
const QgsDiagramLayerSettings * diagramLayerSettings() const
Q_DECL_DEPRECATED void setFieldEditable(int idx, bool editable)
Set edit widget editable.
QgsGeometryCache * cache()
Evaluates and returns the diagram settings relating to a diagram for a specific feature.
Q_DECL_DEPRECATED const QgsEditorWidgetConfig editorWidgetV2Config(const QString &fieldName) const
Get the configuration for the editor widget used to represent the field with the given name...
Manages joined fields for a vector layer.
Q_DECL_DEPRECATED void setEditorWidgetV2(int attrIdx, const QString &widgetType)
Set the editor widget type for a field.
Q_DECL_DEPRECATED const QString editorWidgetV2(const QString &fieldName) const
Get the id for the editor widget used to represent the field at the given index.
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:34
SnappingType
Snap to vertex, to segment or both.
Definition: qgssnapper.h: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
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Q_DECL_DEPRECATED void setEditFormInit(const QString &function)
Set python function for edit form initialization.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QgsAttributeEditorElement * attributeEditorElementFromDomElement(QDomElement &elem, QObject *parent)
Convert a saved attribute editor element into a AttributeEditor structure as it&#39;s used internally...
Q_DECL_DEPRECATED bool fieldEditable(int idx)
Is edit widget editable.
Storage and management of actions associated with a layer.
QSharedPointer< QStringList > joinFieldsSubset
Subset of fields to use from joined layer.
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:44
Q_DECL_DEPRECATED bool labelOnTop(int idx)
Label widget on top.
const QgsFeatureRendererV2 * rendererV2() const
Return const renderer V2.
const QMap< QString, QString > & attributeAliases() const
const QgsDiagramRendererV2 * diagramRenderer() const
A class to represent a point.
Definition: qgspoint.h:117
Q_DECL_DEPRECATED void setEditorWidgetV2Config(int attrIdx, const QgsEditorWidgetConfig &config)
Set the editor widget config for a field.
QgsAttributeList pendingAllAttributesList() const
Returns list of attribute indexes.
Partial snapshot of vector layer&#39;s state (only the members necessary for access to features) ...
A class to render labels.
Definition: qgslabel.h:51
Stores the settings for rendering of all diagrams for a layer.
uuid generator - readonly and automatically intialized
SelectBehaviour
Selection behaviour.
long pendingFeatureCount() const
Returns feature count including changes which have not yet been committed Alias for featureCount()...
Add selection to current selection.
This class contains information how to simplify geometries fetched from a vector layer.
Contains information about the context of a rendering operation.
Buffers information about expression fields for a vector layer.
QHash< QString, QgsAttributes > cachedAttributes
Cache for joined attributes to provide fast lookup (size is 0 if no memory caching) ...
Q_DECL_DEPRECATED QString editFormInit() const
Get python function for edit form initialization.
Q_DECL_DEPRECATED const QgsEditorWidgetConfig editorWidgetV2Config(int fieldIdx) const
Get the configuration for the editor widget used to represent the field at the given index...
This class manages a set of relations between layers.
The QgsConditionalLayerStyles class holds conditional style information for a layer.
Q_DECL_DEPRECATED EditorLayout editorLayout()
Get the active layout for the attribute editor for this layer.
Abstract base class - its implementations define different approaches to the labeling of a vector lay...
Class for doing transforms between two map coordinate systems.
void setSimplifyMethod(const QgsVectorSimplifyMethod &simplifyMethod)
Set the simplification settings for fast rendering of features.
qint64 QgsFeatureId
Definition: qgsfeature.h:31
Q_DECL_DEPRECATED QgsVectorLayer::FeatureFormSuppress featureFormSuppress() const
Type of feature form pop-up suppression after feature creation (overrides app setting) ...
Base class for utility classes that encapsulate information necessary for rendering of map layers...
Remove from current selection.
QStringList * joinFieldNamesSubset() const
Get subset of fields to be used from joined layer.
QSet< int > QgsAttributeIds
Q_DECL_DEPRECATED QString editForm() const
Get edit form.
This is a container for configuration of the attribute table.
FeatureFormSuppress
Types of feature form suppression after feature creation.
This is the base class for vector data providers.
Abstract base class for curved geometry type.
Definition: qgscurvev2.h:32
QList< int > QgsAttributeList
Represents a vector layer which manages a vector based data sets.
modularized edit widgets
EditResult
Result of an edit operation.
QString joinLayerId
Source layer.
Q_DECL_DEPRECATED void setEditorLayout(EditorLayout editorLayout)
Set the active layout for the attribute editor for this layer.
value map from an table
Abstract base class for simplify geometries using a specific algorithm.
Aggregate
Available aggregates to calculate.
QgsEditFormConfig::TabData TabData
QList< QgsPointV2 > QgsPointSequenceV2
A bundle of parameters controlling aggregate calculation.
Q_DECL_DEPRECATED RangeData()