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;
179 virtual QString dataComment()
const;
210 virtual QStringList uniqueStringsMatching(
int index,
const QString &substring,
int limit = -1,
236 virtual void enumValues(
int index, QStringList &enumList
SIP_OUT )
const { Q_UNUSED( index ); enumList.clear(); }
255 virtual bool truncate();
263 virtual bool cancelReload();
270 virtual bool addAttributes(
const QList<QgsField> &attributes );
289 virtual bool renameAttributes(
const QgsFieldNameMap &renamedAttributes );
324 virtual QVariant defaultValue(
int fieldIndex )
const;
333 virtual QString defaultValueClause(
int fieldIndex )
const;
341 QgsFieldConstraints::Constraints fieldConstraints(
int fieldIndex )
const;
359 virtual bool changeGeometryValues(
const QgsGeometryMap &geometry_map );
365 virtual bool createSpatialIndex();
368 virtual bool createAttributeIndex(
int field );
376 virtual QgsVectorDataProvider::Capabilities capabilities()
const;
381 QString capabilitiesString()
const;
386 virtual void setEncoding(
const QString &e );
391 QString encoding()
const;
396 int fieldNameIndex(
const QString &fieldName )
const;
401 QMap<QString, int> fieldNameMap()
const;
421 bool supportedType(
const QgsField &field )
const;
425 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 )
426 : mTypeDesc( typeDesc )
427 , mTypeName( typeName )
431 , mMinPrec( minPrec )
432 , mMaxPrec( maxPrec )
433 , mSubType( subType )
449 QList< QgsVectorDataProvider::NativeType > nativeTypes()
const;
458 static QStringList availableEncodings();
463 bool hasErrors()
const;
473 QStringList errors()
const;
479 virtual bool isSaveAndLoadStyleToDatabaseSupported()
const;
485 virtual bool isDeleteStyleFromDatabaseSupported()
const;
502 virtual QgsFeatureRenderer *createRenderer(
const QVariantMap &configuration = QVariantMap() )
const;
504 static QVariant convertValue( QVariant::Type type,
const QString &value );
518 virtual void forceReload();
523 virtual QSet<QgsMapLayerDependency> dependencies()
const;
532 virtual QList<QgsRelation> discoverRelations(
const QgsVectorLayer *
self,
const QList<QgsVectorLayer *> &layers )
const;
538 virtual QVariantMap
metadata()
const {
return QVariantMap(); }
553 virtual QString
translateMetadataValue(
const QString &mdKey,
const QVariant &value )
const { Q_UNUSED( mdKey );
return value.toString(); }
571 void raiseError(
const QString &msg )
const;
579 void clearMinMaxCache();
584 void fillMinMaxCache()
const;
595 void pushError(
const QString &msg )
const;
609 void setNativeTypes(
const QList<QgsVectorDataProvider::NativeType> &nativeTypes );
616 QTextCodec *textEncoding()
const;
619 mutable bool mCacheMinMaxDirty =
true;
620 mutable QMap<int, QVariant> mCacheMinValues, mCacheMaxValues;
623 QTextCodec *mEncoding =
nullptr;
629 QList< NativeType > mNativeTypes;
632 mutable QStringList mErrors;
634 static QStringList sEncodings;
643 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
Gets 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
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).
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
Gets metadata, dependent on the provider type, that will be display in the metadata tab of the layer ...