Skip to content

Commit

Permalink
Hide unsupported parameters in modeller
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Mar 1, 2018
1 parent a0cda52 commit 0c73059
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
5 changes: 3 additions & 2 deletions python/plugins/processing/core/Processing.py
Expand Up @@ -114,7 +114,7 @@ def deinitialize():
Processing.REGISTERED_PARAMETERS = dict()

@staticmethod
def registerParameter(id, name, parameter, metadata=dict(), description=None):
def registerParameter(id, name, parameter, metadata=dict(), description=None, exposeToModeller=True):
"""Register a new parameter.
The ``name`` is a human readable translated string, the ``parameter`` is a class type with the base class ``qgis.core.QgsProcessingParameterDefinition``,
the ``metadata`` is a dictionary with additional metadata, mainly used for widget wrappers.
Expand All @@ -123,7 +123,8 @@ def registerParameter(id, name, parameter, metadata=dict(), description=None):
'name': name,
'parameter': parameter,
'metadata': metadata,
'description': description
'description': description,
'exposeToModeller': exposeToModeller
}

@staticmethod
Expand Down
10 changes: 5 additions & 5 deletions python/plugins/processing/core/parameters.py
Expand Up @@ -262,18 +262,18 @@ def initializeParameters():
Processing.registerParameter(PARAMETER_RANGE, QCoreApplication.translate('Processing', 'Range'), QgsProcessingParameterRange)
Processing.registerParameter(PARAMETER_POINT, QCoreApplication.translate('Processing', 'Point'), QgsProcessingParameterPoint,
description=QCoreApplication.translate('Processing', 'A geographic point parameter.'))
Processing.registerParameter(PARAMETER_ENUM, QCoreApplication.translate('Processing', 'Enum'), QgsProcessingParameterEnum)
Processing.registerParameter(PARAMETER_ENUM, QCoreApplication.translate('Processing', 'Enum'), QgsProcessingParameterEnum, exposeToModeller=False)
Processing.registerParameter(PARAMETER_EXTENT, QCoreApplication.translate('Processing', 'Extent'), QgsProcessingParameterExtent,
description=QCoreApplication.translate('Processing', 'A map extent parameter.'))
Processing.registerParameter(PARAMETER_MATRIX, QCoreApplication.translate('Processing', 'Matrix'), QgsProcessingParameterMatrix)
Processing.registerParameter(PARAMETER_FILE, QCoreApplication.translate('Processing', 'File'), QgsProcessingParameterFile,
description=QCoreApplication.translate('Processing', 'A file parameter, for use with non-map layer file sources.'))
Processing.registerParameter(PARAMETER_TABLE_FIELD, QCoreApplication.translate('Processing', 'Field'), QgsProcessingParameterField,
description=QCoreApplication.translate('Processing', 'A vector field parameter, for selecting an existing field from a vector source.'))
Processing.registerParameter(PARAMETER_VECTOR_DESTINATION, QCoreApplication.translate('Processing', 'Vector Destination'), QgsProcessingParameterVectorDestination)
Processing.registerParameter(PARAMETER_FILE_DESTINATION, QCoreApplication.translate('Processing', 'File Destination'), QgsProcessingParameterFileDestination)
Processing.registerParameter(PARAMETER_FOLDER_DESTINATION, QCoreApplication.translate('Processing', 'Folder Destination'), QgsProcessingParameterFolderDestination)
Processing.registerParameter(PARAMETER_RASTER_DESTINATION, QCoreApplication.translate('Processing', 'Raster Destination'), QgsProcessingParameterRasterDestination)
Processing.registerParameter(PARAMETER_VECTOR_DESTINATION, QCoreApplication.translate('Processing', 'Vector Destination'), QgsProcessingParameterVectorDestination, exposeToModeller=False)
Processing.registerParameter(PARAMETER_FILE_DESTINATION, QCoreApplication.translate('Processing', 'File Destination'), QgsProcessingParameterFileDestination, exposeToModeller=False)
Processing.registerParameter(PARAMETER_FOLDER_DESTINATION, QCoreApplication.translate('Processing', 'Folder Destination'), QgsProcessingParameterFolderDestination, exposeToModeller=False)
Processing.registerParameter(PARAMETER_RASTER_DESTINATION, QCoreApplication.translate('Processing', 'Raster Destination'), QgsProcessingParameterRasterDestination, exposeToModeller=False)
Processing.registerParameter(PARAMETER_STRING, QCoreApplication.translate('Processing', 'String'), QgsProcessingParameterString,
description=QCoreApplication.translate('Processing', 'A freeform string parameter.'))
Processing.registerParameter(PARAMETER_MULTIPLE, QCoreApplication.translate('Processing', 'Multiple Layers'), QgsProcessingParameterMultipleLayers,
Expand Down
15 changes: 8 additions & 7 deletions python/plugins/processing/modeler/ModelerDialog.py
Expand Up @@ -628,13 +628,14 @@ def fillInputsTree(self):
parametersItem.setText(0, self.tr('Parameters'))
sortedParams = sorted(Processing.registeredParameters().items())
for param in sortedParams:
paramItem = QTreeWidgetItem()
paramItem.setText(0, param[1]['name'])
paramItem.setData(0, Qt.UserRole, param[0])
paramItem.setIcon(0, icon)
paramItem.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsDragEnabled)
paramItem.setToolTip(0, param[1]['description'])
parametersItem.addChild(paramItem)
if param[1]['exposeToModeller']:
paramItem = QTreeWidgetItem()
paramItem.setText(0, param[1]['name'])
paramItem.setData(0, Qt.UserRole, param[0])
paramItem.setIcon(0, icon)
paramItem.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable | Qt.ItemIsDragEnabled)
paramItem.setToolTip(0, param[1]['description'])
parametersItem.addChild(paramItem)
self.inputsTree.addTopLevelItem(parametersItem)
parametersItem.setExpanded(True)

Expand Down

0 comments on commit 0c73059

Please sign in to comment.