mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-23 00:02:38 -05:00
Add UseSelection flag to QgsProcessingContext
Indicates whether only selected features should be used in algorithms
This commit is contained in:
parent
dd4f530cfb
commit
06a20b935d
@ -26,8 +26,28 @@ class QgsProcessingContext
|
||||
%End
|
||||
public:
|
||||
|
||||
enum Flag
|
||||
{
|
||||
UseSelection,
|
||||
};
|
||||
typedef QFlags<QgsProcessingContext::Flag> Flags;
|
||||
|
||||
|
||||
QgsProcessingContext();
|
||||
|
||||
QgsProcessingContext::Flags flags() const;
|
||||
%Docstring
|
||||
Returns any flags set in the context.
|
||||
\see setFlags()
|
||||
:rtype: QgsProcessingContext.Flags
|
||||
%End
|
||||
|
||||
void setFlags( const QgsProcessingContext::Flags &flags );
|
||||
%Docstring
|
||||
Sets ``flags`` for the context.
|
||||
\see flags()
|
||||
%End
|
||||
|
||||
QgsProject *project() const;
|
||||
%Docstring
|
||||
Returns the project in which the algorithm is being executed.
|
||||
@ -58,6 +78,15 @@ class QgsProcessingContext
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
QFlags<QgsProcessingContext::Flag> operator|(QgsProcessingContext::Flag f1, QFlags<QgsProcessingContext::Flag> f2);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/************************************************************************
|
||||
* This file has been generated automatically from *
|
||||
* *
|
||||
@ -65,4 +94,3 @@ class QgsProcessingContext
|
||||
* *
|
||||
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
||||
************************************************************************/
|
||||
|
||||
|
@ -41,6 +41,7 @@ from qgis.core import (QgsApplication,
|
||||
from processing.core.Processing import Processing
|
||||
from processing.core.parameters import ParameterSelection
|
||||
from processing.gui.Postprocessing import handleAlgorithmResults
|
||||
from processing.core.ProcessingConfig import ProcessingConfig
|
||||
|
||||
|
||||
def algorithmOptions(id):
|
||||
@ -102,4 +103,9 @@ def createContext():
|
||||
"""
|
||||
context = QgsProcessingContext()
|
||||
context.setProject(QgsProject.instance())
|
||||
|
||||
use_selection = ProcessingConfig.getSetting(ProcessingConfig.USE_SELECTED)
|
||||
if use_selection:
|
||||
context.setFlags(QgsProcessingContext.UseSelection)
|
||||
|
||||
return context
|
||||
|
@ -37,8 +37,27 @@ class CORE_EXPORT QgsProcessingContext
|
||||
{
|
||||
public:
|
||||
|
||||
//! Flags that affect how processing algorithms are run
|
||||
enum Flag
|
||||
{
|
||||
UseSelection = 1 << 0, //!< Filter to selected features when running algorithms
|
||||
};
|
||||
Q_DECLARE_FLAGS( Flags, Flag )
|
||||
|
||||
QgsProcessingContext() = default;
|
||||
|
||||
/**
|
||||
* Returns any flags set in the context.
|
||||
* \see setFlags()
|
||||
*/
|
||||
QgsProcessingContext::Flags flags() const { return mFlags; }
|
||||
|
||||
/**
|
||||
* Sets \a flags for the context.
|
||||
* \see flags()
|
||||
*/
|
||||
void setFlags( const QgsProcessingContext::Flags &flags ) { mFlags = flags; }
|
||||
|
||||
/**
|
||||
* Returns the project in which the algorithm is being executed.
|
||||
* \see setProject()
|
||||
@ -63,12 +82,22 @@ class CORE_EXPORT QgsProcessingContext
|
||||
|
||||
private:
|
||||
|
||||
QgsProcessingContext::Flags mFlags = 0;
|
||||
|
||||
QPointer< QgsProject > mProject;
|
||||
|
||||
QgsExpressionContext mExpressionContext;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsProcessingContext::Flags )
|
||||
|
||||
#endif // QGSPROCESSINGPARAMETERS_H
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user