26#include <QDirIterator>
29#include "moc_qgsprocessingmodelprovider.cpp"
31using namespace Qt::StringLiterals;
43 return tr(
"Models" );
81 for (
const QString &folder : folders )
83 loadFromFolder( folder );
89void QgsProcessingModelProvider::onProviderAdded(
const QString &providerId )
91 if ( providerId ==
id() )
97void QgsProcessingModelProvider::loadFromFolder(
const QString &folder )
99 if ( !QFile::exists( folder ) )
102 QDirIterator it( folder, QDir::Files, QDirIterator::Subdirectories );
103 while ( it.hasNext() )
106 const QString modelFile = it.fileName();
107 if ( QFileInfo( modelFile ).suffix().compare(
"model3"_L1, Qt::CaseInsensitive ) == 0 )
109 const QString fullpath = it.filePath();
110 auto modelAlgorithm = std::make_unique<QgsProcessingModelAlgorithm>();
111 if ( modelAlgorithm->fromFile( fullpath ) )
113 if ( !modelAlgorithm->name().isEmpty() )
115 modelAlgorithm->setSourceFilePath( fullpath );
@ Critical
Critical/error message.
static QgsProcessingRegistry * processingRegistry()
Returns the application's processing registry, used for managing processing providers,...
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
static QString iconPath(const QString &iconFile)
Returns path to the desired icon file.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true, const char *file=__builtin_FILE(), const char *function=__builtin_FUNCTION(), int line=__builtin_LINE(), Qgis::StringFormat format=Qgis::StringFormat::PlainText)
Adds a message to the log instance (and creates it if necessary).
QString svgIconPath() const override
Returns a path to an SVG version of the provider's icon.
QString id() const override
Returns the unique provider id, used for identifying the provider.
bool supportsNonFileBasedOutput() const override
Returns true if the provider supports non-file based outputs (such as memory layers or direct databas...
QIcon icon() const override
Returns an icon for the provider.
QString name() const override
Returns the provider name, which is used to describe the provider within the GUI.
QgsProcessingModelProvider(QObject *parent=nullptr)
Constructor for QgsProcessingModelProvider.
void loadAlgorithms() override
Loads all algorithms belonging to this provider.
bool load() override
Loads the provider.
QgsProcessingProvider(QObject *parent=nullptr)
Constructor for QgsProcessingProvider.
void refreshAlgorithms()
Refreshes the algorithms available from the provider, causing it to re-populate with all associated a...
bool addAlgorithm(QgsProcessingAlgorithm *algorithm)
Adds an algorithm to the provider.
void providerAdded(const QString &id)
Emitted when a provider has been added to the registry.
static QStringList modelFolders()
Returns the list of locations for reading Processing model files.
static const QString MODEL_PROVIDER_ID
Constant used for the model provider's ID.
Scoped object for logging of the runtime for a single operation or group of operations.