QGIS API Documentation  2.12.0-Lyon
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"
35 #include "qgsrelation.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 
71 
72 
82 class CORE_EXPORT QgsAttributeEditorElement : public QObject
83 {
84  Q_OBJECT
85  public:
86 
88  {
92  AeTypeInvalid
93  };
94 
102  QgsAttributeEditorElement( AttributeEditorType type, const QString& name, QObject *parent = NULL )
103  : QObject( parent ), mType( type ), mName( name ) {}
104 
107 
113  QString name() const { return mName; }
114 
120  AttributeEditorType type() const { return mType; }
121 
129  virtual QDomElement toDomElement( QDomDocument& doc ) const = 0;
130 
131  protected:
134 };
135 
141 {
142  public:
150  : QgsAttributeEditorElement( AeTypeContainer, name, parent )
151  , mIsGroupBox( true )
152  {}
153 
156 
164  virtual QDomElement toDomElement( QDomDocument& doc ) const override;
165 
171  virtual void addChildElement( QgsAttributeEditorElement* element );
172 
178  virtual void setIsGroupBox( bool isGroupBox ) { mIsGroupBox = isGroupBox; }
179 
185  virtual bool isGroupBox() const { return mIsGroupBox; }
186 
192  QList<QgsAttributeEditorElement*> children() const { return mChildren; }
193 
201  virtual QList<QgsAttributeEditorElement*> findElements( AttributeEditorType type ) const;
202 
208  void setName( const QString& name );
209 
210  private:
211  bool mIsGroupBox;
213 };
214 
219 {
220  public:
228  QgsAttributeEditorField( const QString& name, int idx, QObject *parent )
229  : QgsAttributeEditorElement( AeTypeField, name, parent ), mIdx( idx ) {}
230 
233 
241  virtual QDomElement toDomElement( QDomDocument& doc ) const override;
242 
247  int idx() const { return mIdx; }
248 
249  private:
250  int mIdx;
251 };
252 
259 {
260  public:
268  QgsAttributeEditorRelation( const QString& name, const QString &relationId, QObject *parent )
269  : QgsAttributeEditorElement( AeTypeRelation, name, parent )
270  , mRelationId( relationId ) {}
271 
279  QgsAttributeEditorRelation( const QString& name, const QgsRelation& relation, QObject *parent )
280  : QgsAttributeEditorElement( AeTypeRelation, name, parent )
281  , mRelationId( relation.id() )
282  , mRelation( relation ) {}
283 
286 
294  virtual QDomElement toDomElement( QDomDocument& doc ) const override;
295 
301  const QgsRelation& relation() const { return mRelation; }
302 
309  bool init( QgsRelationManager *relManager );
310 
311  private:
312  QString mRelationId;
313  QgsRelation mRelation;
314 };
315 
316 
317 struct CORE_EXPORT QgsVectorJoinInfo
318 {
331 
336 
341 
342  bool operator==( const QgsVectorJoinInfo& other ) const
343  {
344  return targetFieldName == other.targetFieldName &&
345  joinLayerId == other.joinLayerId &&
346  joinFieldName == other.joinFieldName &&
347  joinFieldsSubset == other.joinFieldsSubset &&
348  memoryCache == other.memoryCache &&
349  prefix == other.prefix;
350  }
351 
354  void setJoinFieldNamesSubset( QStringList* fieldNamesSubset ) { joinFieldsSubset = QSharedPointer<QStringList>( fieldNamesSubset ); }
357  QStringList* joinFieldNamesSubset() const { return joinFieldsSubset.data(); }
358 
359 protected:
362 };
363 
364 
365 
628 class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
629 {
630  Q_OBJECT
631 
632  public:
635  {
636  GeneratedLayout = 0,
637  TabLayout = 1,
638  UiFileLayout = 2
639  };
640 
644  enum EditType
645  {
667  };
668 
672  {
673  SuppressDefault = 0, // use the application-wide setting
674  SuppressOn = 1,
675  SuppressOff = 2
676  };
677 
678  struct RangeData
679  {
680  RangeData() { mMin = QVariant( 0 ); mMax = QVariant( 5 ); mStep = QVariant( 1 );}
681  RangeData( const QVariant& theMin, const QVariant& theMax, const QVariant& theStep )
682  : mMin( theMin ), mMax( theMax ), mStep( theStep ) {}
683 
687  };
688 
690  {
691  ValueRelationData() : mAllowNull( false ), mOrderByValue( false ), mAllowMulti( false ) {}
692  ValueRelationData( const QString& layer, const QString& key, const QString& value, bool allowNull, bool orderByValue,
693  bool allowMulti = false,
694  const QString& filterExpression = QString::null )
695  : mLayer( layer )
696  , mKey( key )
697  , mValue( value )
698  , mFilterExpression( filterExpression )
699  , mAllowNull( allowNull )
700  , mOrderByValue( orderByValue )
701  , mAllowMulti( allowMulti )
702  {}
703 
710  bool mAllowMulti; /* allow selection of multiple keys */
711  };
712 
713  struct GroupData
714  {
716  GroupData( const QString& name, const QList<QString>& fields )
717  : mName( name ), mFields( fields ) {}
720  };
721 
722  struct TabData
723  {
724  TabData() {}
725  TabData( const QString& name, const QList<QString>& fields, const QList<GroupData>& groups )
726  : mName( name ), mFields( fields ), mGroups( groups ) {}
730  };
731 
745  QgsVectorLayer( const QString& path = QString::null, const QString& baseName = QString::null,
746  const QString& providerLib = QString::null, bool loadDefaultStyleFlag = true );
747 
749  virtual ~QgsVectorLayer();
750 
752  QString storageType() const;
753 
755  QString capabilitiesString() const;
756 
758  QString dataComment() const;
759 
761  void setDisplayField( const QString& fldName = "" );
762 
764  const QString displayField() const;
765 
772  void setDisplayExpression( const QString &displayExpression );
773 
780  const QString displayExpression();
781 
783  QgsVectorDataProvider* dataProvider();
784 
788  const QgsVectorDataProvider* dataProvider() const;
789 
791  void setProviderEncoding( const QString& encoding );
792 
794  void setCoordinateSystem();
795 
799  bool addJoin( const QgsVectorJoinInfo& joinInfo );
800 
802  void removeJoin( const QString& joinLayerId );
803 
804  const QList<QgsVectorJoinInfo> vectorJoins() const;
805 
816  int addExpressionField( const QString& exp, const QgsField& fld );
817 
825  void removeExpressionField( int index );
826 
836  const QString expressionField( int index );
837 
847  void updateExpressionField( int index, const QString& exp );
848 
850  QgsLabel *label();
851 
852  const QgsLabel *label() const;
853 
854  QgsAttributeAction *actions() { return mActions; }
855 
861  int selectedFeatureCount();
862 
871  void select( QgsRectangle & rect, bool addToSelection );
872 
884  void modifySelection( QgsFeatureIds selectIds, QgsFeatureIds deselectIds );
885 
887  void invertSelection();
888 
890  void selectAll();
891 
893  QgsFeatureIds allFeatureIds();
894 
902  void invertSelectionInRectangle( QgsRectangle & rect );
903 
912  QgsFeatureList selectedFeatures();
913 
925  QgsFeatureIterator selectedFeaturesIterator( QgsFeatureRequest request = QgsFeatureRequest() );
926 
933  const QgsFeatureIds &selectedFeaturesIds() const;
934 
942  void setSelectedFeatures( const QgsFeatureIds &ids );
943 
945  QgsRectangle boundingBoxOfSelected();
946 
951  bool labelsEnabled() const;
952 
957  bool diagramsEnabled() const;
958 
960  void setDiagramRenderer( QgsDiagramRendererV2* r );
961  const QgsDiagramRendererV2* diagramRenderer() const { return mDiagramRenderer; }
962 
963  void setDiagramLayerSettings( const QgsDiagramLayerSettings& s );
964  const QgsDiagramLayerSettings *diagramLayerSettings() const { return mDiagramLayerSettings; }
965 
967  QgsFeatureRendererV2* rendererV2() { return mRendererV2; }
968 
970  const QgsFeatureRendererV2* rendererV2() const { return mRendererV2; }
971 
973  void setRendererV2( QgsFeatureRendererV2* r );
974 
976  QGis::GeometryType geometryType() const;
977 
979  bool hasGeometryType() const;
980 
982  QGis::WkbType wkbType() const;
983 
985  QString providerType() const;
986 
990  virtual bool readXml( const QDomNode& layer_node ) override;
991 
995  virtual bool writeXml( QDomNode & layer_node, QDomDocument & doc ) override;
996 
1005  virtual void saveStyleToDatabase( const QString& name, const QString& description,
1006  bool useAsDefault, const QString& uiFileContent,
1007  QString &msgError );
1008 
1017  virtual int listStylesInDatabase( QStringList &ids, QStringList &names,
1018  QStringList &descriptions, QString &msgError );
1019 
1023  virtual QString getStyleFromDatabase( const QString& styleId, QString &msgError );
1024 
1031  virtual QString loadNamedStyle( const QString &theURI, bool &theResultFlag, bool loadFromLocalDb );
1032 
1037  virtual QString loadNamedStyle( const QString &theURI, bool &theResultFlag ) override;
1038 
1049  virtual bool applyNamedStyle( const QString& namedStyle, QString &errorMsg );
1050 
1055  QgsAttributeEditorElement* attributeEditorElementFromDomElement( QDomElement &elem, QObject* parent );
1056 
1062  bool readSymbology( const QDomNode& node, QString& errorMessage ) override;
1063 
1070  bool writeSymbology( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const override;
1071 
1072  bool writeSld( QDomNode& node, QDomDocument& doc, QString& errorMessage ) const;
1073  bool readSld( const QDomNode& node, QString& errorMessage ) override;
1074 
1081  long featureCount( QgsSymbolV2* symbol );
1082 
1093  void setDataSource( const QString& dataSource, const QString& baseName, const QString& provider, bool loadDefaultStyleFlag = false );
1094 
1100  bool countSymbolFeatures( bool showProgress = true );
1101 
1109  virtual bool setSubsetString( const QString& subset );
1110 
1115  virtual QString subsetString();
1116 
1120  QgsFeatureIterator getFeatures( const QgsFeatureRequest& request = QgsFeatureRequest() );
1121 
1127  bool addFeature( QgsFeature& f, bool alsoUpdateExtent = true );
1128 
1135  bool updateFeature( QgsFeature &f );
1136 
1141  bool insertVertex( double x, double y, QgsFeatureId atFeatureId, int beforeVertex );
1142 
1147  bool moveVertex( double x, double y, QgsFeatureId atFeatureId, int atVertex );
1148 
1153  bool moveVertex( const QgsPointV2& p, QgsFeatureId atFeatureId, int atVertex );
1154 
1157  bool deleteVertex( QgsFeatureId atFeatureId, int atVertex );
1158 
1162  bool deleteSelectedFeatures( int *deletedCount = 0 );
1163 
1175  int addRing( const QList<QgsPoint>& ring, QgsFeatureId* featureId = 0 );
1176 
1185  int addRing( QgsCurveV2* ring, QgsFeatureId* featureId = 0 );
1186 
1197  int addPart( const QList<QgsPoint>& ring );
1198 
1199  int addPart( QgsCurveV2* ring );
1200 
1206  int translateFeature( QgsFeatureId featureId, double dx, double dy );
1207 
1215  int splitParts( const QList<QgsPoint>& splitLine, bool topologicalEditing = false );
1216 
1224  int splitFeatures( const QList<QgsPoint>& splitLine, bool topologicalEditing = false );
1225 
1234  Q_DECL_DEPRECATED int removePolygonIntersections( QgsGeometry* geom, const QgsFeatureIds& ignoreFeatures = QgsFeatureIds() );
1235 
1241  int addTopologicalPoints( const QgsGeometry* geom );
1242 
1250  int addTopologicalPoints( const QgsPoint& p );
1251 
1257  int insertSegmentVerticesForSnap( const QList<QgsSnappingResult>& snapResults );
1258 
1262  Q_DECL_DEPRECATED void enableLabels( bool on );
1263 
1267  Q_DECL_DEPRECATED bool hasLabelsEnabled() const;
1268 
1272  const QgsAbstractVectorLayerLabeling* labeling() const { return mLabeling; }
1273 
1277  void setLabeling( QgsAbstractVectorLayerLabeling* labeling );
1278 
1280  virtual bool isEditable() const override;
1281 
1283  virtual bool isReadOnly() const;
1284 
1286  virtual bool isModified() const;
1287 
1294  bool snapPoint( QgsPoint& point, double tolerance );
1295 
1303  int snapWithContext( const QgsPoint& startPoint,
1304  double snappingTolerance,
1305  QMultiMap < double, QgsSnappingResult > &snappingResults,
1306  QgsSnapper::SnappingType snap_to );
1307 
1309  virtual void reload() override;
1310 
1314  virtual QgsMapLayerRenderer* createMapRenderer( QgsRenderContext& rendererContext ) override;
1315 
1319  bool draw( QgsRenderContext& rendererContext ) override;
1320 
1324  Q_DECL_DEPRECATED void drawLabels( QgsRenderContext& rendererContext ) override;
1325 
1327  QgsRectangle extent() override;
1328 
1335  inline QgsFields fields() const { return mUpdatedFields; }
1336 
1344  inline QgsFields pendingFields() const { return mUpdatedFields; }
1345 
1350  inline QgsAttributeList pendingAllAttributesList() const { return mUpdatedFields.allAttributesList(); }
1351 
1356  inline QgsAttributeList attributeList() const { return mUpdatedFields.allAttributesList(); }
1357 
1362  inline QgsAttributeList pendingPkAttributesList() const { return pkAttributeList(); }
1363 
1365  QgsAttributeList pkAttributeList() const;
1366 
1371  inline long pendingFeatureCount() const { return featureCount(); }
1372 
1377  long featureCount() const;
1378 
1382  bool setReadOnly( bool readonly = true );
1383 
1390  bool startEditing();
1391 
1393  bool changeGeometry( QgsFeatureId fid, QgsGeometry* geom );
1394 
1401  Q_DECL_DEPRECATED bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant& value, bool emitSignal );
1402 
1413  bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant() );
1414 
1417  bool addAttribute( const QgsField &field );
1418 
1420  void addAttributeAlias( int attIndex, const QString& aliasString );
1421 
1423  void remAttributeAlias( int attIndex );
1424 
1428  void addAttributeEditorWidget( QgsAttributeEditorElement* data );
1429 
1437  const QString editorWidgetV2( int fieldIdx ) const;
1438 
1448  const QString editorWidgetV2( const QString& fieldName ) const;
1449 
1457  const QgsEditorWidgetConfig editorWidgetV2Config( int fieldIdx ) const;
1458 
1468  const QgsEditorWidgetConfig editorWidgetV2Config( const QString& fieldName ) const;
1469 
1473  QList< QgsAttributeEditorElement* > &attributeEditorElements();
1477  void clearAttributeEditorWidgets();
1478 
1480  QString attributeAlias( int attributeIndex ) const;
1481 
1483  QString attributeDisplayName( int attributeIndex ) const;
1484 
1485  const QMap< QString, QString >& attributeAliases() const { return mAttributeAliasMap; }
1486 
1487  const QSet<QString>& excludeAttributesWMS() const { return mExcludeAttributesWMS; }
1488  void setExcludeAttributesWMS( const QSet<QString>& att ) { mExcludeAttributesWMS = att; }
1489 
1490  const QSet<QString>& excludeAttributesWFS() const { return mExcludeAttributesWFS; }
1491  void setExcludeAttributesWFS( const QSet<QString>& att ) { mExcludeAttributesWFS = att; }
1492 
1494  bool deleteAttribute( int attr );
1495 
1503  bool deleteAttributes( QList<int> attrs );
1504 
1506  bool addFeatures( QgsFeatureList features, bool makeSelected = true );
1507 
1509  bool deleteFeature( QgsFeatureId fid );
1510 
1526  bool commitChanges();
1527  const QStringList &commitErrors();
1528 
1532  bool rollBack( bool deleteBuffer = true );
1533 
1539  Q_DECL_DEPRECATED EditType editType( int idx );
1540 
1546  Q_DECL_DEPRECATED void setEditType( int idx, EditType edit );
1547 
1549  EditorLayout editorLayout();
1550 
1552  void setEditorLayout( EditorLayout editorLayout );
1553 
1582  void setEditorWidgetV2( int attrIdx, const QString& widgetType );
1583 
1599  void setEditorWidgetV2Config( int attrIdx, const QgsEditorWidgetConfig& config );
1600 
1606  Q_DECL_DEPRECATED void setCheckedState( int idx, const QString& checked, const QString& notChecked );
1607 
1609  QString editForm();
1610 
1612  void setEditForm( const QString& ui );
1613 
1616  QgsVectorLayer::FeatureFormSuppress featureFormSuppress() const { return mFeatureFormSuppress; }
1617 
1620  void setFeatureFormSuppress( QgsVectorLayer::FeatureFormSuppress s ) { mFeatureFormSuppress = s; }
1621 
1623  QString annotationForm() const { return mAnnotationForm; }
1624 
1626  void setAnnotationForm( const QString& ui );
1627 
1629  QString editFormInit();
1630 
1632  void setEditFormInit( const QString& function );
1633 
1638  Q_DECL_DEPRECATED QMap<QString, QVariant> valueMap( int idx );
1639 
1645  Q_DECL_DEPRECATED RangeData range( int idx );
1646 
1648  ValueRelationData valueRelation( int idx );
1649 
1656  QList<QgsRelation> referencingRelations( int idx );
1657 
1663  Q_DECL_DEPRECATED QString dateFormat( int idx );
1664 
1670  Q_DECL_DEPRECATED QSize widgetSize( int idx );
1671 
1673  bool fieldEditable( int idx );
1674 
1676  bool labelOnTop( int idx );
1677 
1679  void setFieldEditable( int idx, bool editable );
1680 
1682  void setLabelOnTop( int idx, bool onTop );
1683 
1685  QgsVectorLayerEditBuffer* editBuffer() { return mEditBuffer; }
1686 
1691  void beginEditCommand( const QString& text );
1692 
1694  void endEditCommand();
1695 
1697  void destroyEditCommand();
1698 
1700  int fieldNameIndex( const QString& fieldName ) const;
1701 
1704  {
1707  NoMarker
1708  };
1709 
1711  static void drawVertexMarker( double x, double y, QPainter& p, QgsVectorLayer::VertexMarkerType type, int vertexSize );
1712 
1714  void updateFields();
1715 
1717  void createJoinCaches();
1718 
1723  void uniqueValues( int index, QList<QVariant> &uniqueValues, int limit = -1 );
1724 
1726  QVariant minimumValue( int index );
1727 
1729  QVariant maximumValue( int index );
1730 
1739  QList< QVariant > getValues( const QString &fieldOrExpression, bool &ok, bool selectedOnly = false );
1740 
1751  QList< double > getDoubleValues( const QString &fieldOrExpression, bool &ok, bool selectedOnly = false, int* nullCount = 0 );
1752 
1754  void setFeatureBlendMode( const QPainter::CompositionMode &blendMode );
1756  QPainter::CompositionMode featureBlendMode() const;
1757 
1759  void setLayerTransparency( int layerTransparency );
1761  int layerTransparency() const;
1762 
1763  QString metadata() override;
1764 
1766  inline QgsGeometryCache* cache() { return mCache; }
1767 
1771  void setSimplifyMethod( const QgsVectorSimplifyMethod& simplifyMethod ) { mSimplifyMethod = simplifyMethod; }
1775  inline const QgsVectorSimplifyMethod& simplifyMethod() const { return mSimplifyMethod; }
1776 
1781  bool simplifyDrawingCanbeApplied( const QgsRenderContext& renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint ) const;
1782 
1790  QgsConditionalLayerStyles *conditionalStyles() const;
1791 
1792  public slots:
1800  void select( const QgsFeatureId &featureId );
1801 
1809  void select( const QgsFeatureIds& featureIds );
1810 
1818  void deselect( const QgsFeatureId featureId );
1819 
1827  void deselect( const QgsFeatureIds& featureIds );
1828 
1834  void removeSelection();
1835 
1839  virtual void updateExtents();
1840 
1842  void checkJoinLayerRemove( const QString& theLayerId );
1843 
1844  protected slots:
1845  void invalidateSymbolCountedFlag();
1846 
1847  signals:
1848 
1856  void selectionChanged( const QgsFeatureIds selected, const QgsFeatureIds deselected, const bool clearAndSelect );
1857 
1859  void selectionChanged();
1860 
1862  void layerModified();
1863 
1865  void beforeModifiedCheck() const;
1866 
1868  void editingStarted();
1869 
1871  void editingStopped();
1872 
1874  void beforeCommitChanges();
1875 
1877  void beforeRollBack();
1878 
1887  void attributeAdded( int idx );
1894  void beforeAddingExpressionField( QString fieldName );
1903  void attributeDeleted( int idx );
1910  void beforeRemovingExpressionField( int idx );
1911 
1917  void featureAdded( QgsFeatureId fid );
1926  void featureDeleted( QgsFeatureId fid );
1936  void featuresDeleted( QgsFeatureIds fids );
1941  void updatedFields();
1942  void layerDeleted();
1943 
1944  void attributeValueChanged( QgsFeatureId fid, int idx, const QVariant & );
1945  void geometryChanged( QgsFeatureId fid, QgsGeometry &geom );
1946 
1948  void committedAttributesDeleted( const QString& layerId, const QgsAttributeList& deletedAttributes );
1949  void committedAttributesAdded( const QString& layerId, const QList<QgsField>& addedAttributes );
1950  void committedFeaturesAdded( const QString& layerId, const QgsFeatureList& addedFeatures );
1951  void committedFeaturesRemoved( const QString& layerId, const QgsFeatureIds& deletedFeatureIds );
1952  void committedAttributeValuesChanges( const QString& layerId, const QgsChangedAttributesMap& changedAttributesValues );
1953  void committedGeometriesChanges( const QString& layerId, const QgsGeometryMap& changedGeometries );
1954 
1955  void saveLayerToProject();
1956 
1958  void labelingFontNotFound( QgsVectorLayer* layer, const QString& fontfamily );
1959 
1961  void featureBlendModeChanged( const QPainter::CompositionMode &blendMode );
1962 
1964  void layerTransparencyChanged( int layerTransparency );
1965 
1971  void editCommandStarted( const QString& text );
1972 
1978  void editCommandEnded();
1979 
1985  void editCommandDestroyed();
1986 
1996  void readCustomSymbology( const QDomElement& element, QString& errorMessage );
1997 
2007  void writeCustomSymbology( QDomElement& element, QDomDocument& doc, QString& errorMessage ) const;
2008 
2009 
2010  private slots:
2011  void onRelationsLoaded();
2012  void onJoinedFieldsChanged();
2013  void onFeatureDeleted( const QgsFeatureId& fid );
2014 
2015  protected:
2017  void setExtent( const QgsRectangle &rect ) override;
2018 
2019  private: // Private methods
2020 
2022  QgsVectorLayer( const QgsVectorLayer & rhs );
2023 
2025  QgsVectorLayer & operator=( QgsVectorLayer const & rhs );
2026 
2027 
2032  bool setDataProvider( QString const & provider );
2033 
2035  QgsFeatureId findFreeId();
2036 
2045  void snapToGeometry( const QgsPoint& startPoint,
2046  QgsFeatureId featureId,
2047  const QgsGeometry *geom,
2048  double sqrSnappingTolerance,
2049  QMultiMap<double, QgsSnappingResult>& snappingResults,
2050  QgsSnapper::SnappingType snap_to ) const;
2051 
2053  //void addJoinedAttributes( QgsFeature& f, bool all = false );
2054 
2056  void readSldLabeling( const QDomNode& node );
2057 
2058  private: // Private attributes
2059 
2060  QgsConditionalLayerStyles * mConditionalStyles;
2061 
2063  QgsVectorDataProvider *mDataProvider;
2064 
2066  QString mDisplayField;
2067 
2069  QString mDisplayExpression;
2070 
2072  QString mProviderKey;
2073 
2075  QgsAttributeAction* mActions;
2076 
2078  bool mReadOnly;
2079 
2084  QgsFeatureIds mSelectedFeatureIds;
2085 
2087  QgsFields mUpdatedFields;
2088 
2090  QMap< QString, QString > mAttributeAliasMap;
2091 
2093  QList< QgsAttributeEditorElement* > mAttributeEditorElements;
2094 
2096  QSet<QString> mExcludeAttributesWMS;
2098  QSet<QString> mExcludeAttributesWFS;
2099 
2101  QList< TabData > mTabs;
2102 
2104  QGis::WkbType mWkbType;
2105 
2107  QgsFeatureRendererV2 *mRendererV2;
2108 
2110  QgsVectorSimplifyMethod mSimplifyMethod;
2111 
2113  QgsLabel *mLabel;
2114 
2116  bool mLabelOn;
2117 
2119  QgsAbstractVectorLayerLabeling* mLabeling;
2120 
2122  bool mLabelFontNotFoundNotified;
2123 
2125  QPainter::CompositionMode mFeatureBlendMode;
2126 
2128  int mLayerTransparency;
2129 
2131  bool mVertexMarkerOnlyForSelection;
2132 
2133  QStringList mCommitErrors;
2134 
2135  QMap< QString, bool> mFieldEditables;
2136  QMap< QString, bool> mLabelOnTop;
2137 
2138  QMap<QString, QString> mEditorWidgetV2Types;
2139  QMap<QString, QgsEditorWidgetConfig > mEditorWidgetV2Configs;
2140 
2142  EditorLayout mEditorLayout;
2143 
2144  QString mEditForm, mEditFormInit;
2145 
2148  QgsVectorLayer::FeatureFormSuppress mFeatureFormSuppress;
2149 
2150  //annotation form for this layer
2151  QString mAnnotationForm;
2152 
2154  QgsGeometryCache* mCache;
2155 
2157  QgsVectorLayerEditBuffer* mEditBuffer;
2159 
2160  //stores information about joined layers
2161  QgsVectorLayerJoinBuffer* mJoinBuffer;
2162 
2164  QgsExpressionFieldBuffer* mExpressionFieldBuffer;
2165 
2166  //diagram rendering object. 0 if diagram drawing is disabled
2167  QgsDiagramRendererV2* mDiagramRenderer;
2168 
2169  //stores infos about diagram placement (placement type, priority, position distance)
2170  QgsDiagramLayerSettings *mDiagramLayerSettings;
2171 
2172  bool mValidExtent;
2173  bool mLazyExtent;
2174 
2175  // Features in renderer classes counted
2176  bool mSymbolFeatureCounted;
2177 
2178  // Feature counts for each renderer symbol
2179  QMap<QgsSymbolV2*, long> mSymbolFeatureCountMap;
2180 
2182  bool mEditCommandActive;
2183 
2184  QgsFeatureIds mDeletedFids;
2185 
2187 };
2188 
2189 #endif
virtual bool isEditable() const
True if the layer can be edited.
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
QgsAttributeEditorRelation(const QString &name, const QString &relationId, QObject *parent)
Creates a new element which embeds a relation.
QgsAttributeList attributeList() const
Returns list of attribute indexes.
virtual ~QgsAttributeEditorContainer()
Destructor.
QString joinFieldName
Join field in the source layer.
const QSet< QString > & excludeAttributesWMS() const
void setExcludeAttributesWFS(const QSet< QString > &att)
This is an abstract base class for any elements of a drag and drop form.
virtual QString metadata()
Obtain Metadata for this layer.
QString targetFieldName
Join field in the target layer.
virtual void drawLabels(QgsRenderContext &rendererContext)
Draw labels.
QgsAttributeEditorRelation(const QString &name, const QgsRelation &relation, QObject *parent)
Creates a new element which embeds a relation.
virtual bool isGroupBox() const
Returns if this ccontainer is going to be rendered as a group box.
QgsAttributeAction * actions()
ValueRelationData(const QString &layer, const QString &key, const QString &value, bool allowNull, bool orderByValue, bool allowMulti=false, const QString &filterExpression=QString::null)
GroupData(const QString &name, const QList< QString > &fields)
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:422
QgsFields fields() const
Returns the list of fields of this layer.
EditorLayout
The different types to layout the attribute editor.
Manages an editor widget Widget and wrapper share the same parent.
void setExcludeAttributesWMS(const QSet< QString > &att)
int joinFieldIndex
Join field index in the source layer.
virtual bool readSymbology(const QDomNode &node, QString &errorMessage)=0
Read the symbology for the current layer from the Dom node supplied.
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(). ...
virtual void reload()
Synchronises with changes in the datasource.
Definition: qgsmaplayer.h:129
QgsVectorLayer::FeatureFormSuppress featureFormSuppress() const
Type of feature form pop-up suppression after feature creation (overrides app setting) ...
FeatureFormSuppress
Types of feature form suppression after feature creation.
SimplifyHint
Simplification flags for fast rendering of features.
Container of fields for a vector layer.
Definition: qgsfield.h:177
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:76
This element will load a field's widget onto the form.
GeometryType
Definition: qgis.h:104
virtual ~QgsAttributeEditorElement()
Destructor.
This element will load a relation editor onto the form.
virtual QgsMapLayerRenderer * createMapRenderer(QgsRenderContext &rendererContext)
Return new instance of QgsMapLayerRenderer that will be used for rendering of given context...
Definition: qgsmaplayer.h:134
WkbType
Used for symbology operations.
Definition: qgis.h:56
const QgsRelation & relation() const
Get the id of the relation which shall be embedded.
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:176
const QgsDiagramLayerSettings * diagramLayerSettings() const
RangeData(const QVariant &theMin, const QVariant &theMax, const QVariant &theStep)
int idx() const
Return the index of the field.
virtual bool writeSymbology(QDomNode &node, QDomDocument &doc, QString &errorMessage) const =0
Write the symbology for the layer into the docment provided.
QgsGeometryCache * cache()
Returns diagram settings for a feature.
QString name() const
Return the name of this element.
Manages joined fields for a vector layer.
virtual bool draw(QgsRenderContext &rendererContext)
This is the method that does the actual work of drawing the layer onto a paint device.
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
value map from an table
virtual bool writeXml(QDomNode &layer_node, QDomDocument &document)
Called by writeLayerXML(), used by children to write state specific to them to project files...
const QgsAbstractVectorLayerLabeling * labeling() const
Access to labeling configuration.
const QSet< QString > & excludeAttributesWFS() const
VertexMarkerType
Editing vertex markers.
Point geometry type.
Definition: qgspointv2.h:29
virtual void setExtent(const QgsRectangle &rect)
Set the extent.
The attribute value should not be changed in the attribute form.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
AttributeEditorType type() const
The type of this element.
QgsAttributeEditorField(const QString &name, int idx, QObject *parent)
Creates a new attribute editor element which represents a field.
QSharedPointer< QStringList > joinFieldsSubset
Subset of fields to use from joined layer.
virtual ~QgsAttributeEditorField()
Destructor.
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:40
const QgsFeatureRendererV2 * rendererV2() const
Return const renderer V2.
QgsAttributeEditorContainer(const QString &name, QObject *parent)
Creates a new attribute editor container.
const QMap< QString, QString > & attributeAliases() const
const QgsDiagramRendererV2 * diagramRenderer() const
A class to represent a point.
Definition: qgspoint.h:63
virtual bool readSld(const QDomNode &node, QString &errorMessage)
Definition: qgsmaplayer.h:353
void setName(const char *name)
virtual ~QgsAttributeEditorRelation()
Destructor.
QgsAttributeList pendingAllAttributesList() const
Returns list of attribute indexes.
QList< QgsAttributeEditorElement * > children() const
Get a list of the children elements of this container.
Partial snapshot of vector layer's state (only the members necessary for access to features) ...
QList< QString > mFields
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()...
modularized edit widgets
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.
virtual QDomElement toDomElement(QDomDocument &doc) const =0
Is reimplemented in classes inheriting from this to serialize it.
QHash< QString, QgsAttributes > cachedAttributes
Cache for joined attributes to provide fast lookup (size is 0 if no memory caching) ...
The attribute value should not be shown in the attribute form.
virtual void setIsGroupBox(bool isGroupBox)
Determines if this container is rendered as collapsible group box or tab in a tabwidget.
This class manages a set of relations between layers.
The QgsConditionalLayerStyles class holds conditional style information for a layer.
virtual bool readXml(const QDomNode &layer_node)
Called by readLayerXML(), used by children to read state specific to them from project files...
Abstract base class - its implementations define different approaches to the labeling of a vector lay...
uuid generator - readonly and automatically intialized
This is a container for attribute editors, used to group them visually in the attribute form if it is...
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
Base class for utility classes that encapsulate information necessary for rendering of map layers...
void setFeatureFormSuppress(QgsVectorLayer::FeatureFormSuppress s)
Set type of feature form pop-up suppression after feature creation (overrides app setting) ...
QStringList * joinFieldNamesSubset() const
Get subset of fields to be used from joined layer.
virtual QString loadNamedStyle(const QString &theURI, bool &theResultFlag)
Retrieve a named style for this layer if one exists (either as a .qml file on disk or as a record in ...
QList< QString > mFields
QSet< int > QgsAttributeIds
QgsAttributeEditorElement(AttributeEditorType type, const QString &name, QObject *parent=NULL)
Constructor.
This is the base class for vector data providers.
Abstract base class for curved geometry type.
Definition: qgscurvev2.h:32
QList< int > QgsAttributeList
virtual QgsRectangle extent()
Return the extent of the layer.
Represents a vector layer which manages a vector based data sets.
QString joinLayerId
Source layer.
AttributeEditorType mType
Abstract base class for simplify geometries using a specific algorithm.
TabData(const QString &name, const QList< QString > &fields, const QList< GroupData > &groups)
QList< GroupData > mGroups