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;
176 virtual
bool isSqlQuery() const;
184 virtual
Qgis::VectorLayerTypeFlags vectorLayerTypeFlags() const;
205 QString sourceName()
const override {
return QString(); }
242 virtual QStringList uniqueStringsMatching(
int index,
const QString &substring,
int limit = -1,
270 virtual void enumValues(
int index, QStringList &enumList
SIP_OUT )
const { Q_UNUSED( index ) enumList.clear(); }
290 virtual bool truncate();
298 virtual bool cancelReload();
305 virtual bool addAttributes(
const QList<QgsField> &attributes );
324 virtual bool renameAttributes(
const QgsFieldNameMap &renamedAttributes );
361 virtual QVariant defaultValue(
int fieldIndex )
const;
370 virtual QString defaultValueClause(
int fieldIndex )
const;
378 QgsFieldConstraints::Constraints fieldConstraints(
int fieldIndex )
const;
396 virtual bool changeGeometryValues(
const QgsGeometryMap &geometry_map );
402 virtual bool createSpatialIndex();
405 virtual bool createAttributeIndex(
int field );
413 Q_INVOKABLE
virtual QgsVectorDataProvider::Capabilities capabilities()
const;
418 QString capabilitiesString()
const;
432 virtual void setEncoding(
const QString &e );
439 QString encoding()
const;
444 int fieldNameIndex(
const QString &fieldName )
const;
449 QMap<QString, int> fieldNameMap()
const;
473 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 )
474 : mTypeDesc( typeDesc )
479 , mMinPrec( minPrec )
480 , mMaxPrec( maxPrec )
481 , mSubType( subType )
497 QList< QgsVectorDataProvider::NativeType > nativeTypes()
const;
506 static QStringList availableEncodings();
511 bool hasErrors()
const;
521 QStringList errors()
const;
527 virtual bool isSaveAndLoadStyleToDatabaseSupported()
const;
533 virtual bool isDeleteStyleFromDatabaseSupported()
const;
569 static QVariant convertValue( QVariant::Type type, const QString &value );
584 virtual QSet<QgsMapLayerDependency> dependencies()
const;
593 virtual QList<QgsRelation> discoverRelations(
const QgsVectorLayer *target,
const QList<QgsVectorLayer *> &layers )
const;
599 virtual QVariantMap
metadata()
const {
return QVariantMap(); }
614 virtual QString
translateMetadataValue(
const QString &mdKey,
const QVariant &value )
const { Q_UNUSED( mdKey )
return value.toString(); }
643 void raiseError( const QString &msg ) const;
651 void clearMinMaxCache();
656 void fillMinMaxCache() const;
667 void pushError( const QString &msg ) const;
688 QTextCodec *textEncoding() const;
691 mutable
bool mCacheMinMaxDirty = true;
692 mutable QMap<
int, QVariant> mCacheMinValues, mCacheMaxValues;
695 QTextCodec *mEncoding =
nullptr;
701 QList< NativeType > mNativeTypes;
704 mutable QStringList mErrors;
708 static QStringList sEncodings;