File tree 3 files changed +64
-1
lines changed
3 files changed +64
-1
lines changed Original file line number Diff line number Diff line change @@ -26,8 +26,28 @@ class QgsProcessingContext
26
26
%End
27
27
public:
28
28
29
+ enum Flag
30
+ {
31
+ UseSelection,
32
+ };
33
+ typedef QFlags<QgsProcessingContext::Flag> Flags;
34
+
35
+
29
36
QgsProcessingContext();
30
37
38
+ QgsProcessingContext::Flags flags() const;
39
+ %Docstring
40
+ Returns any flags set in the context.
41
+ \see setFlags()
42
+ :rtype: QgsProcessingContext.Flags
43
+ %End
44
+
45
+ void setFlags( const QgsProcessingContext::Flags &flags );
46
+ %Docstring
47
+ Sets ``flags`` for the context.
48
+ \see flags()
49
+ %End
50
+
31
51
QgsProject *project() const;
32
52
%Docstring
33
53
Returns the project in which the algorithm is being executed.
@@ -58,11 +78,19 @@ class QgsProcessingContext
58
78
59
79
60
80
81
+
82
+
83
+ QFlags<QgsProcessingContext::Flag> operator|(QgsProcessingContext::Flag f1, QFlags<QgsProcessingContext::Flag> f2);
84
+
85
+
86
+
87
+
88
+
89
+
61
90
/************************************************************************
62
91
* This file has been generated automatically from *
63
92
* *
64
93
* src/core/processing/qgsprocessingcontext.h *
65
94
* *
66
95
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
67
96
************************************************************************/
68
-
Original file line number Diff line number Diff line change 41
41
from processing .core .Processing import Processing
42
42
from processing .core .parameters import ParameterSelection
43
43
from processing .gui .Postprocessing import handleAlgorithmResults
44
+ from processing .core .ProcessingConfig import ProcessingConfig
44
45
45
46
46
47
def algorithmOptions (id ):
@@ -102,4 +103,9 @@ def createContext():
102
103
"""
103
104
context = QgsProcessingContext ()
104
105
context .setProject (QgsProject .instance ())
106
+
107
+ use_selection = ProcessingConfig .getSetting (ProcessingConfig .USE_SELECTED )
108
+ if use_selection :
109
+ context .setFlags (QgsProcessingContext .UseSelection )
110
+
105
111
return context
Original file line number Diff line number Diff line change @@ -37,8 +37,27 @@ class CORE_EXPORT QgsProcessingContext
37
37
{
38
38
public:
39
39
40
+ // ! Flags that affect how processing algorithms are run
41
+ enum Flag
42
+ {
43
+ UseSelection = 1 << 0 , // !< Filter to selected features when running algorithms
44
+ };
45
+ Q_DECLARE_FLAGS ( Flags, Flag )
46
+
40
47
QgsProcessingContext () = default ;
41
48
49
+ /* *
50
+ * Returns any flags set in the context.
51
+ * \see setFlags()
52
+ */
53
+ QgsProcessingContext::Flags flags () const { return mFlags ; }
54
+
55
+ /* *
56
+ * Sets \a flags for the context.
57
+ * \see flags()
58
+ */
59
+ void setFlags ( const QgsProcessingContext::Flags &flags ) { mFlags = flags; }
60
+
42
61
/* *
43
62
* Returns the project in which the algorithm is being executed.
44
63
* \see setProject()
@@ -63,12 +82,22 @@ class CORE_EXPORT QgsProcessingContext
63
82
64
83
private:
65
84
85
+ QgsProcessingContext::Flags mFlags = 0 ;
86
+
66
87
QPointer< QgsProject > mProject ;
67
88
68
89
QgsExpressionContext mExpressionContext ;
69
90
70
91
};
71
92
93
+
94
+
95
+
96
+
97
+
98
+
99
+ Q_DECLARE_OPERATORS_FOR_FLAGS ( QgsProcessingContext::Flags )
100
+
72
101
#endif // QGSPROCESSINGPARAMETERS_H
73
102
74
103
You can’t perform that action at this time.
0 commit comments