Skip to content
Permalink
Browse files

Use flags for parameter type extra info

  • Loading branch information
m-kuhn authored and nyalldawson committed Mar 6, 2018
1 parent e3dabac commit c3a843619f3e46af272335d93e6f9d74c10a737b
@@ -23,6 +23,14 @@ Makes metadata of processing parameters available.
%End
public:

enum ParameterFlag
{
ExposeToModeler
};
typedef QFlags<QgsProcessingParameterType::ParameterFlag> ParameterFlags;



virtual QgsProcessingParameterDefinition *create( const QString &name ) const = 0 /Factory/;
%Docstring
Creates a new parameter of this type.
@@ -48,7 +56,7 @@ This will be used in comboboxes and list widgets.
A static id for this type which will be used for storing this parameter type.
%End

virtual bool exposeToModeler() const;
virtual ParameterFlags flags() const;
%Docstring
Determines if this parameter is available in the modeler.
The default implementation returns true.
@@ -620,14 +620,12 @@ def _filterItem(self, item, text):
return False

def fillInputsTree(self):
from processing.core.Processing import Processing

icon = QIcon(os.path.join(pluginPath, 'images', 'input.svg'))
parametersItem = QTreeWidgetItem()
parametersItem.setText(0, self.tr('Parameters'))
sortedParams = sorted(QgsApplication.instance().processingRegistry().parameterTypes(), key=lambda pt: pt.name())
for param in sortedParams:
if param.exposeToModeller():
if param.flags() & QgsProcessingParameterType.ExposeToModeler:
paramItem = QTreeWidgetItem()
paramItem.setText(0, param.name())
paramItem.setData(0, Qt.UserRole, param.id())
@@ -17,9 +17,9 @@

#include "qgsprocessingparametertype.h"

bool QgsProcessingParameterType::exposeToModeler() const
QgsProcessingParameterType::ParameterFlags QgsProcessingParameterType::flags() const
{
return true;
return QgsProcessingParameterType::ExposeToModeler;
}

QVariantMap QgsProcessingParameterType::metadata() const
@@ -34,6 +34,17 @@ class CORE_EXPORT QgsProcessingParameterType
{
public:

/**
* Each parameter type can offer a number of additional flags to finetune its behavior
* and capabilities.
*/
enum ParameterFlag
{
ExposeToModeler = 1 //!< Is this parameter available in the modeler. Is set to on by default.
};
Q_DECLARE_FLAGS( ParameterFlags, ParameterFlag )


/**
* Creates a new parameter of this type.
*/
@@ -66,7 +77,7 @@ class CORE_EXPORT QgsProcessingParameterType
* Determines if this parameter is available in the modeler.
* The default implementation returns true.
*/
virtual bool exposeToModeler() const;
virtual ParameterFlags flags() const;

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

0 comments on commit c3a8436

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