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,
257 virtual void enumValues(
int index, QStringList &enumList
SIP_OUT )
const { Q_UNUSED( index ); enumList.clear(); }
276 virtual bool truncate();
284 virtual bool cancelReload();
291 virtual bool addAttributes(
const QList<QgsField> &attributes );
310 virtual bool renameAttributes(
const QgsFieldNameMap &renamedAttributes );
345 virtual QVariant defaultValue(
int fieldIndex )
const;
354 virtual QString defaultValueClause(
int fieldIndex )
const;
362 QgsFieldConstraints::Constraints fieldConstraints(
int fieldIndex )
const;
380 virtual bool changeGeometryValues(
const QgsGeometryMap &geometry_map );
386 virtual bool createSpatialIndex();
389 virtual bool createAttributeIndex(
int field );
397 virtual QgsVectorDataProvider::Capabilities capabilities()
const;
402 QString capabilitiesString()
const;
407 virtual void setEncoding(
const QString &e );
412 QString encoding()
const;
417 int fieldNameIndex(
const QString &fieldName )
const;
422 QMap<QString, int> fieldNameMap()
const;
442 bool supportedType(
const QgsField &field )
const;
446 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 )
447 : mTypeDesc( typeDesc )
448 , mTypeName( typeName )
452 , mMinPrec( minPrec )
453 , mMaxPrec( maxPrec )
454 , mSubType( subType )
470 QList< QgsVectorDataProvider::NativeType > nativeTypes()
const;
479 static QStringList availableEncodings();
484 bool hasErrors()
const;
494 QStringList errors()
const;
500 virtual bool isSaveAndLoadStyleToDatabaseSupported()
const;
506 virtual bool isDeleteStyleFromDatabaseSupported()
const;
542 static QVariant convertValue( QVariant::Type type,
const QString &value );
556 virtual void forceReload();
561 virtual QSet<QgsMapLayerDependency> dependencies()
const;
570 virtual QList<QgsRelation> discoverRelations(
const QgsVectorLayer *
self,
const QList<QgsVectorLayer *> &layers )
const;
576 virtual QVariantMap
metadata()
const {
return QVariantMap(); }
591 virtual QString
translateMetadataValue(
const QString &mdKey,
const QVariant &value )
const { Q_UNUSED( mdKey );
return value.toString(); }
609 void raiseError(
const QString &msg )
const;
617 void clearMinMaxCache();
622 void fillMinMaxCache()
const;
633 void pushError(
const QString &msg )
const;
647 void setNativeTypes(
const QList<QgsVectorDataProvider::NativeType> &nativeTypes );
654 QTextCodec *textEncoding()
const;
657 mutable bool mCacheMinMaxDirty =
true;
658 mutable QMap<int, QVariant> mCacheMinValues, mCacheMaxValues;
661 QTextCodec *mEncoding =
nullptr;
667 QList< NativeType > mNativeTypes;
670 mutable QStringList mErrors;
672 static QStringList sEncodings;
681 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 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
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 ...