24 QString QgsAttributeIndexAlgorithm::name()
const
26 return QStringLiteral(
"createattributeindex" );
29 QString QgsAttributeIndexAlgorithm::displayName()
const
31 return QObject::tr(
"Create attribute index" );
34 QStringList QgsAttributeIndexAlgorithm::tags()
const
36 return QObject::tr(
"table,attribute,index,create,vector" ).split(
',' );
39 QString QgsAttributeIndexAlgorithm::group()
const
41 return QObject::tr(
"Vector general" );
44 QString QgsAttributeIndexAlgorithm::groupId()
const
46 return QStringLiteral(
"vectorgeneral" );
49 QgsProcessingAlgorithm::Flags QgsAttributeIndexAlgorithm::flags()
const
55 QString 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." );
62 QgsAttributeIndexAlgorithm *QgsAttributeIndexAlgorithm::createInstance()
const
64 return new QgsAttributeIndexAlgorithm();
67 void 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( QStringLiteral(
"INPUT" ) ) );
82 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() );