15 #ifndef QGSVECTORDATAPROVIDER_H 16 #define QGSVECTORDATAPROVIDER_H 20 #include "qgis_core.h" 75 DeleteFeatures = 1 << 1,
76 ChangeAttributeValues = 1 << 2,
77 AddAttributes = 1 << 3,
78 DeleteAttributes = 1 << 4,
79 CreateSpatialIndex = 1 << 6,
81 ChangeGeometries = 1 << 8,
82 SelectEncoding = 1 << 13,
83 CreateAttributeIndex = 1 << 12,
84 SimplifyGeometries = 1 << 14,
85 SimplifyGeometriesWithTopologicalValidation = 1 << 15,
86 TransactionSupport = 1 << 16,
87 CircularGeometries = 1 << 17,
88 ChangeFeatures = 1 << 18,
91 RenameAttributes = 1 << 19,
92 FastTruncate = 1 << 20,
93 ReadLayerMetadata = 1 << 21,
94 WriteLayerMetadata = 1 << 22,
95 CancelSupport = 1 << 23,
96 CreateRenderer = 1 << 24,
97 CreateLabeling = 1 << 25,
103 static const
int EditingCapabilities = AddFeatures | DeleteFeatures |
104 ChangeAttributeValues | ChangeGeometries | AddAttributes | DeleteAttributes |
148 virtual QString storageType()
const;
173 virtual bool empty()
const;
200 virtual QString dataComment()
const;
231 virtual QStringList uniqueStringsMatching(
int index,
const QString &substring,
int limit = -1,
259 virtual void enumValues(
int index, QStringList &enumList
SIP_OUT )
const { Q_UNUSED( index ) enumList.clear(); }
278 virtual bool truncate();
286 virtual bool cancelReload();
293 virtual bool addAttributes(
const QList<QgsField> &attributes );
312 virtual bool renameAttributes(
const QgsFieldNameMap &renamedAttributes );
347 virtual QVariant defaultValue(
int fieldIndex )
const;
356 virtual QString defaultValueClause(
int fieldIndex )
const;
364 QgsFieldConstraints::Constraints fieldConstraints(
int fieldIndex )
const;
382 virtual bool changeGeometryValues(
const QgsGeometryMap &geometry_map );
388 virtual bool createSpatialIndex();
391 virtual bool createAttributeIndex(
int field );
399 virtual QgsVectorDataProvider::Capabilities capabilities()
const;
404 QString capabilitiesString()
const;
409 virtual void setEncoding(
const QString &e );
414 QString encoding()
const;
419 int fieldNameIndex(
const QString &fieldName )
const;
424 QMap<QString, int> fieldNameMap()
const;
444 bool supportedType(
const QgsField &field )
const;
448 NativeType(
const QString &typeDesc,
const QString &
typeName, QVariant::Type type,
int minLen = 0,
int maxLen = 0,
int minPrec = 0,
int maxPrec = 0, QVariant::Type subType = QVariant::Invalid )
449 : mTypeDesc( typeDesc )
450 , mTypeName( typeName )
454 , mMinPrec( minPrec )
455 , mMaxPrec( maxPrec )
456 , mSubType( subType )
472 QList< QgsVectorDataProvider::NativeType > nativeTypes()
const;
481 static QStringList availableEncodings();
486 bool hasErrors()
const;
496 QStringList errors()
const;
502 virtual bool isSaveAndLoadStyleToDatabaseSupported()
const;
508 virtual bool isDeleteStyleFromDatabaseSupported()
const;
544 static QVariant convertValue( QVariant::Type type,
const QString &value );
558 virtual void forceReload();
563 virtual QSet<QgsMapLayerDependency> dependencies()
const;
572 virtual QList<QgsRelation> discoverRelations(
const QgsVectorLayer *
self,
const QList<QgsVectorLayer *> &layers )
const;
578 virtual QVariantMap
metadata()
const {
return QVariantMap(); }
593 virtual QString
translateMetadataValue(
const QString &mdKey,
const QVariant &value )
const { Q_UNUSED( mdKey )
return value.toString(); }
611 void raiseError(
const QString &msg )
const;
619 void clearMinMaxCache();
624 void fillMinMaxCache()
const;
635 void pushError(
const QString &msg )
const;
649 void setNativeTypes(
const QList<QgsVectorDataProvider::NativeType> &nativeTypes );
656 QTextCodec *textEncoding()
const;
659 mutable bool mCacheMinMaxDirty =
true;
660 mutable QMap<int, QVariant> mCacheMinValues, mCacheMaxValues;
663 QTextCodec *mEncoding =
nullptr;
669 QList< NativeType > mNativeTypes;
672 mutable QStringList mErrors;
674 static QStringList sEncodings;
683 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsVectorDataProvider::Capabilities )
Wrapper for iterator of features from vector data provider or vector layer.
QMap< QgsFeatureId, QgsGeometry > QgsGeometryMap
virtual QgsRectangle sourceExtent() const
Returns the extent of all geometries from the source.
A rectangle specified with double values.
QSet< QgsFeatureId > QgsFeatureIds
virtual QgsFields fields() const =0
Returns the fields associated with features in the source.
virtual bool addFeatures(QgsFeatureList &features)
Insert a copy of the given features into the layer (but does not commit it)
FeatureAvailability
Possible return value for hasFeatures() to determine if a source is empty.
Constraint
Constraints which may be present on a field.
QList< QgsFeature > QgsFeatureList
virtual QgsWkbTypes::Type wkbType() const =0
Returns the geometry type for features returned by this source.
An interface for objects which accept features via addFeature(s) methods.
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
Abstract base class for spatial data provider implementations.
virtual QString translateMetadataValue(const QString &mdKey, const QVariant &value) const
Gets the translated metadata value.
const QgsAttributeList & attributeIndexes
Base class for feedback objects to be used for cancellation of something running in a worker thread...
virtual bool doesStrictFeatureTypeCheck() const
Returns true if the provider is strict about the type of inserted features (e.g.
QSet< int > QgsAttributeIds
Type
The WKB type describes the number of dimensions a geometry has.
virtual QVariant minimumValue(int fieldIndex) const
Returns the minimum value for an attribute column or an invalid variant in case of error...
QString sourceName() const override
Returns a friendly display name for the source.
NativeType(const QString &typeDesc, const QString &typeName, QVariant::Type type, int minLen=0, int maxLen=0, int minPrec=0, int maxPrec=0, QVariant::Type subType=QVariant::Invalid)
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
virtual QString translateMetadataKey(const QString &mdKey) const
Gets the translated metadata key.
Capability
enumeration with capabilities that providers might implement
This class wraps a request for features to a vector layer (or directly its vector data provider)...
virtual bool deleteFeatures(const QgsFeatureIds &fid)
Deletes a set of features from the layer (but does not commit it)
Encapsulate a field in an attribute table or data source.
virtual bool changeAttributeValues(QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues)
Changes values of attributes (but does not commit it).
Base class that can be used for any class that is capable of returning features.
QMap< int, QString > QgsFieldNameMap
virtual QgsCoordinateReferenceSystem sourceCrs() const =0
Returns the coordinate reference system for features in the source.
Setting options for creating vector data providers.
QMap< QgsFeatureId, QgsAttributeMap > QgsChangedAttributesMap
An interface for objects which provide features via a getFeatures method.
This class allows including a set of layers in a database-side transaction, provided the layer data p...
This class represents a coordinate reference system (CRS).
Abstract base class - its implementations define different approaches to the labeling of a vector lay...
virtual QVariant maximumValue(int fieldIndex) const
Returns the maximum value for an attribute column or an invalid variant in case of error...
virtual void enumValues(int index, QStringList &enumList) const
Returns the possible enum values of an attribute.
QList< int > QgsAttributeList
This is the base class for vector data providers.
Represents a vector layer which manages a vector based data sets.
virtual FeatureAvailability hasFeatures() const
Determines if there are any features available in the source.
QHash< int, QString > QgsAttrPalIndexNameHash
virtual bool hasMetadata() const
Returns true if the data source has metadata, false otherwise.
Aggregate
Available aggregates to calculate.
virtual QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const =0
Returns an iterator for the features in the source.
A bundle of parameters controlling aggregate calculation.
FeatureCountState
Enumeration of feature count states.
virtual long featureCount() const =0
Returns the number of features contained in the source, or -1 if the feature count is unknown...
virtual QVariantMap metadata() const
Gets metadata, dependent on the provider type, that will be display in the metadata tab of the layer ...