24QString QgsAttributeIndexAlgorithm::name()
const
26 return QStringLiteral(
"createattributeindex" );
29QString QgsAttributeIndexAlgorithm::displayName()
const
31 return QObject::tr(
"Create attribute index" );
34QStringList QgsAttributeIndexAlgorithm::tags()
const
36 return QObject::tr(
"table,attribute,index,create,vector" ).split(
',' );
39QString QgsAttributeIndexAlgorithm::group()
const
41 return QObject::tr(
"Vector general" );
44QString QgsAttributeIndexAlgorithm::groupId()
const
46 return QStringLiteral(
"vectorgeneral" );
55QString QgsAttributeIndexAlgorithm::shortHelpString()
const
57 return QObject::tr(
"Creates an index to speed up queries made against "
58 "a field in a table. Support for index creation is "
59 "dependent on the layer's data provider and the field type." );
62QgsAttributeIndexAlgorithm *QgsAttributeIndexAlgorithm::createInstance()
const
64 return new QgsAttributeIndexAlgorithm();
67void QgsAttributeIndexAlgorithm::initAlgorithm(
const QVariantMap & )
70 addParameter(
new QgsProcessingParameterField( QStringLiteral(
"FIELD" ), QObject::tr(
"Attribute to index" ), QVariant(), QStringLiteral(
"INPUT" ) ) );
77 QgsVectorLayer *layer = parameterAsVectorLayer( parameters, QStringLiteral(
"INPUT" ), context );
80 throw QgsProcessingException( QObject::tr(
"Could not load source layer for %1." ).arg( QLatin1String(
"INPUT" ) ) );
82 const QString field = parameterAsString( parameters, QStringLiteral(
"FIELD" ), context );
89 feedback->
pushInfo( QObject::tr(
"Can not create attribute index on %1" ).arg( field ) );
98 feedback->
pushInfo( QObject::tr(
"Could not create attribute index" ) );
103 feedback->
pushInfo( QObject::tr(
"Layer's data provider does not support creating attribute indexes" ) );
108 outputs.insert( QStringLiteral(
"OUTPUT" ), layer->
id() );
@ Vector
Tables (i.e. vector layers with or without geometry). When used for a sink this indicates the sink ha...
@ CreateAttributeIndex
Can create indexes on provider's fields.
QFlags< ProcessingAlgorithmFlag > ProcessingAlgorithmFlags
Flags indicating how and when an algorithm operates and should be exposed to users.
@ Provider
Field originates from the underlying data provider of the vector layer.
@ NoThreading
Algorithm is not thread safe and cannot be run in a background thread, e.g. for algorithms which mani...
int fieldOriginIndex(int fieldIdx) const
Returns the field's origin index (its meaning is specific to each type of origin).
Q_INVOKABLE int lookupField(const QString &fieldName) const
Looks up field's index from the field name.
virtual Qgis::ProcessingAlgorithmFlags flags() const
Returns the flags indicating how and when the algorithm operates and should be exposed to users.
Contains information about the context in which a processing algorithm is executed.
Custom exception class for processing related exceptions.
Base class for providing feedback from a processing algorithm.
virtual void pushInfo(const QString &info)
Pushes a general informational message from the algorithm.
A vector layer output for processing algorithms.
A vector layer or feature source field parameter for processing algorithms.
A vector layer (with or without geometry) parameter for processing algorithms.
This is the base class for vector data providers.
virtual Q_INVOKABLE Qgis::VectorProviderCapabilities capabilities() const
Returns flags containing the supported capabilities.
virtual bool createAttributeIndex(int field)
Create an attribute index on the datasource.
Represents a vector layer which manages a vector based data sets.
QgsVectorDataProvider * dataProvider() FINAL
Returns the layer's data provider, it may be nullptr.