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; }
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 );
972 int addRing(
const QList<QgsPoint>& ring,
QgsFeatureId* featureId = 0 );
984 int addPart(
const QList<QgsPoint>& ring );
991 int translateFeature(
QgsFeatureId featureId,
double dx,
double dy );
1000 int splitParts(
const QList<QgsPoint>& splitLine,
bool topologicalEditing =
false );
1009 int splitFeatures(
const QList<QgsPoint>& splitLine,
bool topologicalEditing =
false );
1035 int addTopologicalPoints(
const QgsPoint& p );
1042 int insertSegmentVerticesForSnap(
const QList<QgsSnappingResult>& snapResults );
1045 void enableLabels(
bool on );
1048 bool hasLabelsEnabled()
const;
1051 virtual bool isEditable()
const override;
1054 virtual bool isReadOnly()
const;
1057 virtual bool isModified()
const;
1065 bool snapPoint(
QgsPoint& point,
double tolerance );
1074 int snapWithContext(
const QgsPoint& startPoint,
1075 double snappingTolerance,
1076 QMultiMap < double, QgsSnappingResult > &snappingResults,
1080 virtual void reload()
override;
1108 int pendingFeatureCount();
1113 bool setReadOnly(
bool readonly =
true );
1116 bool startEditing();
1127 Q_DECL_DEPRECATED
bool changeAttributeValue(
QgsFeatureId fid,
int field, QVariant value,
bool emitSignal );
1139 bool changeAttributeValue(
QgsFeatureId fid,
int field,
const QVariant &newValue,
const QVariant &oldValue = QVariant() );
1143 bool addAttribute(
const QgsField &field );
1146 void addAttributeAlias(
int attIndex, QString aliasString );
1149 void remAttributeAlias(
int attIndex );
1163 const QString editorWidgetV2(
int fieldIdx )
const;
1174 const QString editorWidgetV2(
const QString& fieldName )
const;
1199 QList< QgsAttributeEditorElement* > &attributeEditorElements();
1203 void clearAttributeEditorWidgets();
1206 QString attributeAlias(
int attributeIndex )
const;
1209 QString attributeDisplayName(
int attributeIndex )
const;
1220 bool deleteAttribute(
int attr );
1229 bool deleteAttributes( QList<int> attrs );
1232 bool addFeatures(
QgsFeatureList features,
bool makeSelected =
true );
1252 bool commitChanges();
1253 const QStringList &commitErrors();
1258 bool rollBack(
bool deleteBuffer =
true );
1265 Q_DECL_DEPRECATED
EditType editType(
int idx );
1272 Q_DECL_DEPRECATED
void setEditType(
int idx,
EditType edit );
1308 void setEditorWidgetV2(
int attrIdx,
const QString& widgetType );
1332 Q_DECL_DEPRECATED
void setCheckedState(
int idx, QString checked, QString notChecked );
1338 void setEditForm( QString ui );
1352 void setAnnotationForm(
const QString& ui );
1355 QString editFormInit();
1358 void setEditFormInit( QString
function );
1364 Q_DECL_DEPRECATED QMap<QString, QVariant> valueMap(
int idx );
1371 Q_DECL_DEPRECATED
RangeData range(
int idx );
1382 QList<QgsRelation> referencingRelations(
int idx );
1389 Q_DECL_DEPRECATED QString dateFormat(
int idx );
1396 Q_DECL_DEPRECATED QSize widgetSize(
int idx );
1399 bool fieldEditable(
int idx );
1402 bool labelOnTop(
int idx );
1405 void setFieldEditable(
int idx,
bool editable );
1408 void setLabelOnTop(
int idx,
bool onTop );
1417 void beginEditCommand( QString text );
1420 void endEditCommand();
1423 void destroyEditCommand();
1426 int fieldNameIndex(
const QString& fieldName )
const;
1440 void updateFields();
1443 void createJoinCaches();
1449 void uniqueValues(
int index, QList<QVariant> &uniqueValues,
int limit = -1 );
1452 QVariant minimumValue(
int index );
1455 QVariant maximumValue(
int index );
1458 void setFeatureBlendMode(
const QPainter::CompositionMode &blendMode );
1460 QPainter::CompositionMode featureBlendMode()
const;
1463 void setLayerTransparency(
int layerTransparency );
1465 int layerTransparency()
const;
1467 QString metadata()
override;
1529 void removeSelection();
1534 virtual void updateExtents();
1537 void checkJoinLayerRemove( QString theLayerId );
1540 void invalidateSymbolCountedFlag();
1554 void selectionChanged();
1557 void layerModified();
1560 void beforeModifiedCheck()
const;
1563 void editingStarted();
1566 void editingStopped();
1569 void beforeCommitChanges();
1572 void beforeRollBack();
1582 void attributeAdded(
int idx );
1591 void attributeDeleted(
int idx );
1598 void updatedFields();
1599 void layerDeleted();
1601 void attributeValueChanged(
QgsFeatureId fid,
int idx,
const QVariant & );
1605 void committedAttributesDeleted(
const QString& layerId,
const QgsAttributeList& deletedAttributes );
1606 void committedAttributesAdded(
const QString& layerId,
const QList<QgsField>& addedAttributes );
1607 void committedFeaturesAdded(
const QString& layerId,
const QgsFeatureList& addedFeatures );
1608 void committedFeaturesRemoved(
const QString& layerId,
const QgsFeatureIds& deletedFeatureIds );
1609 void committedAttributeValuesChanges(
const QString& layerId,
const QgsChangedAttributesMap& changedAttributesValues );
1610 void committedGeometriesChanges(
const QString& layerId,
const QgsGeometryMap& changedGeometries );
1612 void saveLayerToProject();
1615 void labelingFontNotFound(
QgsVectorLayer* layer,
const QString& fontfamily );
1618 void featureBlendModeChanged(
const QPainter::CompositionMode &blendMode );
1621 void layerTransparencyChanged(
int layerTransparency );
1628 void editCommandStarted(
const QString& text );
1635 void editCommandEnded();
1642 void editCommandDestroyed();
1653 void readCustomSymbology(
const QDomElement& element, QString& errorMessage );
1664 void writeCustomSymbology( QDomElement& element, QDomDocument& doc, QString& errorMessage )
const;
1667 void onRelationsLoaded();
1668 void onJoinedFieldsChanged();
1686 bool setDataProvider( QString
const & provider );
1699 void snapToGeometry(
const QgsPoint& startPoint,
1702 double sqrSnappingTolerance,
1703 QMultiMap<double, QgsSnappingResult>& snappingResults,
1710 void readSldLabeling(
const QDomNode& node );
1718 QString mDisplayField;
1721 QString mDisplayExpression;
1724 QString mProviderKey;
1742 QMap< QString, QString > mAttributeAliasMap;
1745 QList< QgsAttributeEditorElement* > mAttributeEditorElements;
1748 QSet<QString> mExcludeAttributesWMS;
1750 QSet<QString> mExcludeAttributesWFS;
1753 QList< TabData > mTabs;
1771 bool mLabelFontNotFoundNotified;
1774 QPainter::CompositionMode mFeatureBlendMode;
1777 int mLayerTransparency;
1780 bool mVertexMarkerOnlyForSelection;
1782 QStringList mCommitErrors;
1784 QMap< QString, bool> mFieldEditables;
1785 QMap< QString, bool> mLabelOnTop;
1787 QMap<QString, QString> mEditorWidgetV2Types;
1788 QMap<QString, QgsEditorWidgetConfig > mEditorWidgetV2Configs;
1793 QString mEditForm, mEditFormInit;
1800 QString mAnnotationForm;
1825 bool mSymbolFeatureCounted;
1828 QMap<QgsSymbolV2*, long> mSymbolFeatureCountMap;
Wrapper for iterator of features from vector data provider or vector layer.
QString annotationForm() const
get annotation form
QMap< QgsFeatureId, QgsGeometry > QgsGeometryMap
A rectangle specified with double values.
Base class for all map layer types.
QString joinFieldName
Join field in the source layer.
const QSet< QString > & excludeAttributesWMS() const
void setExcludeAttributesWFS(const QSet< QString > &att)
QString targetFieldName
Join field in the target layer.
virtual bool isGroupBox() const
RangeData(QVariant theMin, QVariant theMax, QVariant theStep)
QgsAttributeAction * actions()
EditorLayout
The different types to layout the attribute editor.
The attribute value should not be changed in the attribute form.
QSet< QgsFeatureId > QgsFeatureIds
QList< QgsFeature > QgsFeatureList
void setExcludeAttributesWMS(const QSet< QString > &att)
int joinFieldIndex
Join field index in the source layer.
Storage and management of actions associated with Qgis layer attributes.
const QgsVectorSimplifyMethod & simplifyMethod() const
Returns the simplification settings for fast rendering of features.
VertexMarkerType
Editing vertex markers.
QgsVectorLayer::FeatureFormSuppress featureFormSuppress() const
Type of feature form pop-up suppression after feature creation (overrides app setting) ...
SimplifyHint
Simplification flags for fast rendering of features.
Container of fields for a vector layer.
WkbType
Used for symbology operations.
virtual ~QgsAttributeEditorElement()
const QgsRelation & relation() const
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...
const QgsDiagramLayerSettings * diagramLayerSettings() const
QgsAttributeEditorField(QString name, int idx, QObject *parent)
TabData(QString name, QList< QString > fields, QList< GroupData > groups)
QgsGeometryCache * cache()
QgsAttributeEditorRelation(QString name, const QString &relationId, QObject *parent)
Returns diagram settings for a feature.
Manages joined fields for a vector layer.
Perform transforms between map coordinates and device coordinates.
SnappingType
Snap to vertex, to segment or both.
QString prefix
An optional prefix.
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
The attribute value should not be shown in the attribute form.
const QSet< QString > & excludeAttributesWFS() const
~QgsAttributeEditorRelation()
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QList< int > QgsAttributeList
AttributeEditorType type() const
QSharedPointer< QStringList > joinFieldsSubset
Subset of fields to use from joined layer.
~QgsAttributeEditorField()
Encapsulate a field in an attribute table or data source.
const QMap< QString, QString > & attributeAliases() const
const QgsDiagramRendererV2 * diagramRenderer() const
A class to represent a point.
QList< QgsAttributeEditorElement * > children() const
Partial snapshot of vector layer's state (only the members necessary for access to features) ...
A class to render labels.
~QgsAttributeEditorContainer()
uuid generator - readonly and automatically intialized
This class contains information how to simplify geometries fetched from a vector layer.
Contains information about the context of a rendering operation.
ValueRelationData(QString layer, QString key, QString value, bool allowNull, bool orderByValue, bool allowMulti=false, QString filterExpression=QString::null)
Buffers information about expression fields for a vector layer.
virtual QDomElement toDomElement(QDomDocument &doc) const =0
QHash< QString, QgsAttributes > cachedAttributes
Cache for joined attributes to provide fast lookup (size is 0 if no memory caching) ...
QMap< QgsFeatureId, QgsAttributeMap > QgsChangedAttributesMap
GroupData(QString name, QList< QString > fields)
virtual void setIsGroupBox(bool isGroupBox)
This class manages a set of relations between layers.
QString mFilterExpression
QgsAttributeEditorRelation(QString name, const QgsRelation &relation, QObject *parent)
void setSimplifyMethod(const QgsVectorSimplifyMethod &simplifyMethod)
Set the simplification settings for fast rendering of features.
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.
QgsAttributeEditorElement(AttributeEditorType type, QString name, QObject *parent=NULL)
QSet< int > QgsAttributeIds
QgsAttributeEditorContainer(QString name, QObject *parent)
FeatureFormSuppress
Types of feature form suppression after feature creation.
This is the base class for vector data providers.
QList< int > QgsAttributeList
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.
QList< GroupData > mGroups