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,
92 RenameAttributes = 1 << 19,
93 FastTruncate = 1 << 20,
94 ReadLayerMetadata = 1 << 21,
95 WriteLayerMetadata = 1 << 22,
96 CancelSupport = 1 << 23,
97 CreateRenderer = 1 << 24,
98 CreateLabeling = 1 << 25,
101 Q_DECLARE_FLAGS( Capabilities, Capability )
104 static const
int EditingCapabilities = AddFeatures | DeleteFeatures |
105 ChangeAttributeValues | ChangeGeometries | AddAttributes | DeleteAttributes |
149 virtual QString storageType()
const;
174 virtual bool empty()
const;
232 virtual QStringList uniqueStringsMatching(
int index,
const QString &substring,
int limit = -1,
260 virtual void enumValues(
int index, QStringList &enumList
SIP_OUT )
const { Q_UNUSED( index ) enumList.clear(); }
279 virtual bool truncate();
287 virtual bool cancelReload();
294 virtual bool addAttributes(
const QList<QgsField> &attributes );
313 virtual bool renameAttributes(
const QgsFieldNameMap &renamedAttributes );
350 virtual QVariant defaultValue(
int fieldIndex )
const;
359 virtual QString defaultValueClause(
int fieldIndex )
const;
367 QgsFieldConstraints::Constraints fieldConstraints(
int fieldIndex )
const;
385 virtual bool changeGeometryValues(
const QgsGeometryMap &geometry_map );
391 virtual bool createSpatialIndex();
394 virtual bool createAttributeIndex(
int field );
402 virtual QgsVectorDataProvider::Capabilities capabilities()
const;
407 QString capabilitiesString()
const;
421 virtual void setEncoding(
const QString &e );
428 QString encoding()
const;
433 int fieldNameIndex(
const QString &fieldName )
const;
438 QMap<QString, int> fieldNameMap()
const;
458 bool supportedType(
const QgsField &field )
const;
462 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 )
463 : mTypeDesc( typeDesc )
468 , mMinPrec( minPrec )
469 , mMaxPrec( maxPrec )
470 , mSubType( subType )
486 QList< QgsVectorDataProvider::NativeType > nativeTypes()
const;
495 static QStringList availableEncodings();
500 bool hasErrors()
const;
510 QStringList errors()
const;
516 virtual bool isSaveAndLoadStyleToDatabaseSupported()
const;
522 virtual bool isDeleteStyleFromDatabaseSupported()
const;
558 static QVariant convertValue( QVariant::Type type, const QString &value );
573 virtual QSet<QgsMapLayerDependency> dependencies()
const;
582 virtual QList<QgsRelation> discoverRelations(
const QgsVectorLayer *
self,
const QList<QgsVectorLayer *> &layers )
const;
588 virtual QVariantMap
metadata()
const {
return QVariantMap(); }
603 virtual QString
translateMetadataValue(
const QString &mdKey,
const QVariant &value )
const { Q_UNUSED( mdKey )
return value.toString(); }
632 void raiseError( const QString &msg ) const;
640 void clearMinMaxCache();
645 void fillMinMaxCache() const;
656 void pushError( const QString &msg ) const;
677 QTextCodec *textEncoding() const;
680 mutable
bool mCacheMinMaxDirty = true;
681 mutable QMap<
int, QVariant> mCacheMinValues, mCacheMaxValues;
684 QTextCodec *mEncoding =
nullptr;
690 QList< NativeType > mNativeTypes;
693 mutable QStringList mErrors;
697 static QStringList sEncodings;
705 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsVectorDataProvider::Capabilities )