18 #ifndef QGSVECTORLAYER_H
19 #define QGSVECTORLAYER_H
24 #include <QStringList>
51 class QgsGeometryVertexIndex;
81 : QObject( parent ), mType( type ), mName( name ) {}
85 QString
name()
const {
return mName; }
88 virtual QDomElement toDomElement( QDomDocument& doc )
const = 0;
100 , mIsGroupBox( true )
105 virtual QDomElement
toDomElement( QDomDocument& doc )
const override;
109 QList<QgsAttributeEditorElement*>
children()
const {
return mChildren; }
110 virtual QList<QgsAttributeEditorElement*> findElements( AttributeEditorType type )
const;
114 QList<QgsAttributeEditorElement*> mChildren;
126 virtual QDomElement
toDomElement( QDomDocument& doc )
const override;
127 int idx()
const {
return mIdx; }
139 , mRelationId( relationId ) {}
143 , mRelationId( relation.id() )
144 , mRelation( relation ) {}
148 virtual QDomElement
toDomElement( QDomDocument& doc )
const override;
202 void setJoinFieldNamesSubset( QStringList* fieldNamesSubset ) { joinFieldsSubset = QSharedPointer<QStringList>( fieldNamesSubset ); }
526 RangeData() { mMin = QVariant( 0 ); mMax = QVariant( 5 ); mStep = QVariant( 1 );}
527 RangeData( QVariant theMin, QVariant theMax, QVariant theStep )
528 : mMin( theMin ), mMax( theMax ), mStep( theStep ) {}
538 ValueRelationData( QString layer, QString key, QString value,
bool allowNull,
bool orderByValue,
539 bool allowMulti =
false,
540 QString filterExpression = QString::null )
544 , mFilterExpression( filterExpression )
545 , mAllowNull( allowNull )
546 , mOrderByValue( orderByValue )
547 , mAllowMulti( allowMulti )
563 : mName( name ), mFields( fields ) {}
571 TabData( QString name, QList<QString> fields, QList<GroupData> groups )
572 : mName( name ), mFields( fields ), mGroups( groups ) {}
591 QgsVectorLayer( QString path = QString::null, QString baseName = QString::null,
592 QString providerLib = QString::null,
bool loadDefaultStyleFlag =
true );
598 QString storageType()
const;
601 QString capabilitiesString()
const;
604 QString dataComment()
const;
607 void setDisplayField( QString fldName =
"" );
610 const QString displayField()
const;
618 void setDisplayExpression(
const QString &displayExpression );
626 const QString displayExpression();
637 void setProviderEncoding(
const QString& encoding );
640 void setCoordinateSystem();
648 void removeJoin(
const QString& joinLayerId );
650 const QList< QgsVectorJoinInfo >& vectorJoins()
const;
660 void addExpressionField(
const QString& exp,
const QgsField& fld );
669 void removeExpressionField(
int index );
683 int selectedFeatureCount();
693 void select(
QgsRectangle & rect,
bool addToSelection );
709 void invertSelection();
785 bool hasGeometryType()
const;
791 QString providerType()
const;
796 virtual bool readXml(
const QDomNode& layer_node )
override;
801 virtual bool writeXml( QDomNode & layer_node, QDomDocument & doc )
override;
811 virtual void saveStyleToDatabase( QString name, QString description,
812 bool useAsDefault, QString uiFileContent,
823 virtual int listStylesInDatabase( QStringList &ids, QStringList &names,
824 QStringList &descriptions, QString &msgError );
829 virtual QString getStyleFromDatabase( QString styleId, QString &msgError );
837 virtual QString
loadNamedStyle(
const QString &theURI,
bool &theResultFlag,
bool loadFromLocalDb );
843 virtual QString
loadNamedStyle(
const QString &theURI,
bool &theResultFlag )
override;
855 virtual bool applyNamedStyle( QString namedStyle, QString &errorMsg );
868 bool readSymbology(
const QDomNode& node, QString& errorMessage )
override;
876 bool writeSymbology( QDomNode& node, QDomDocument& doc, QString& errorMessage )
const override;
878 bool writeSld( QDomNode& node, QDomDocument& doc, QString& errorMessage )
const;
879 bool readSld(
const QDomNode& node, QString& errorMessage )
override;
888 virtual long featureCount()
const;
903 bool countSymbolFeatures(
bool showProgress =
true );
912 virtual bool setSubsetString( QString subset );
918 virtual QString subsetString();
930 bool addFeature(
QgsFeature& f,
bool alsoUpdateExtent =
true );
944 bool insertVertex(
double x,
double y,
QgsFeatureId atFeatureId,
int beforeVertex );
950 bool moveVertex(
double x,
double y,
QgsFeatureId atFeatureId,
int atVertex );
954 bool deleteVertex(
QgsFeatureId atFeatureId,
int atVertex );
959 bool deleteSelectedFeatures(
int *deletedCount = 0 );
970 int addRing(
const QList<QgsPoint>& ring );
982 int addPart(
const QList<QgsPoint>& ring );
989 int translateFeature(
QgsFeatureId featureId,
double dx,
double dy );
998 int splitParts(
const QList<QgsPoint>& splitLine,
bool topologicalEditing =
false );
1007 int splitFeatures(
const QList<QgsPoint>& splitLine,
bool topologicalEditing =
false );
1033 int addTopologicalPoints(
const QgsPoint& p );
1040 int insertSegmentVerticesForSnap(
const QList<QgsSnappingResult>& snapResults );
1043 void enableLabels(
bool on );
1046 bool hasLabelsEnabled()
const;
1052 virtual bool isReadOnly()
const;
1055 virtual bool isModified()
const;
1063 bool snapPoint(
QgsPoint& point,
double tolerance );
1072 int snapWithContext(
const QgsPoint& startPoint,
1073 double snappingTolerance,
1074 QMultiMap < double, QgsSnappingResult > &snappingResults,
1078 virtual void reload()
override;
1106 int pendingFeatureCount();
1111 bool setReadOnly(
bool readonly =
true );
1114 bool startEditing();
1125 Q_DECL_DEPRECATED
bool changeAttributeValue(
QgsFeatureId fid,
int field, QVariant value,
bool emitSignal );
1137 bool changeAttributeValue(
QgsFeatureId fid,
int field,
const QVariant &newValue,
const QVariant &oldValue = QVariant() );
1141 bool addAttribute(
const QgsField &field );
1144 void addAttributeAlias(
int attIndex, QString aliasString );
1147 void remAttributeAlias(
int attIndex );
1161 const QString editorWidgetV2(
int fieldIdx )
const;
1172 const QString editorWidgetV2(
const QString& fieldName )
const;
1197 QList< QgsAttributeEditorElement* > &attributeEditorElements();
1201 void clearAttributeEditorWidgets();
1204 QString attributeAlias(
int attributeIndex )
const;
1207 QString attributeDisplayName(
int attributeIndex )
const;
1218 bool deleteAttribute(
int attr );
1227 bool deleteAttributes( QList<int> attrs );
1230 bool addFeatures(
QgsFeatureList features,
bool makeSelected =
true );
1250 bool commitChanges();
1251 const QStringList &commitErrors();
1256 bool rollBack(
bool deleteBuffer =
true );
1263 Q_DECL_DEPRECATED EditType editType(
int idx );
1270 Q_DECL_DEPRECATED
void setEditType(
int idx, EditType edit );
1273 EditorLayout editorLayout();
1276 void setEditorLayout( EditorLayout editorLayout );
1306 void setEditorWidgetV2(
int attrIdx,
const QString& widgetType );
1330 Q_DECL_DEPRECATED
void setCheckedState(
int idx, QString checked, QString notChecked );
1336 void setEditForm( QString ui );
1350 void setAnnotationForm(
const QString& ui );
1353 QString editFormInit();
1356 void setEditFormInit( QString
function );
1362 Q_DECL_DEPRECATED QMap<QString, QVariant> valueMap(
int idx );
1369 Q_DECL_DEPRECATED RangeData range(
int idx );
1372 ValueRelationData valueRelation(
int idx );
1380 QList<QgsRelation> referencingRelations(
int idx );
1387 Q_DECL_DEPRECATED QString dateFormat(
int idx );
1394 Q_DECL_DEPRECATED QSize widgetSize(
int idx );
1397 bool fieldEditable(
int idx );
1400 bool labelOnTop(
int idx );
1403 void setFieldEditable(
int idx,
bool editable );
1406 void setLabelOnTop(
int idx,
bool onTop );
1415 void beginEditCommand( QString text );
1418 void endEditCommand();
1421 void destroyEditCommand();
1424 int fieldNameIndex(
const QString& fieldName )
const;
1438 void updateFields();
1441 void createJoinCaches();
1447 void uniqueValues(
int index, QList<QVariant> &uniqueValues,
int limit = -1 );
1450 QVariant minimumValue(
int index );
1453 QVariant maximumValue(
int index );
1456 void setFeatureBlendMode(
const QPainter::CompositionMode &blendMode );
1458 QPainter::CompositionMode featureBlendMode()
const;
1461 void setLayerTransparency(
int layerTransparency );
1463 int layerTransparency()
const;
1527 void removeSelection();
1532 virtual void updateExtents();
1535 void checkJoinLayerRemove( QString theLayerId );
1538 void invalidateSymbolCountedFlag();
1552 void selectionChanged();
1555 void layerModified();
1558 void beforeModifiedCheck()
const;
1561 void editingStarted();
1564 void editingStopped();
1567 void beforeCommitChanges();
1570 void beforeRollBack();
1580 void attributeAdded(
int idx );
1589 void attributeDeleted(
int idx );
1596 void updatedFields();
1597 void layerDeleted();
1599 void attributeValueChanged(
QgsFeatureId fid,
int idx,
const QVariant & );
1603 void committedAttributesDeleted(
const QString& layerId,
const QgsAttributeList& deletedAttributes );
1604 void committedAttributesAdded(
const QString& layerId,
const QList<QgsField>& addedAttributes );
1605 void committedFeaturesAdded(
const QString& layerId,
const QgsFeatureList& addedFeatures );
1606 void committedFeaturesRemoved(
const QString& layerId,
const QgsFeatureIds& deletedFeatureIds );
1607 void committedAttributeValuesChanges(
const QString& layerId,
const QgsChangedAttributesMap& changedAttributesValues );
1608 void committedGeometriesChanges(
const QString& layerId,
const QgsGeometryMap& changedGeometries );
1610 void saveLayerToProject();
1613 void labelingFontNotFound(
QgsVectorLayer* layer,
const QString& fontfamily );
1616 void featureBlendModeChanged(
const QPainter::CompositionMode &blendMode );
1619 void layerTransparencyChanged(
int layerTransparency );
1626 void editCommandStarted(
const QString& text );
1633 void editCommandEnded();
1640 void editCommandDestroyed();
1651 void readCustomSymbology(
const QDomElement& element, QString& errorMessage );
1662 void writeCustomSymbology( QDomElement& element, QDomDocument& doc, QString& errorMessage )
const;
1665 void onRelationsLoaded();
1666 void onJoinedFieldsChanged();
1684 bool setDataProvider( QString
const & provider );
1697 void snapToGeometry(
const QgsPoint& startPoint,
1700 double sqrSnappingTolerance,
1701 QMultiMap<double, QgsSnappingResult>& snappingResults,
1708 void readSldLabeling(
const QDomNode& node );
1716 QString mDisplayField;
1719 QString mDisplayExpression;
1722 QString mProviderKey;
1740 QMap< QString, QString > mAttributeAliasMap;
1743 QList< QgsAttributeEditorElement* > mAttributeEditorElements;
1746 QSet<QString> mExcludeAttributesWMS;
1748 QSet<QString> mExcludeAttributesWFS;
1751 QList< TabData > mTabs;
1769 bool mLabelFontNotFoundNotified;
1772 QPainter::CompositionMode mFeatureBlendMode;
1775 int mLayerTransparency;
1778 bool mVertexMarkerOnlyForSelection;
1780 QStringList mCommitErrors;
1782 QMap< QString, bool> mFieldEditables;
1783 QMap< QString, bool> mLabelOnTop;
1785 QMap<QString, QString> mEditorWidgetV2Types;
1786 QMap<QString, QgsEditorWidgetConfig > mEditorWidgetV2Configs;
1789 EditorLayout mEditorLayout;
1791 QString mEditForm, mEditFormInit;
1798 QString mAnnotationForm;
1823 bool mSymbolFeatureCounted;
1826 QMap<QgsSymbolV2*, long> mSymbolFeatureCountMap;