Skip to content

Commit c3a8436

Browse files
m-kuhnnyalldawson
authored andcommittedMar 6, 2018
Use flags for parameter type extra info
1 parent e3dabac commit c3a8436

File tree

4 files changed

+24
-7
lines changed

4 files changed

+24
-7
lines changed
 

‎python/core/processing/qgsprocessingparametertype.sip.in

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ Makes metadata of processing parameters available.
2323
%End
2424
public:
2525

26+
enum ParameterFlag
27+
{
28+
ExposeToModeler
29+
};
30+
typedef QFlags<QgsProcessingParameterType::ParameterFlag> ParameterFlags;
31+
32+
33+
2634
virtual QgsProcessingParameterDefinition *create( const QString &name ) const = 0 /Factory/;
2735
%Docstring
2836
Creates a new parameter of this type.
@@ -48,7 +56,7 @@ This will be used in comboboxes and list widgets.
4856
A static id for this type which will be used for storing this parameter type.
4957
%End
5058

51-
virtual bool exposeToModeler() const;
59+
virtual ParameterFlags flags() const;
5260
%Docstring
5361
Determines if this parameter is available in the modeler.
5462
The default implementation returns true.

‎python/plugins/processing/modeler/ModelerDialog.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -620,14 +620,12 @@ def _filterItem(self, item, text):
620620
return False
621621

622622
def fillInputsTree(self):
623-
from processing.core.Processing import Processing
624-
625623
icon = QIcon(os.path.join(pluginPath, 'images', 'input.svg'))
626624
parametersItem = QTreeWidgetItem()
627625
parametersItem.setText(0, self.tr('Parameters'))
628626
sortedParams = sorted(QgsApplication.instance().processingRegistry().parameterTypes(), key=lambda pt: pt.name())
629627
for param in sortedParams:
630-
if param.exposeToModeller():
628+
if param.flags() & QgsProcessingParameterType.ExposeToModeler:
631629
paramItem = QTreeWidgetItem()
632630
paramItem.setText(0, param.name())
633631
paramItem.setData(0, Qt.UserRole, param.id())

‎src/core/processing/qgsprocessingparametertype.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717

1818
#include "qgsprocessingparametertype.h"
1919

20-
bool QgsProcessingParameterType::exposeToModeler() const
20+
QgsProcessingParameterType::ParameterFlags QgsProcessingParameterType::flags() const
2121
{
22-
return true;
22+
return QgsProcessingParameterType::ExposeToModeler;
2323
}
2424

2525
QVariantMap QgsProcessingParameterType::metadata() const

‎src/core/processing/qgsprocessingparametertype.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,17 @@ class CORE_EXPORT QgsProcessingParameterType
3434
{
3535
public:
3636

37+
/**
38+
* Each parameter type can offer a number of additional flags to finetune its behavior
39+
* and capabilities.
40+
*/
41+
enum ParameterFlag
42+
{
43+
ExposeToModeler = 1 //!< Is this parameter available in the modeler. Is set to on by default.
44+
};
45+
Q_DECLARE_FLAGS( ParameterFlags, ParameterFlag )
46+
47+
3748
/**
3849
* Creates a new parameter of this type.
3950
*/
@@ -66,7 +77,7 @@ class CORE_EXPORT QgsProcessingParameterType
6677
* Determines if this parameter is available in the modeler.
6778
* The default implementation returns true.
6879
*/
69-
virtual bool exposeToModeler() const;
80+
virtual ParameterFlags flags() const;
7081

7182
/**
7283
* Metadata for this parameter type. Can be used for example to define custom widgets.

0 commit comments

Comments
 (0)
Please sign in to comment.