15 #ifndef QGSVECTORDATAPROVIDER_H 16 #define QGSVECTORDATAPROVIDER_H 20 #include "qgis_core.h" 74 DeleteFeatures = 1 << 1,
75 ChangeAttributeValues = 1 << 2,
76 AddAttributes = 1 << 3,
77 DeleteAttributes = 1 << 4,
78 CreateSpatialIndex = 1 << 6,
80 ChangeGeometries = 1 << 8,
81 SelectEncoding = 1 << 13,
82 CreateAttributeIndex = 1 << 12,
83 SimplifyGeometries = 1 << 14,
84 SimplifyGeometriesWithTopologicalValidation = 1 << 15,
85 TransactionSupport = 1 << 16,
86 CircularGeometries = 1 << 17,
87 ChangeFeatures = 1 << 18,
90 RenameAttributes = 1 << 19,
91 FastTruncate = 1 << 20,
92 ReadLayerMetadata = 1 << 21,
93 WriteLayerMetadata = 1 << 22,
94 CancelSupport = 1 << 23,
95 CreateRenderer = 1 << 24,
101 static const
int EditingCapabilities = AddFeatures | DeleteFeatures |
102 ChangeAttributeValues | ChangeGeometries | AddAttributes | DeleteAttributes |
146 virtual QString storageType()
const;
171 virtual bool empty()
const;
198 virtual QString dataComment()
const;
229 virtual QStringList uniqueStringsMatching(
int index,
const QString &substring,
int limit = -1,
255 virtual void enumValues(
int index, QStringList &enumList
SIP_OUT )
const { Q_UNUSED( index ); enumList.clear(); }
274 virtual bool truncate();
282 virtual bool cancelReload();
289 virtual bool addAttributes(
const QList<QgsField> &attributes );
308 virtual bool renameAttributes(
const QgsFieldNameMap &renamedAttributes );
343 virtual QVariant defaultValue(
int fieldIndex )
const;
352 virtual QString defaultValueClause(
int fieldIndex )
const;
360 QgsFieldConstraints::Constraints fieldConstraints(
int fieldIndex )
const;
378 virtual bool changeGeometryValues(
const QgsGeometryMap &geometry_map );
384 virtual bool createSpatialIndex();
387 virtual bool createAttributeIndex(
int field );
395 virtual QgsVectorDataProvider::Capabilities capabilities()
const;
400 QString capabilitiesString()
const;
405 virtual void setEncoding(
const QString &e );
410 QString encoding()
const;
415 int fieldNameIndex(
const QString &fieldName )
const;
420 QMap<QString, int> fieldNameMap()
const;
440 bool supportedType(
const QgsField &field )
const;
444 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 )
445 : mTypeDesc( typeDesc )
446 , mTypeName( typeName )
450 , mMinPrec( minPrec )
451 , mMaxPrec( maxPrec )
452 , mSubType( subType )
468 QList< QgsVectorDataProvider::NativeType > nativeTypes()
const;
477 static QStringList availableEncodings();
482 bool hasErrors()
const;
492 QStringList errors()
const;
498 virtual bool isSaveAndLoadStyleToDatabaseSupported()
const;
504 virtual bool isDeleteStyleFromDatabaseSupported()
const;
523 static QVariant convertValue( QVariant::Type type,
const QString &value );
537 virtual void forceReload();
542 virtual QSet<QgsMapLayerDependency> dependencies()
const;
551 virtual QList<QgsRelation> discoverRelations(
const QgsVectorLayer *
self,
const QList<QgsVectorLayer *> &layers )
const;
557 virtual QVariantMap
metadata()
const {
return QVariantMap(); }
572 virtual QString
translateMetadataValue(
const QString &mdKey,
const QVariant &value )
const { Q_UNUSED( mdKey );
return value.toString(); }
590 void raiseError(
const QString &msg )
const;
598 void clearMinMaxCache();
603 void fillMinMaxCache()
const;
614 void pushError(
const QString &msg )
const;
628 void setNativeTypes(
const QList<QgsVectorDataProvider::NativeType> &nativeTypes );
635 QTextCodec *textEncoding()
const;
638 mutable bool mCacheMinMaxDirty =
true;
639 mutable QMap<int, QVariant> mCacheMinValues, mCacheMaxValues;
642 QTextCodec *mEncoding =
nullptr;
648 QList< NativeType > mNativeTypes;
651 mutable QStringList mErrors;
653 static QStringList sEncodings;
662 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsVectorDataProvider::Capabilities )
Wrapper for iterator of features from vector data provider or vector layer.
QMap< QgsFeatureId, QgsGeometry > QgsGeometryMap
virtual QVariant maximumValue(int fieldIndex) const
Returns the maximum value for an attribute column or an invalid variant in case of error...
A rectangle specified with double values.
virtual QString translateMetadataKey(const QString &mdKey) const
Gets the translated metadata key.
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.
const QgsAttributeList & attributeIndexes
Base class for feedback objects to be used for cancellation of something running in a worker thread...
QSet< int > QgsAttributeIds
Type
The WKB type describes the number of dimensions a geometry has.
QString sourceName() const override
Returns a friendly display name for the source.
virtual QgsRectangle sourceExtent() const
Returns the extent of all geometries from 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...
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.
virtual QVariant minimumValue(int fieldIndex) const
Returns the minimum value for an attribute column or an invalid variant in case of error...
QMap< QgsFeatureId, QgsAttributeMap > QgsChangedAttributesMap
An interface for objects which provide features via a getFeatures method.
virtual bool doesStrictFeatureTypeCheck() const
Returns true if the provider is strict about the type of inserted features (e.g.
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).
QList< int > QgsAttributeList
virtual QString translateMetadataValue(const QString &mdKey, const QVariant &value) const
Gets the translated metadata value.
This is the base class for vector data providers.
virtual bool hasMetadata() const
Returns true if the data source has metadata, false otherwise.
Represents a vector layer which manages a vector based data sets.
QHash< int, QString > QgsAttrPalIndexNameHash
virtual void enumValues(int index, QStringList &enumList) const
Returns the possible enum values of an attribute.
virtual FeatureAvailability hasFeatures() const
Determines if there are any features available in the source.
Aggregate
Available aggregates to calculate.
virtual QVariantMap metadata() const
Gets metadata, dependent on the provider type, that will be display in the metadata tab of the layer ...
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...