Skip to content
Permalink
Browse files

[processing] Add a flag for algorithms to indicate that they should

not be available from the standalone qgis_process tool (e.g. "select by "
algorithms, which have no meaning outside of a GUI application)

These algorithms are hidden from the algorithm list for qgis_process
and cannot be run by the tool
  • Loading branch information
nyalldawson committed Jul 29, 2020
1 parent 8049da8 commit 937a41a65628efe22389bb38db90e30ec8127462
@@ -49,6 +49,7 @@ Abstract base class for processing algorithms.
FlagCustomException,
FlagPruneModelBranchesBasedOnAlgorithmResults,
FlagSkipGenericModelLogging,
FlagNotAvailableInStandaloneTool,
FlagDeprecated,
};
typedef QFlags<QgsProcessingAlgorithm::Flag> Flags;
@@ -79,6 +79,7 @@ class CORE_EXPORT QgsProcessingAlgorithm
FlagCustomException = 1 << 10, //!< Algorithm raises custom exception notices, don't use the standard ones
FlagPruneModelBranchesBasedOnAlgorithmResults = 1 << 11, //!< Algorithm results will cause remaining model branches to be pruned based on the results of running the algorithm
FlagSkipGenericModelLogging = 1 << 12, //!< When running as part of a model, the generic algorithm setup and results logging should be skipped
FlagNotAvailableInStandaloneTool = 1 << 13, //!< Algorithm should not be available from the standalone "qgis_process" tool. Used to flag algorithms which make no sense outside of the QGIS application, such as "select by..." style algorithms.
FlagDeprecated = FlagHideFromToolbox | FlagHideFromModeler, //!< Algorithm is deprecated
};
Q_DECLARE_FLAGS( Flags, Flag )
@@ -314,6 +314,9 @@ void QgsProcessingExec::listAlgorithms()
const QList<const QgsProcessingAlgorithm *> algorithms = provider->algorithms();
for ( const QgsProcessingAlgorithm *algorithm : algorithms )
{
if ( algorithm->flags() & QgsProcessingAlgorithm::FlagDeprecated || algorithm->flags() & QgsProcessingAlgorithm::FlagNotAvailableInStandaloneTool )
continue;

std::cout << "\t" << algorithm->id().toLocal8Bit().constData() << "\t" << algorithm->displayName().toLocal8Bit().constData() << "\n";
}

@@ -450,6 +453,12 @@ int QgsProcessingExec::execute( const QString &id, const QVariantMap &params, co
std::cerr << QStringLiteral( "Algorithm %1 not found!\n" ).arg( id ).toLocal8Bit().constData();
return 1;
}

if ( alg->flags() & QgsProcessingAlgorithm::FlagNotAvailableInStandaloneTool )
{
std::cerr << QStringLiteral( "The \"%1\" algorithm is not available for use outside of the QGIS desktop application\n" ).arg( id ).toLocal8Bit().constData();
return 1;
}
}

std::cout << "\n----------------\n";

0 comments on commit 937a41a

Please sign in to comment.
You can’t perform that action at this time.