15 #ifndef QGSVECTORDATAPROVIDER_H 16 #define QGSVECTORDATAPROVIDER_H 20 #include "qgis_core.h" 73 DeleteFeatures = 1 << 1,
74 ChangeAttributeValues = 1 << 2,
75 AddAttributes = 1 << 3,
76 DeleteAttributes = 1 << 4,
77 CreateSpatialIndex = 1 << 6,
79 ChangeGeometries = 1 << 8,
80 SelectEncoding = 1 << 13,
81 CreateAttributeIndex = 1 << 12,
82 SimplifyGeometries = 1 << 14,
83 SimplifyGeometriesWithTopologicalValidation = 1 << 15,
84 TransactionSupport = 1 << 16,
85 CircularGeometries = 1 << 17,
86 ChangeFeatures = 1 << 18,
89 RenameAttributes = 1 << 19,
90 FastTruncate = 1 << 20,
91 ReadLayerMetadata = 1 << 21,
92 WriteLayerMetadata = 1 << 22,
98 static const
int EditingCapabilities = AddFeatures | DeleteFeatures |
99 ChangeAttributeValues | ChangeGeometries | AddAttributes | DeleteAttributes |
140 virtual QString storageType()
const;
173 virtual QString dataComment()
const;
204 virtual QStringList uniqueStringsMatching(
int index,
const QString &substring,
int limit = -1,
230 virtual void enumValues(
int index, QStringList &enumList
SIP_OUT )
const { Q_UNUSED( index ); enumList.clear(); }
249 virtual bool truncate();
256 virtual bool addAttributes(
const QList<QgsField> &attributes );
275 virtual bool renameAttributes(
const QgsFieldNameMap &renamedAttributes );
310 virtual QVariant defaultValue(
int fieldIndex )
const;
319 virtual QString defaultValueClause(
int fieldIndex )
const;
327 QgsFieldConstraints::Constraints fieldConstraints(
int fieldIndex )
const;
345 virtual bool changeGeometryValues(
const QgsGeometryMap &geometry_map );
351 virtual bool createSpatialIndex();
354 virtual bool createAttributeIndex(
int field );
362 virtual QgsVectorDataProvider::Capabilities capabilities()
const;
367 QString capabilitiesString()
const;
372 virtual void setEncoding(
const QString &e );
377 QString encoding()
const;
382 int fieldNameIndex(
const QString &fieldName )
const;
387 QMap<QString, int> fieldNameMap()
const;
407 bool supportedType(
const QgsField &field )
const;
411 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 )
412 : mTypeDesc( typeDesc )
413 , mTypeName( typeName )
417 , mMinPrec( minPrec )
418 , mMaxPrec( maxPrec )
419 , mSubType( subType )
435 QList< QgsVectorDataProvider::NativeType > nativeTypes()
const;
444 static QStringList availableEncodings();
449 bool hasErrors()
const;
459 QStringList errors()
const;
465 virtual bool isSaveAndLoadStyleToDatabaseSupported()
const;
471 virtual bool isDeleteStyleFromDatabaseSupported()
const;
473 static QVariant convertValue( QVariant::Type type,
const QString &value );
487 virtual void forceReload();
492 virtual QSet<QgsMapLayerDependency> dependencies()
const;
501 virtual QList<QgsRelation> discoverRelations(
const QgsVectorLayer *
self,
const QList<QgsVectorLayer *> &layers )
const;
507 virtual QVariantMap
metadata()
const {
return QVariantMap(); }
522 virtual QString
translateMetadataValue(
const QString &mdKey,
const QVariant &value )
const { Q_UNUSED( mdKey );
return value.toString(); }
540 void raiseError(
const QString &msg )
const;
548 void clearMinMaxCache();
553 void fillMinMaxCache()
const;
564 void pushError(
const QString &msg )
const;
578 void setNativeTypes(
const QList<QgsVectorDataProvider::NativeType> &nativeTypes );
585 QTextCodec *textEncoding()
const;
588 mutable bool mCacheMinMaxDirty =
true;
589 mutable QMap<int, QVariant> mCacheMinValues, mCacheMaxValues;
592 QTextCodec *mEncoding =
nullptr;
598 QList< NativeType > mNativeTypes;
601 mutable QStringList mErrors;
603 static QStringList sEncodings;
612 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.
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)
Constraint
Constraints which may be present on a field.
QSet< QgsFeatureId > QgsFeatureIds
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
Get the translated metadata value.
Base class for feedback objects to be used for cancelation 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
Get 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.
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).
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.
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
Get metadata, dependent on the provider type, that will be display in the metadata tab of the layer p...