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,
98 FeatureSymbology = 1 << 27,
101 Q_DECLARE_FLAGS( Capabilities, Capability )
104 static const
int EditingCapabilities = AddFeatures | DeleteFeatures |
105 ChangeAttributeValues | ChangeGeometries | AddAttributes | DeleteAttributes |
140 virtual QString storageType() const;
158 long long featureCount() const override = 0;
165 virtual
bool empty() const;
186 QString sourceName()
const override {
return QString(); }
223 virtual QStringList uniqueStringsMatching(
int index,
const QString &substring,
int limit = -1,
251 virtual void enumValues(
int index, QStringList &enumList
SIP_OUT )
const { Q_UNUSED( index ) enumList.clear(); }
271 virtual bool truncate();
279 virtual bool cancelReload();
286 virtual bool addAttributes(
const QList<QgsField> &attributes );
305 virtual bool renameAttributes(
const QgsFieldNameMap &renamedAttributes );
342 virtual QVariant defaultValue(
int fieldIndex )
const;
351 virtual QString defaultValueClause(
int fieldIndex )
const;
359 QgsFieldConstraints::Constraints fieldConstraints(
int fieldIndex )
const;
377 virtual bool changeGeometryValues(
const QgsGeometryMap &geometry_map );
383 virtual bool createSpatialIndex();
386 virtual bool createAttributeIndex(
int field );
394 Q_INVOKABLE
virtual QgsVectorDataProvider::Capabilities capabilities()
const;
399 QString capabilitiesString()
const;
413 virtual void setEncoding(
const QString &e );
420 QString encoding()
const;
425 int fieldNameIndex(
const QString &fieldName )
const;
430 QMap<QString, int> fieldNameMap()
const;
454 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 )
455 : mTypeDesc( typeDesc )
460 , mMinPrec( minPrec )
461 , mMaxPrec( maxPrec )
462 , mSubType( subType )
478 QList< QgsVectorDataProvider::NativeType > nativeTypes()
const;
487 static QStringList availableEncodings();
492 bool hasErrors()
const;
502 QStringList errors()
const;
508 virtual bool isSaveAndLoadStyleToDatabaseSupported()
const;
514 virtual bool isDeleteStyleFromDatabaseSupported()
const;
550 static QVariant convertValue( QVariant::Type type, const QString &value );
565 virtual QSet<QgsMapLayerDependency> dependencies()
const;
574 virtual QList<QgsRelation> discoverRelations(
const QgsVectorLayer *target,
const QList<QgsVectorLayer *> &layers )
const;
580 virtual QVariantMap
metadata()
const {
return QVariantMap(); }
595 virtual QString
translateMetadataValue(
const QString &mdKey,
const QVariant &value )
const { Q_UNUSED( mdKey )
return value.toString(); }
624 void raiseError( const QString &msg ) const;
632 void clearMinMaxCache();
637 void fillMinMaxCache() const;
648 void pushError( const QString &msg ) const;
669 QTextCodec *textEncoding() const;
672 mutable
bool mCacheMinMaxDirty = true;
673 mutable QMap<
int, QVariant> mCacheMinValues, mCacheMaxValues;
676 QTextCodec *mEncoding =
nullptr;
685 mutable QStringList mErrors;
689 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.
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.
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
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.
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 ...
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.
Handles storage of information regarding WKB types and their properties.
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)