15 #ifndef QGSVECTORDATAPROVIDER_H
16 #define QGSVECTORDATAPROVIDER_H
20 #include "qgis_core.h"
76 DeleteFeatures = 1 << 1,
77 ChangeAttributeValues = 1 << 2,
78 AddAttributes = 1 << 3,
79 DeleteAttributes = 1 << 4,
80 CreateSpatialIndex = 1 << 6,
82 ChangeGeometries = 1 << 8,
83 SelectEncoding = 1 << 13,
84 CreateAttributeIndex = 1 << 12,
85 SimplifyGeometries = 1 << 14,
86 SimplifyGeometriesWithTopologicalValidation = 1 << 15,
87 TransactionSupport = 1 << 16,
88 CircularGeometries = 1 << 17,
89 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,
96 CreateLabeling = 1 << 25,
100 Q_DECLARE_FLAGS( Capabilities, Capability )
103 static const
int EditingCapabilities = AddFeatures | DeleteFeatures |
104 ChangeAttributeValues | ChangeGeometries | AddAttributes | DeleteAttributes |
127 QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags() );
150 virtual QString storageType()
const;
175 virtual bool empty()
const;
233 virtual QStringList uniqueStringsMatching(
int index,
const QString &substring,
int limit = -1,
261 virtual void enumValues(
int index, QStringList &enumList
SIP_OUT )
const { Q_UNUSED( index ) enumList.clear(); }
281 virtual bool truncate();
289 virtual bool cancelReload();
296 virtual bool addAttributes(
const QList<QgsField> &attributes );
315 virtual bool renameAttributes(
const QgsFieldNameMap &renamedAttributes );
352 virtual QVariant defaultValue(
int fieldIndex )
const;
361 virtual QString defaultValueClause(
int fieldIndex )
const;
369 QgsFieldConstraints::Constraints fieldConstraints(
int fieldIndex )
const;
387 virtual bool changeGeometryValues(
const QgsGeometryMap &geometry_map );
393 virtual bool createSpatialIndex();
396 virtual bool createAttributeIndex(
int field );
404 Q_INVOKABLE
virtual QgsVectorDataProvider::Capabilities capabilities()
const;
409 QString capabilitiesString()
const;
423 virtual void setEncoding(
const QString &e );
430 QString encoding()
const;
435 int fieldNameIndex(
const QString &fieldName )
const;
440 QMap<QString, int> fieldNameMap()
const;
464 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 )
465 : mTypeDesc( typeDesc )
470 , mMinPrec( minPrec )
471 , mMaxPrec( maxPrec )
472 , mSubType( subType )
488 QList< QgsVectorDataProvider::NativeType > nativeTypes()
const;
497 static QStringList availableEncodings();
502 bool hasErrors()
const;
512 QStringList errors()
const;
518 virtual bool isSaveAndLoadStyleToDatabaseSupported()
const;
524 virtual bool isDeleteStyleFromDatabaseSupported()
const;
560 static QVariant convertValue( QVariant::Type type, const QString &value );
575 virtual QSet<QgsMapLayerDependency> dependencies()
const;
584 virtual QList<QgsRelation> discoverRelations(
const QgsVectorLayer *
self,
const QList<QgsVectorLayer *> &layers )
const;
590 virtual QVariantMap
metadata()
const {
return QVariantMap(); }
605 virtual QString
translateMetadataValue(
const QString &mdKey,
const QVariant &value )
const { Q_UNUSED( mdKey )
return value.toString(); }
634 void raiseError( const QString &msg ) const;
642 void clearMinMaxCache();
647 void fillMinMaxCache() const;
658 void pushError( const QString &msg ) const;
679 QTextCodec *textEncoding() const;
682 mutable
bool mCacheMinMaxDirty = true;
683 mutable QMap<
int, QVariant> mCacheMinValues, mCacheMaxValues;
686 QTextCodec *mEncoding =
nullptr;
695 mutable QStringList mErrors;
699 static QStringList sEncodings;
Base class that can be used for any class that is capable of returning features.
Abstract base class - its implementations define different approaches to the labeling of a vector lay...
Aggregate
Available aggregates to calculate.
This class represents a coordinate reference system (CRS).
Abstract base class for spatial data provider implementations.
virtual QString dataComment() const
Returns a short comment for the data that this provider is providing access to (e....
virtual QgsDataProviderTemporalCapabilities * temporalCapabilities()
Returns the provider's temporal capabilities.
virtual void reloadData()
Reloads the data from the source for providers with data caches to synchronize, changes in the data s...
Expression contexts are used to encapsulate the parameters around which a QgsExpression should be eva...
Wrapper for iterator of features from vector data provider or vector layer.
This class wraps a request for features to a vector layer (or directly its vector data provider).
An interface for objects which accept features via addFeature(s) methods.
virtual QString lastError() const
Returns the most recent error encountered by the sink, e.g.
An interface for objects which provide features via a getFeatures method.
virtual QgsCoordinateReferenceSystem sourceCrs() const =0
Returns the coordinate reference system for features in the source.
virtual FeatureAvailability hasFeatures() const
Determines if there are any features available in the source.
FeatureAvailability
Possible return value for hasFeatures() to determine if a source is empty.
virtual QVariant minimumValue(int fieldIndex) const
Returns the minimum value for an attribute column or an invalid variant in case of error.
virtual QVariant maximumValue(int fieldIndex) const
Returns the maximum value for an attribute column or an invalid variant in case of error.
virtual QgsRectangle sourceExtent() const
Returns the extent of all geometries from the source.
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Constraint
Constraints which may be present on a field.
Encapsulate a field in an attribute table or data source.
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
A rectangle specified with double values.
This class allows including a set of layers in a database-side transaction, provided the layer data p...
Implementation of data provider temporal properties for QgsVectorDataProviders.
This is the base class for vector data providers.
virtual void enumValues(int index, QStringList &enumList) const
Returns the possible enum values of an attribute.
Capability
enumeration with capabilities that providers might implement
QString sourceName() const override
Returns a friendly display name for the source.
QgsWkbTypes::Type wkbType() const override=0
Returns the geometry type which is returned by this layer.
virtual QgsAbstractFeatureSource * featureSource() const =0
Returns feature source object that can be used for querying provider's data.
virtual QString translateMetadataValue(const QString &mdKey, const QVariant &value) const
Gets the translated metadata value.
virtual bool doesStrictFeatureTypeCheck() const
Returns true if the provider is strict about the type of inserted features (e.g.
virtual bool hasMetadata() const
Returns true if the data source has metadata, false otherwise.
long featureCount() const override=0
Number of features in the layer.
QgsFields fields() const override=0
Returns the fields associated with this data provider.
QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest()) const override=0
Query the provider for features specified in request.
virtual QString translateMetadataKey(const QString &mdKey) const
Gets the translated metadata key.
virtual QVariantMap metadata() const
Gets metadata, dependent on the provider type, that will be display in the metadata tab of the layer ...
FeatureCountState
Enumeration of feature count states.
virtual bool deleteFeatures(const QgsFeatureIds &fid)
Deletes a set of features from the layer (but does not commit it)
virtual bool addFeatures(QgsFeatureList &features)
Insert a copy of the given features into the layer (but does not commit it)
virtual bool changeAttributeValues(QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues)
Changes values of attributes (but does not commit it).
Represents a vector layer which manages a vector based data sets.
Type
The WKB type describes the number of dimensions a geometry has.
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
QMap< int, QString > QgsFieldNameMap
QMap< QgsFeatureId, QgsGeometry > QgsGeometryMap
QMap< QgsFeatureId, QgsAttributeMap > QgsChangedAttributesMap
QList< QgsFeature > QgsFeatureList
QSet< QgsFeatureId > QgsFeatureIds
QList< int > QgsAttributeList
Q_DECLARE_OPERATORS_FOR_FLAGS(QgsField::ConfigurationFlags) CORE_EXPORT QDataStream &operator<<(QDataStream &out
Writes the field to stream out. QGIS version compatibility is not guaranteed.
QSet< int > QgsAttributeIds
QHash< int, QString > QgsAttrPalIndexNameHash
const QgsAttributeList & attributeIndexes
A bundle of parameters controlling aggregate calculation.
Setting options for creating vector data providers.
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)