31 qDeleteAll( mAlgorithms );
66 qDeleteAll( mAlgorithms );
77 return mAlgorithms.values();
82 return mAlgorithms.value( name );
90 if ( mAlgorithms.contains( algorithm->
name() ) )
120 if ( outputPath.isEmpty() )
128 error = tr(
"Missing parameter value %1" ).arg( parameter->
description() );
136 if ( outputPath.startsWith( QLatin1String(
"memory:" ) ) )
140 error = tr(
"This algorithm only supports disk-based outputs" );
149 QMap<QString, QVariant> options;
150 bool useWriter =
false;
153 QgsProcessingUtils::parseDestinationString( outputPath, providerKey, uri, layerName, format, options, useWriter, extension );
155 if ( providerKey != QLatin1String(
"ogr" ) )
159 error = tr(
"This algorithm only supports disk-based outputs" );
167 error = tr(
"“.%1” files are not supported as outputs for this algorithm" ).arg( extension );
174 QFileInfo fi( outputPath );
175 const QString extension = fi.completeSuffix();
178 error = tr(
"“.%1” files are not supported as outputs for this algorithm" ).arg( extension );
192 const QString defaultExtension = hasGeometry ? QStringLiteral(
"shp" ) : QStringLiteral(
"dbf" );
193 const QString userDefault = settings.
value( QStringLiteral(
"Processing/DefaultOutputVectorLayerExt" ), defaultExtension,
QgsSettings::Core ).toString();
196 if ( supportedExtensions.contains( userDefault, Qt::CaseInsensitive ) )
201 else if ( !supportedExtensions.empty() )
203 return supportedExtensions.at( 0 );
209 return defaultExtension;
216 const QString defaultExtension = QStringLiteral(
"tif" );
217 const QString userDefault = settings.
value( QStringLiteral(
"Processing/DefaultOutputRasterLayerExt" ), defaultExtension,
QgsSettings::Core ).toString();
220 if ( supportedExtensions.contains( userDefault, Qt::CaseInsensitive ) )
225 else if ( !supportedExtensions.empty() )
227 return supportedExtensions.at( 0 );
232 return defaultExtension;
void setProvider(QgsProcessingProvider *provider)
Associates this algorithm with its provider.
virtual QStringList supportedOutputTableExtensions() const
Returns a list of the table (geometry-less vector layers) file extensions supported by this provider...
virtual QString name() const =0
Returns the provider name, which is used to describe the provider within the GUI. ...
~QgsProcessingProvider() override
QList< const QgsProcessingAlgorithm *> algorithms() const
Returns a list of algorithms supplied by this provider.
This class is a composition of two QSettings instances:
QVariant value(const QString &key, const QVariant &defaultValue=QVariant(), Section section=NoSection) const
Returns the value for setting key.
virtual QString name() const =0
Returns the algorithm name, used for identifying the algorithm.
virtual QString helpId() const
Returns the provider help id string, used for creating QgsHelp urls for algorithms belong to this pro...
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
virtual QStringList supportedOutputRasterLayerExtensions() const
Returns a list of the raster format file extensions supported by this provider.
virtual QString versionInfo() const
Returns a version information string for the provider, or an empty string if this is not applicable (...
static QIcon getThemeIcon(const QString &name)
Helper to get a theme icon.
virtual bool supportsNonFileBasedOutput() const
Returns true if the provider supports non-file based outputs (such as memory layers or direct databas...
virtual QString svgIconPath() const
Returns a path to an SVG version of the provider's icon.
Base class for all parameter definitions which represent file or layer destinations, e.g.
Abstract base class for processing algorithms.
virtual void initAlgorithm(const QVariantMap &configuration=QVariantMap())=0
Initializes the algorithm using the specified configuration.
static QString typeName()
Returns the type name for the parameter class.
QgsProcessingProvider(QObject *parent=nullptr)
Constructor for QgsProcessingProvider.
static QStringList supportedFormatExtensions(RasterFormatOptions options=SortRecommended)
Returns a list of file extensions for supported formats.
virtual bool isActive() const
Returns true if the provider is active and able to run algorithms.
virtual QString id() const =0
Returns the unique provider id, used for identifying the provider.
Flags flags() const
Returns any flags associated with the parameter.
virtual QString defaultRasterFileExtension() const
Returns the default file extension to use for raster outputs created by the provider.
virtual void loadAlgorithms()=0
Loads all algorithms belonging to this provider.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
static QStringList supportedFormatExtensions(VectorFormatOptions options=SortRecommended)
Returns a list of file extensions for supported formats, e.g "shp", "gpkg".
virtual QString type() const =0
Unique parameter type name.
void refreshAlgorithms()
Refreshes the algorithms available from the provider, causing it to re-populate with all associated a...
virtual QString defaultVectorFileExtension(bool hasGeometry=true) const
Returns the default file extension to use for vector outputs created by the provider.
const QgsProcessingAlgorithm * algorithm(const QString &name) const
Returns the matching algorithm by name, or nullptr if no matching algorithm is contained by this prov...
virtual bool isSupportedOutputValue(const QVariant &outputValue, const QgsProcessingDestinationParameter *parameter, QgsProcessingContext &context, QString &error) const
Returns true if the specified outputValue is of a supported file format for the given destination par...
static QString parameterAsOutputLayer(const QgsProcessingParameterDefinition *definition, const QVariantMap ¶meters, QgsProcessingContext &context)
Evaluates the parameter with matching definition to a output layer destination.
static QString typeName()
Returns the type name for the parameter class.
static QString typeName()
Returns the type name for the parameter class.
bool addAlgorithm(QgsProcessingAlgorithm *algorithm)
Adds an algorithm to the provider.
virtual QIcon icon() const
Returns an icon for the provider.
virtual QString longName() const
Returns the longer version of the provider name, which can include extra details such as version numb...
virtual QStringList supportedOutputVectorLayerExtensions() const
Returns a list of the vector format file extensions supported by this provider.
Contains information about the context in which a processing algorithm is executed.
QString description() const
Returns the description for the parameter.
void algorithmsLoaded()
Emitted when the provider has loaded (or refreshed) its list of available algorithms.