QGIS API Documentation  2.14.11-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 
566  QgsVectorLayerJoinBuffer* joinBuffer() { return mJoinBuffer; }
567  const QList<QgsVectorJoinInfo> vectorJoins() const;
568 
572  virtual QSet<QString> layerDependencies() const;
573 
584  int addExpressionField( const QString& exp, const QgsField& fld );
585 
593  void removeExpressionField( int index );
594 
604  QString expressionField( int index );
605 
615  void updateExpressionField( int index, const QString& exp );
616 
618  QgsLabel *label();
619 
623  const QgsLabel *label() const;
624 
625  QgsAttributeAction *actions() { return mActions; }
626 
632  int selectedFeatureCount();
633 
642  void select( QgsRectangle & rect, bool addToSelection );
643 
655  void modifySelection( QgsFeatureIds selectIds, QgsFeatureIds deselectIds );
656 
658  void invertSelection();
659 
661  void selectAll();
662 
664  QgsFeatureIds allFeatureIds();
665 
673  void invertSelectionInRectangle( QgsRectangle & rect );
674 
683  QgsFeatureList selectedFeatures();
684 
696  QgsFeatureIterator selectedFeaturesIterator( QgsFeatureRequest request = QgsFeatureRequest() );
697 
704  const QgsFeatureIds &selectedFeaturesIds() const;
705 
713  void setSelectedFeatures( const QgsFeatureIds &ids );
714 
716  QgsRectangle boundingBoxOfSelected();
717 
722  bool labelsEnabled() const;
723 
728  bool diagramsEnabled() const;
729 
731  void setDiagramRenderer( QgsDiagramRendererV2* r );
732  const QgsDiagramRendererV2* diagramRenderer() const { return mDiagramRenderer; }
733 
734  void setDiagramLayerSettings( const QgsDiagramLayerSettings& s );
735  const QgsDiagramLayerSettings *diagramLayerSettings() const { return mDiagramLayerSettings; }
736 
738  QgsFeatureRendererV2* rendererV2() { return mRendererV2; }
739 
743  const QgsFeatureRendererV2* rendererV2() const { return mRendererV2; }
744 
749  void setRendererV2( QgsFeatureRendererV2* r );
750 
752  QGis::GeometryType geometryType() const;
753 
755  bool hasGeometryType() const;
756 
758  QGis::WkbType wkbType() const;
759 
761  QString providerType() const;
762 
766  virtual bool readXml( const QDomNode& layer_node ) override;
767 
771  virtual bool writeXml( QDomNode & layer_node, QDomDocument & doc ) override;
772 
781  virtual void saveStyleToDatabase( const QString& name, const QString& description,
782  bool useAsDefault, const QString& uiFileContent,
783  QString &msgError );
784 
793  virtual int listStylesInDatabase( QStringList &ids, QStringList &names,
794  QStringList &descriptions, QString &msgError );
795 
799  virtual QString getStyleFromDatabase( const QString& styleId, QString &msgError );
800 
807  virtual QString loadNamedStyle( const QString &theURI, bool &theResultFlag, bool loadFromLocalDb );
808 
813  virtual QString loadNamedStyle( const QString &theURI, bool &theResultFlag ) override;
814 
825  Q_DECL_DEPRECATED virtual bool applyNamedStyle( const QString& namedStyle, QString &errorMsg );
826 
831  QgsAttributeEditorElement* attributeEditorElementFromDomElement( QDomElement &elem, QObject* parent ) { return mEditFormConfig->attributeEditorElementFromDomElement( elem, parent ); }
832 
838  bool readSymbology( const QDomNode& node, QString& errorMessage ) override;
839 
846  bool writeSymbology( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const override;
847 
848 
856  bool writeSld( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const;
857 
866  bool writeSld( QDomNode& node, QDomDocument& doc, QString& errorMessage, const QgsStringMap& props ) const;
867 
875  bool readSld( const QDomNode& node, QString& errorMessage ) override;
876 
883  long featureCount( QgsSymbolV2* symbol );
884 
895  void setDataSource( const QString& dataSource, const QString& baseName, const QString& provider, bool loadDefaultStyleFlag = false );
896 
902  bool countSymbolFeatures( bool showProgress = true );
903 
911  virtual bool setSubsetString( const QString& subset );
912 
917  virtual QString subsetString();
918 
922  QgsFeatureIterator getFeatures( const QgsFeatureRequest& request = QgsFeatureRequest() );
923 
929  bool addFeature( QgsFeature& f, bool alsoUpdateExtent = true );
930 
937  bool updateFeature( QgsFeature &f );
938 
943  bool insertVertex( double x, double y, QgsFeatureId atFeatureId, int beforeVertex );
944 
949  bool moveVertex( double x, double y, QgsFeatureId atFeatureId, int atVertex );
950 
956  bool moveVertex( const QgsPointV2& p, QgsFeatureId atFeatureId, int atVertex );
957 
961  Q_DECL_DEPRECATED bool deleteVertex( QgsFeatureId atFeatureId, int atVertex );
962 
968  //TODO QGIS 3.0 - rename back to deleteVertex
969  EditResult deleteVertexV2( QgsFeatureId featureId, int vertex );
970 
974  bool deleteSelectedFeatures( int *deletedCount = nullptr );
975 
988  // TODO QGIS 3.0 returns an enum instead of a magic constant
989  int addRing( const QList<QgsPoint>& ring, QgsFeatureId* featureId = nullptr );
990 
1001  // TODO QGIS 3.0 returns an enum instead of a magic constant
1002  int addRing( QgsCurveV2* ring, QgsFeatureId* featureId = nullptr );
1003 
1015  // TODO QGIS 3.0 returns an enum instead of a magic constant
1016  int addPart( const QList<QgsPoint>& ring );
1017 
1030  // TODO QGIS 3.0 returns an enum instead of a magic constant
1031  int addPart( const QgsPointSequenceV2 &ring );
1032 
1034  int addPart( QgsCurveV2* ring );
1035 
1042  int translateFeature( QgsFeatureId featureId, double dx, double dy );
1043 
1051  // TODO QGIS 3.0 returns an enum instead of a magic constant
1052  int splitParts( const QList<QgsPoint>& splitLine, bool topologicalEditing = false );
1053 
1061  // TODO QGIS 3.0 returns an enum instead of a magic constant
1062  int splitFeatures( const QList<QgsPoint>& splitLine, bool topologicalEditing = false );
1063 
1072  Q_DECL_DEPRECATED int removePolygonIntersections( QgsGeometry* geom, const QgsFeatureIds& ignoreFeatures = QgsFeatureIds() );
1073 
1079  int addTopologicalPoints( const QgsGeometry* geom );
1080 
1088  int addTopologicalPoints( const QgsPoint& p );
1089 
1095  int insertSegmentVerticesForSnap( const QList<QgsSnappingResult>& snapResults );
1096 
1100  Q_DECL_DEPRECATED void enableLabels( bool on );
1101 
1105  Q_DECL_DEPRECATED bool hasLabelsEnabled() const;
1106 
1111  const QgsAbstractVectorLayerLabeling* labeling() const { return mLabeling; }
1112 
1117  void setLabeling( QgsAbstractVectorLayerLabeling* labeling );
1118 
1120  virtual bool isEditable() const override;
1121 
1123  virtual bool isReadOnly() const;
1124 
1126  virtual bool isModified() const;
1127 
1134  bool snapPoint( QgsPoint& point, double tolerance );
1135 
1143  int snapWithContext( const QgsPoint& startPoint,
1144  double snappingTolerance,
1145  QMultiMap < double, QgsSnappingResult > &snappingResults,
1146  QgsSnapper::SnappingType snap_to );
1147 
1149  virtual void reload() override;
1150 
1154  virtual QgsMapLayerRenderer* createMapRenderer( QgsRenderContext& rendererContext ) override;
1155 
1159  bool draw( QgsRenderContext& rendererContext ) override;
1160 
1164  Q_DECL_DEPRECATED void drawLabels( QgsRenderContext& rendererContext ) override;
1165 
1167  QgsRectangle extent() override;
1168 
1175  inline QgsFields fields() const { return mUpdatedFields; }
1176 
1184  inline QgsFields pendingFields() const { return mUpdatedFields; }
1185 
1190  inline QgsAttributeList pendingAllAttributesList() const { return mUpdatedFields.allAttributesList(); }
1191 
1196  inline QgsAttributeList attributeList() const { return mUpdatedFields.allAttributesList(); }
1197 
1202  inline QgsAttributeList pendingPkAttributesList() const { return pkAttributeList(); }
1203 
1205  QgsAttributeList pkAttributeList() const;
1206 
1211  inline long pendingFeatureCount() const { return featureCount(); }
1212 
1217  long featureCount() const;
1218 
1222  bool setReadOnly( bool readonly = true );
1223 
1225  bool changeGeometry( QgsFeatureId fid, QgsGeometry* geom );
1226 
1233  Q_DECL_DEPRECATED bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant& value, bool emitSignal );
1234 
1245  bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant() );
1246 
1250  bool addAttribute( const QgsField &field );
1251 
1253  void addAttributeAlias( int attIndex, const QString& aliasString );
1254 
1256  void remAttributeAlias( int attIndex );
1257 
1263  Q_DECL_DEPRECATED void addAttributeEditorWidget( QgsAttributeEditorElement* data ) {mEditFormConfig->addTab( data );}
1264 
1274  Q_DECL_DEPRECATED const QString editorWidgetV2( int fieldIdx ) const { return mEditFormConfig->widgetType( fieldIdx ); }
1275 
1287  Q_DECL_DEPRECATED const QString editorWidgetV2( const QString& fieldName ) const { return mEditFormConfig->widgetType( fieldName ); }
1288 
1298  Q_DECL_DEPRECATED const QgsEditorWidgetConfig editorWidgetV2Config( int fieldIdx ) const { return mEditFormConfig->widgetConfig( fieldIdx ); }
1299 
1311  Q_DECL_DEPRECATED const QgsEditorWidgetConfig editorWidgetV2Config( const QString& fieldName ) const { return mEditFormConfig->widgetConfig( fieldName ); }
1312 
1318  Q_DECL_DEPRECATED QList< QgsAttributeEditorElement* > attributeEditorElements() { return mEditFormConfig->tabs(); }
1319 
1326  QgsEditFormConfig* editFormConfig() const { return mEditFormConfig; }
1327 
1331  void clearAttributeEditorWidgets() { mEditFormConfig->clearTabs(); }
1332 
1334  QString attributeAlias( int attributeIndex ) const;
1335 
1337  QString attributeDisplayName( int attributeIndex ) const;
1338 
1339  const QMap< QString, QString >& attributeAliases() const { return mAttributeAliasMap; }
1340 
1341  const QSet<QString>& excludeAttributesWMS() const { return mExcludeAttributesWMS; }
1342  void setExcludeAttributesWMS( const QSet<QString>& att ) { mExcludeAttributesWMS = att; }
1343 
1344  const QSet<QString>& excludeAttributesWFS() const { return mExcludeAttributesWFS; }
1345  void setExcludeAttributesWFS( const QSet<QString>& att ) { mExcludeAttributesWFS = att; }
1346 
1348  bool deleteAttribute( int attr );
1349 
1357  bool deleteAttributes( QList<int> attrs );
1358 
1360  bool addFeatures( QgsFeatureList features, bool makeSelected = true );
1361 
1363  bool deleteFeature( QgsFeatureId fid );
1364 
1372  bool deleteFeatures( const QgsFeatureIds& fids );
1373 
1389  bool commitChanges();
1390  const QStringList &commitErrors();
1391 
1395  bool rollBack( bool deleteBuffer = true );
1396 
1402  Q_DECL_DEPRECATED EditType editType( int idx );
1403 
1409  Q_DECL_DEPRECATED void setEditType( int idx, EditType edit );
1410 
1415  Q_DECL_DEPRECATED EditorLayout editorLayout() { return static_cast< EditorLayout >( mEditFormConfig->layout() ); }
1416 
1421  Q_DECL_DEPRECATED void setEditorLayout( EditorLayout editorLayout ) { mEditFormConfig->setLayout( static_cast< QgsEditFormConfig::EditorLayout >( editorLayout ) ); }
1422 
1453  Q_DECL_DEPRECATED void setEditorWidgetV2( int attrIdx, const QString& widgetType ) { mEditFormConfig->setWidgetType( attrIdx, widgetType ); }
1454 
1472  Q_DECL_DEPRECATED void setEditorWidgetV2Config( int attrIdx, const QgsEditorWidgetConfig& config ) { mEditFormConfig->setWidgetConfig( attrIdx, config ); }
1473 
1479  Q_DECL_DEPRECATED void setCheckedState( int idx, const QString& checked, const QString& notChecked );
1480 
1486  Q_DECL_DEPRECATED QString editForm() const { return mEditFormConfig->uiForm(); }
1487 
1492  Q_DECL_DEPRECATED void setEditForm( const QString& ui ) { mEditFormConfig->setUiForm( ui ); }
1493 
1498  Q_DECL_DEPRECATED QgsVectorLayer::FeatureFormSuppress featureFormSuppress() const { return static_cast< FeatureFormSuppress >( mEditFormConfig->suppress() ); }
1499 
1504  Q_DECL_DEPRECATED void setFeatureFormSuppress( QgsVectorLayer::FeatureFormSuppress s ) { mEditFormConfig->setSuppress( static_cast< QgsEditFormConfig::FeatureFormSuppress >( s ) ); }
1505 
1507  QString annotationForm() const { return mAnnotationForm; }
1508 
1510  void setAnnotationForm( const QString& ui );
1511 
1517  Q_DECL_DEPRECATED QString editFormInit() const { return mEditFormConfig->initFunction(); }
1518 
1524  Q_DECL_DEPRECATED void setEditFormInit( const QString& function ) { mEditFormConfig->setInitFunction( function ); }
1525 
1530  Q_DECL_DEPRECATED QMap<QString, QVariant> valueMap( int idx );
1531 
1537  Q_DECL_DEPRECATED RangeData range( int idx );
1538 
1540  ValueRelationData valueRelation( int idx );
1541 
1548  QList<QgsRelation> referencingRelations( int idx );
1549 
1555  Q_DECL_DEPRECATED QString dateFormat( int idx );
1556 
1562  Q_DECL_DEPRECATED QSize widgetSize( int idx );
1563 
1569  Q_DECL_DEPRECATED bool fieldEditable( int idx ) { return !mEditFormConfig->readOnly( idx ); }
1570 
1575  Q_DECL_DEPRECATED bool labelOnTop( int idx ) { return mEditFormConfig->labelOnTop( idx ); }
1576 
1581  Q_DECL_DEPRECATED void setFieldEditable( int idx, bool editable ) { mEditFormConfig->setReadOnly( idx, !editable ); }
1582 
1587  Q_DECL_DEPRECATED void setLabelOnTop( int idx, bool onTop ) { mEditFormConfig->setLabelOnTop( idx, onTop ); }
1588 
1590  QgsVectorLayerEditBuffer* editBuffer() { return mEditBuffer; }
1591 
1596  void beginEditCommand( const QString& text );
1597 
1599  void endEditCommand();
1600 
1602  void destroyEditCommand();
1603 
1605  int fieldNameIndex( const QString& fieldName ) const;
1606 
1609  {
1612  NoMarker
1613  };
1614 
1616  static void drawVertexMarker( double x, double y, QPainter& p, QgsVectorLayer::VertexMarkerType type, int vertexSize );
1617 
1619  void updateFields();
1620 
1622  void createJoinCaches();
1623 
1635  void uniqueValues( int index, QList<QVariant> &uniqueValues, int limit = -1 );
1636 
1644  QVariant minimumValue( int index );
1645 
1653  QVariant maximumValue( int index );
1654 
1663  QList< QVariant > getValues( const QString &fieldOrExpression, bool &ok, bool selectedOnly = false );
1664 
1675  QList< double > getDoubleValues( const QString &fieldOrExpression, bool &ok, bool selectedOnly = false, int* nullCount = nullptr );
1676 
1678  void setFeatureBlendMode( QPainter::CompositionMode blendMode );
1680  QPainter::CompositionMode featureBlendMode() const;
1681 
1683  void setLayerTransparency( int layerTransparency );
1685  int layerTransparency() const;
1686 
1687  QString metadata() override;
1688 
1690  inline QgsGeometryCache* cache() { return mCache; }
1691 
1695  void setSimplifyMethod( const QgsVectorSimplifyMethod& simplifyMethod ) { mSimplifyMethod = simplifyMethod; }
1699  inline const QgsVectorSimplifyMethod& simplifyMethod() const { return mSimplifyMethod; }
1700 
1705  bool simplifyDrawingCanbeApplied( const QgsRenderContext& renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint ) const;
1706 
1714  QgsConditionalLayerStyles *conditionalStyles() const;
1715 
1716  public slots:
1724  void select( QgsFeatureId featureId );
1725 
1733  void select( const QgsFeatureIds& featureIds );
1734 
1742  void deselect( const QgsFeatureId featureId );
1743 
1751  void deselect( const QgsFeatureIds& featureIds );
1752 
1758  void removeSelection();
1759 
1763  virtual void updateExtents();
1764 
1766  void checkJoinLayerRemove( const QString& theLayerId );
1767 
1774  bool startEditing();
1775 
1776 
1777  protected slots:
1778  void invalidateSymbolCountedFlag();
1779 
1780  signals:
1781 
1789  void selectionChanged( const QgsFeatureIds& selected, const QgsFeatureIds& deselected, const bool clearAndSelect );
1790 
1792  void selectionChanged();
1793 
1795  void layerModified();
1796 
1798  void beforeModifiedCheck() const;
1799 
1801  void beforeEditingStarted();
1802 
1804  void editingStarted();
1805 
1807  void editingStopped();
1808 
1810  void beforeCommitChanges();
1811 
1813  void beforeRollBack();
1814 
1823  void attributeAdded( int idx );
1824 
1831  void beforeAddingExpressionField( const QString& fieldName );
1832 
1841  void attributeDeleted( int idx );
1842 
1849  void beforeRemovingExpressionField( int idx );
1850 
1856  void featureAdded( QgsFeatureId fid );
1857 
1866  void featureDeleted( QgsFeatureId fid );
1867 
1877  void featuresDeleted( const QgsFeatureIds& fids );
1878 
1883  void updatedFields();
1884 
1888  void layerDeleted();
1889 
1890  void attributeValueChanged( QgsFeatureId fid, int idx, const QVariant & );
1891  void geometryChanged( QgsFeatureId fid, QgsGeometry &geom );
1892 
1894  void committedAttributesDeleted( const QString& layerId, const QgsAttributeList& deletedAttributes );
1895  void committedAttributesAdded( const QString& layerId, const QList<QgsField>& addedAttributes );
1896  void committedFeaturesAdded( const QString& layerId, const QgsFeatureList& addedFeatures );
1897  void committedFeaturesRemoved( const QString& layerId, const QgsFeatureIds& deletedFeatureIds );
1898  void committedAttributeValuesChanges( const QString& layerId, const QgsChangedAttributesMap& changedAttributesValues );
1899  void committedGeometriesChanges( const QString& layerId, const QgsGeometryMap& changedGeometries );
1900 
1901  void saveLayerToProject();
1902 
1904  void labelingFontNotFound( QgsVectorLayer* layer, const QString& fontfamily );
1905 
1907  void featureBlendModeChanged( QPainter::CompositionMode blendMode );
1908 
1910  void layerTransparencyChanged( int layerTransparency );
1911 
1917  void editCommandStarted( const QString& text );
1918 
1924  void editCommandEnded();
1925 
1931  void editCommandDestroyed();
1932 
1942  void readCustomSymbology( const QDomElement& element, QString& errorMessage );
1943 
1953  void writeCustomSymbology( QDomElement& element, QDomDocument& doc, QString& errorMessage ) const;
1954 
1958  void raiseError( const QString& msg );
1959 
1960  private slots:
1961  void onJoinedFieldsChanged();
1962  void onFeatureDeleted( QgsFeatureId fid );
1963 
1964  protected:
1966  void setExtent( const QgsRectangle &rect ) override;
1967 
1968  private: // Private methods
1969 
1971  QgsVectorLayer( const QgsVectorLayer & rhs );
1972 
1974  QgsVectorLayer & operator=( QgsVectorLayer const & rhs );
1975 
1976 
1981  bool setDataProvider( QString const & provider );
1982 
1984  QgsFeatureId findFreeId();
1985 
1994  void snapToGeometry( const QgsPoint& startPoint,
1995  QgsFeatureId featureId,
1996  const QgsGeometry *geom,
1997  double sqrSnappingTolerance,
1998  QMultiMap<double, QgsSnappingResult>& snappingResults,
1999  QgsSnapper::SnappingType snap_to ) const;
2000 
2002  //void addJoinedAttributes( QgsFeature& f, bool all = false );
2003 
2005  void readSldLabeling( const QDomNode& node );
2006 
2007  private: // Private attributes
2008 
2009  QgsConditionalLayerStyles * mConditionalStyles;
2010 
2012  QgsVectorDataProvider *mDataProvider;
2013 
2015  QString mDisplayField;
2016 
2018  QString mDisplayExpression;
2019 
2021  QString mProviderKey;
2022 
2024  QgsAttributeAction* mActions;
2025 
2027  bool mReadOnly;
2028 
2033  QgsFeatureIds mSelectedFeatureIds;
2034 
2036  QgsFields mUpdatedFields;
2037 
2039  QMap< QString, QString > mAttributeAliasMap;
2040 
2042  QgsEditFormConfig* mEditFormConfig;
2043 
2045  QSet<QString> mExcludeAttributesWMS;
2046 
2048  QSet<QString> mExcludeAttributesWFS;
2049 
2051  QGis::WkbType mWkbType;
2052 
2054  QgsFeatureRendererV2 *mRendererV2;
2055 
2057  QgsVectorSimplifyMethod mSimplifyMethod;
2058 
2060  QgsLabel *mLabel;
2061 
2063  bool mLabelOn;
2064 
2066  QgsAbstractVectorLayerLabeling* mLabeling;
2067 
2069  bool mLabelFontNotFoundNotified;
2070 
2072  QPainter::CompositionMode mFeatureBlendMode;
2073 
2075  int mLayerTransparency;
2076 
2078  bool mVertexMarkerOnlyForSelection;
2079 
2080  QStringList mCommitErrors;
2081 
2083  QString mAnnotationForm;
2084 
2086  QgsGeometryCache* mCache;
2087 
2089  QgsVectorLayerEditBuffer* mEditBuffer;
2091 
2092  //stores information about joined layers
2093  QgsVectorLayerJoinBuffer* mJoinBuffer;
2094 
2096  QgsExpressionFieldBuffer* mExpressionFieldBuffer;
2097 
2098  //diagram rendering object. 0 if diagram drawing is disabled
2099  QgsDiagramRendererV2* mDiagramRenderer;
2100 
2101  //stores infos about diagram placement (placement type, priority, position distance)
2102  QgsDiagramLayerSettings *mDiagramLayerSettings;
2103 
2104  bool mValidExtent;
2105  bool mLazyExtent;
2106 
2107  // Features in renderer classes counted
2108  bool mSymbolFeatureCounted;
2109 
2110  // Feature counts for each renderer symbol
2111  QMap<QgsSymbolV2*, long> mSymbolFeatureCountMap;
2112 
2114  bool mEditCommandActive;
2115 
2116  QgsFeatureIds mDeletedFids;
2117 
2119 };
2120 
2121 #endif
const QSet< QString > & excludeAttributesWMS() const
Wrapper for iterator of features from vector data provider or vector layer.
static unsigned index
A rectangle specified with double values.
Definition: qgsrectangle.h:35
Base class for all map layer types.
Definition: qgsmaplayer.h:49
QString joinFieldName
Join field in the source layer.
void clearAttributeEditorWidgets()
Clears all the tabs for the attribute editor form.
void setExcludeAttributesWFS(const QSet< QString > &att)
This is an abstract base class for any elements of a drag and drop form.
QString targetFieldName
Join field in the target layer.
GeometryType
Definition: qgis.h:111
QgsAttributeAction * actions()
ValueRelationData(const QString &layer, const QString &key, const QString &value, bool allowNull, bool orderByValue, bool allowMulti=false, const QString &filterExpression=QString::null)
QgsEditFormConfig::GroupData GroupData
The attribute value should not be changed in the attribute form.
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:433
const QgsFeatureRendererV2 * rendererV2() const
Return const renderer V2.
Manages an editor widget Widget and wrapper share the same parent.
Q_DECL_DEPRECATED void addAttributeEditorWidget(QgsAttributeEditorElement *data)
Adds a tab (for the attribute editor form) holding groups and fields.
void setExcludeAttributesWMS(const QSet< QString > &att)
int joinFieldIndex
Join field index in the source layer.
Storage and management of actions associated with Qgis layer attributes.
VertexMarkerType
Editing vertex markers.
SimplifyHint
Simplification flags for fast rendering of features.
Container of fields for a vector layer.
Definition: qgsfield.h:187
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:76
const QSet< QString > & excludeAttributesWFS() const
Q_DECL_DEPRECATED void setEditForm(const QString &ui)
Set edit form.
WkbType
Used for symbology operations.
Definition: qgis.h:57
bool memoryCache
True if the join is cached in virtual memory.
int targetFieldIndex
Join field index in the target layer.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:187
Q_DECL_DEPRECATED void setFieldEditable(int idx, bool editable)
Set edit widget editable.
Q_DECL_DEPRECATED const QString editorWidgetV2(const QString &fieldName) const
Get the id for the editor widget used to represent the field at the given index.
QgsAttributeList pendingPkAttributesList() const
Returns list of attributes making up the primary key Alias for pkAttributeList(). ...
Q_DECL_DEPRECATED const QgsEditorWidgetConfig editorWidgetV2Config(int fieldIdx) const
Get the configuration for the editor widget used to represent the field at the given index...
QgsGeometryCache * cache()
Returns diagram settings for a feature.
QgsEditFormConfig * editFormConfig() const
Get the configuration of the form used to represent this vector layer.
Manages joined fields for a vector layer.
QgsFields fields() const
Returns the list of fields of this layer.
Q_DECL_DEPRECATED void setEditorWidgetV2(int attrIdx, const QString &widgetType)
Set the editor widget type for a field.
Perform transforms between map coordinates and device coordinates.
Definition: qgsmaptopixel.h:34
SnappingType
Snap to vertex, to segment or both.
Definition: qgssnapper.h:66
QString prefix
An optional prefix.
QgsFeatureRendererV2 * rendererV2()
Return renderer V2.
QgsVectorLayerEditBuffer * editBuffer()
Buffer with uncommitted editing operations. Only valid after editing has been turned on...
void setJoinFieldNamesSubset(QStringList *fieldNamesSubset)
Set subset of fields to be used from joined layer.
const QMap< QString, QString > & attributeAliases() const
Q_DECL_DEPRECATED void setLabelOnTop(int idx, bool onTop)
Label widget on top.
Q_DECL_DEPRECATED QList< QgsAttributeEditorElement *> attributeEditorElements()
Returns a list of tabs holding groups and fields.
The attribute value should not be shown in the attribute form.
Q_DECL_DEPRECATED RangeData(const QVariant &theMin, const QVariant &theMax, const QVariant &theStep)
Q_DECL_DEPRECATED void setFeatureFormSuppress(QgsVectorLayer::FeatureFormSuppress s)
Set type of feature form pop-up suppression after feature creation (overrides app setting) ...
Point geometry type, with support for z-dimension and m-values.
Definition: qgspointv2.h:34
Q_DECL_DEPRECATED const QgsEditorWidgetConfig editorWidgetV2Config(const QString &fieldName) const
Get the configuration for the editor widget used to represent the field with the given name...
const QgsDiagramRendererV2 * diagramRenderer() const
Q_DECL_DEPRECATED void setEditFormInit(const QString &function)
Set python function for edit form initialization.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QgsAttributeEditorElement * attributeEditorElementFromDomElement(QDomElement &elem, QObject *parent)
Convert a saved attribute editor element into a AttributeEditor structure as it&#39;s used internally...
Q_DECL_DEPRECATED bool fieldEditable(int idx)
Is edit widget editable.
Q_DECL_DEPRECATED QgsVectorLayer::FeatureFormSuppress featureFormSuppress() const
Type of feature form pop-up suppression after feature creation (overrides app setting) ...
QSharedPointer< QStringList > joinFieldsSubset
Subset of fields to use from joined layer.
QgsAttributeList attributeList() const
Returns list of attribute indexes.
QgsAttributeList pendingAllAttributesList() const
Returns list of attribute indexes.
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:44
Q_DECL_DEPRECATED bool labelOnTop(int idx)
Label widget on top.
const QgsAbstractVectorLayerLabeling * labeling() const
Access to labeling configuration.
Q_DECL_DEPRECATED QString editForm() const
Get edit form.
QString annotationForm() const
Get annotation form.
A class to represent a point.
Definition: qgspoint.h:65
Q_DECL_DEPRECATED void setEditorWidgetV2Config(int attrIdx, const QgsEditorWidgetConfig &config)
Set the editor widget config for a field.
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings for fast rendering of features.
QgsVectorLayerJoinBuffer * joinBuffer()
Acccessor to the join buffer object.
Partial snapshot of vector layer&#39;s state (only the members necessary for access to features) ...
A class to render labels.
Definition: qgslabel.h:51
long pendingFeatureCount() const
Returns feature count including changes which have not yet been committed Alias for featureCount()...
uuid generator - readonly and automatically intialized
Q_DECL_DEPRECATED QString editFormInit() const
Get python function for edit form initialization.
This class contains information how to simplify geometries fetched from a vector layer.
Contains information about the context of a rendering operation.
Buffers information about expression fields for a vector layer.
QHash< QString, QgsAttributes > cachedAttributes
Cache for joined attributes to provide fast lookup (size is 0 if no memory caching) ...
const QgsDiagramLayerSettings * diagramLayerSettings() const
This class manages a set of relations between layers.
The QgsConditionalLayerStyles class holds conditional style information for a layer.
Q_DECL_DEPRECATED EditorLayout editorLayout()
Get the active layout for the attribute editor for this layer.
Abstract base class - its implementations define different approaches to the labeling of a vector lay...
Class for doing transforms between two map coordinate systems.
void setSimplifyMethod(const QgsVectorSimplifyMethod &simplifyMethod)
Set the simplification settings for fast rendering of features.
qint64 QgsFeatureId
Definition: qgsfeature.h:31
QgsFields pendingFields() const
Returns the list of fields of this layer.
Base class for utility classes that encapsulate information necessary for rendering of map layers...
Q_DECL_DEPRECATED const QString editorWidgetV2(int fieldIdx) const
Get the id for the editor widget used to represent the field at the given index.
QSet< int > QgsAttributeIds
FeatureFormSuppress
Types of feature form suppression after feature creation.
This is the base class for vector data providers.
Abstract base class for curved geometry type.
Definition: qgscurvev2.h:32
QList< int > QgsAttributeList
Represents a vector layer which manages a vector based data sets.
modularized edit widgets
EditResult
Result of an edit operation.
QString joinLayerId
Source layer.
QStringList * joinFieldNamesSubset() const
Get subset of fields to be used from joined layer.
Q_DECL_DEPRECATED void setEditorLayout(EditorLayout editorLayout)
Set the active layout for the attribute editor for this layer.
value map from an table
Abstract base class for simplify geometries using a specific algorithm.
QgsEditFormConfig::TabData TabData
QList< QgsPointV2 > QgsPointSequenceV2
bool operator==(const QgsVectorJoinInfo &other) const
Q_DECL_DEPRECATED RangeData()