mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-25 00:58:06 -05:00
Use flags for parameter type extra info
This commit is contained in:
parent
e3dabac78a
commit
c3a843619f
@ -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 @@ class ModelerDialog(BASE, WIDGET):
|
||||
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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user