Skip to content
Permalink
Browse files

Rename "output" style parameters for clarity

The previous naming was too easily confused with processing outputs.
Rename them to QgsProcessingParameterFileDestination, etc... to
make it clearer what they are used for.
  • Loading branch information
nyalldawson committed Jul 8, 2017
1 parent f82b41e commit 9d04f87249c06022989cbc689dc35a6c3acb054c
@@ -181,14 +181,14 @@ class QgsProcessingParameterDefinition
sipType = sipType_QgsProcessingParameterFeatureSource;
else if ( sipCpp->type() == QgsProcessingParameterFeatureSink::typeName() )
sipType = sipType_QgsProcessingParameterFeatureSink;
else if ( sipCpp->type() == QgsProcessingParameterVectorOutput::typeName() )
sipType = sipType_QgsProcessingParameterVectorOutput;
else if ( sipCpp->type() == QgsProcessingParameterRasterOutput::typeName() )
sipType = sipType_QgsProcessingParameterRasterOutput;
else if ( sipCpp->type() == QgsProcessingParameterFileOutput::typeName() )
sipType = sipType_QgsProcessingParameterFileOutput;
else if ( sipCpp->type() == QgsProcessingParameterFolderOutput::typeName() )
sipType = sipType_QgsProcessingParameterFolderOutput;
else if ( sipCpp->type() == QgsProcessingParameterVectorDestination::typeName() )
sipType = sipType_QgsProcessingParameterVectorDestination;
else if ( sipCpp->type() == QgsProcessingParameterRasterDestination::typeName() )
sipType = sipType_QgsProcessingParameterRasterDestination;
else if ( sipCpp->type() == QgsProcessingParameterFileDestination::typeName() )
sipType = sipType_QgsProcessingParameterFileDestination;
else if ( sipCpp->type() == QgsProcessingParameterFolderDestination::typeName() )
sipType = sipType_QgsProcessingParameterFolderDestination;
%End
public:

@@ -1712,10 +1712,15 @@ class QgsProcessingParameterFeatureSink : QgsProcessingDestinationParameter
};


class QgsProcessingParameterVectorOutput : QgsProcessingDestinationParameter
class QgsProcessingParameterVectorDestination : QgsProcessingDestinationParameter
{
%Docstring
A vector layer output parameter. Consider using the more flexible QgsProcessingParameterFeatureSink wherever
A vector layer destination parameter, for specifying the destination path for a vector layer
created by the algorithm.

.. note::

Consider using the more flexible QgsProcessingParameterFeatureSink wherever
possible.
.. versionadded:: 3.0
%End
@@ -1725,10 +1730,10 @@ class QgsProcessingParameterVectorOutput : QgsProcessingDestinationParameter
%End
public:

QgsProcessingParameterVectorOutput( const QString &name, const QString &description = QString(), QgsProcessing::LayerType type = QgsProcessing::TypeVectorAny, const QVariant &defaultValue = QVariant(),
bool optional = false );
QgsProcessingParameterVectorDestination( const QString &name, const QString &description = QString(), QgsProcessing::LayerType type = QgsProcessing::TypeVectorAny, const QVariant &defaultValue = QVariant(),
bool optional = false );
%Docstring
Constructor for QgsProcessingParameterVectorOutput.
Constructor for QgsProcessingParameterVectorDestination.
%End

static QString typeName();
@@ -1750,21 +1755,21 @@ class QgsProcessingParameterVectorOutput : QgsProcessingDestinationParameter

QgsProcessing::LayerType dataType() const;
%Docstring
Returns the layer type for layers associated with the parameter.
Returns the layer type for this created vector layer.
.. seealso:: setDataType()
:rtype: QgsProcessing.LayerType
%End

bool hasGeometry() const;
%Docstring
Returns true if the layer is likely to include geometries. In cases were presence of geometry
Returns true if the created layer is likely to include geometries. In cases were presence of geometry
cannot be reliably determined in advance, this method will default to returning true.
:rtype: bool
%End

void setDataType( QgsProcessing::LayerType type );
%Docstring
Sets the layer ``type`` for the layers associated with the parameter.
Sets the layer ``type`` for the created vector layer.
.. seealso:: dataType()
%End

@@ -1773,19 +1778,20 @@ class QgsProcessingParameterVectorOutput : QgsProcessingDestinationParameter
virtual bool fromVariantMap( const QVariantMap &map );


static QgsProcessingParameterVectorOutput *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
static QgsProcessingParameterVectorDestination *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterVectorOutput
:rtype: QgsProcessingParameterVectorDestination
%End


};

class QgsProcessingParameterRasterOutput : QgsProcessingDestinationParameter
class QgsProcessingParameterRasterDestination : QgsProcessingDestinationParameter
{
%Docstring
A raster layer output parameter.
A raster layer destination parameter, for specifying the destination path for a raster layer
created by the algorithm.
.. versionadded:: 3.0
%End

@@ -1794,11 +1800,11 @@ class QgsProcessingParameterRasterOutput : QgsProcessingDestinationParameter
%End
public:

QgsProcessingParameterRasterOutput( const QString &name, const QString &description = QString(),
const QVariant &defaultValue = QVariant(),
bool optional = false );
QgsProcessingParameterRasterDestination( const QString &name, const QString &description = QString(),
const QVariant &defaultValue = QVariant(),
bool optional = false );
%Docstring
Constructor for QgsProcessingParameterRasterOutput.
Constructor for QgsProcessingParameterRasterDestination.
%End

static QString typeName();
@@ -1816,17 +1822,18 @@ class QgsProcessingParameterRasterOutput : QgsProcessingDestinationParameter
virtual QString defaultFileExtension() const;


static QgsProcessingParameterRasterOutput *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
static QgsProcessingParameterRasterDestination *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterRasterOutput
:rtype: QgsProcessingParameterRasterDestination
%End
};

class QgsProcessingParameterFileOutput : QgsProcessingDestinationParameter
class QgsProcessingParameterFileDestination : QgsProcessingDestinationParameter
{
%Docstring
A generic file based output parameter.
A generic file based destination parameter, for specifying the destination path for a file (non-map layer)
created by the algorithm.
.. versionadded:: 3.0
%End

@@ -1835,12 +1842,12 @@ class QgsProcessingParameterFileOutput : QgsProcessingDestinationParameter
%End
public:

QgsProcessingParameterFileOutput( const QString &name, const QString &description = QString(),
const QString &fileFilter = QString(),
const QVariant &defaultValue = QVariant(),
bool optional = false );
QgsProcessingParameterFileDestination( const QString &name, const QString &description = QString(),
const QString &fileFilter = QString(),
const QVariant &defaultValue = QVariant(),
bool optional = false );
%Docstring
Constructor for QgsProcessingParameterFileOutput.
Constructor for QgsProcessingParameterFileDestination.
%End

static QString typeName();
@@ -1860,14 +1867,14 @@ class QgsProcessingParameterFileOutput : QgsProcessingDestinationParameter

QString fileFilter() const;
%Docstring
Returns the file filter string for files compatible with this output.
Returns the file filter string for file destinations compatible with this parameter.
.. seealso:: setFileFilter()
:rtype: str
%End

void setFileFilter( const QString &filter );
%Docstring
Sets the file ``filter`` string for files compatible with this output.
Sets the file ``filter`` string for file destinations compatible with this parameter.
.. seealso:: fileFilter()
%End

@@ -1876,18 +1883,20 @@ class QgsProcessingParameterFileOutput : QgsProcessingDestinationParameter
virtual bool fromVariantMap( const QVariantMap &map );


static QgsProcessingParameterFileOutput *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
static QgsProcessingParameterFileDestination *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterFileOutput
:rtype: QgsProcessingParameterFileDestination
%End


};

class QgsProcessingParameterFolderOutput : QgsProcessingDestinationParameter
class QgsProcessingParameterFolderDestination : QgsProcessingDestinationParameter
{
%Docstring
A folder destination parameter, for specifying the destination path for a folder created
by the algorithm or used for creating new files within the algorithm.
A folder output parameter.
.. versionadded:: 3.0
%End
@@ -1897,11 +1906,11 @@ class QgsProcessingParameterFolderOutput : QgsProcessingDestinationParameter
%End
public:

QgsProcessingParameterFolderOutput( const QString &name, const QString &description = QString(),
const QVariant &defaultValue = QVariant(),
bool optional = false );
QgsProcessingParameterFolderDestination( const QString &name, const QString &description = QString(),
const QVariant &defaultValue = QVariant(),
bool optional = false );
%Docstring
Constructor for QgsProcessingParameterFolderOutput.
Constructor for QgsProcessingParameterFolderDestination.
%End

static QString typeName();
@@ -1917,10 +1926,10 @@ class QgsProcessingParameterFolderOutput : QgsProcessingDestinationParameter
virtual QString defaultFileExtension() const;


static QgsProcessingParameterFolderOutput *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
static QgsProcessingParameterFolderDestination *fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) /Factory/;
%Docstring
Creates a new parameter using the definition from a script code.
:rtype: QgsProcessingParameterFolderOutput
:rtype: QgsProcessingParameterFolderDestination
%End

};
@@ -32,7 +32,7 @@
from qgis.analysis import QgsAspectFilter
from qgis.core import (QgsProcessingParameterRasterLayer,
QgsProcessingParameterNumber,
QgsProcessingParameterRasterOutput,
QgsProcessingParameterRasterDestination,
QgsProcessingOutputRasterLayer,
QgsFeatureSink)
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm
@@ -65,7 +65,7 @@ def __init__(self):
self.addParameter(QgsProcessingParameterNumber(self.Z_FACTOR,
self.tr('Z factor'), QgsProcessingParameterNumber.Double,
1, False, 1, 999999.99))
self.addParameter(QgsProcessingParameterRasterOutput(self.OUTPUT, self.tr('Aspect')))
self.addParameter(QgsProcessingParameterRasterDestination(self.OUTPUT, self.tr('Aspect')))
self.addOutput(QgsProcessingOutputRasterLayer(self.OUTPUT, self.tr('Aspect')))

def name(self):
@@ -34,7 +34,7 @@
QgsProcessingUtils,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterField,
QgsProcessingParameterFileOutput,
QgsProcessingParameterFileDestination,
QgsProcessingOutputHtml)
from processing.algs.qgis.QgisAlgorithm import QgisAlgorithm
from processing.tools import vector
@@ -62,7 +62,7 @@ def __init__(self):
self.tr('Value field'),
None, self.INPUT, QgsProcessingParameterField.Numeric))

self.addParameter(QgsProcessingParameterFileOutput(self.OUTPUT, self.tr('Added'), self.tr('HTML files (*.html)')))
self.addParameter(QgsProcessingParameterFileDestination(self.OUTPUT, self.tr('Added'), self.tr('HTML files (*.html)')))

self.addOutput(QgsProcessingOutputHtml(self.OUTPUT, self.tr('Bar plot')))

@@ -39,7 +39,7 @@
QgsProcessingUtils,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterField,
QgsProcessingParameterFileOutput,
QgsProcessingParameterFileDestination,
QgsProcessingOutputHtml,
QgsProcessingOutputNumber)

@@ -95,7 +95,7 @@ def __init__(self):
self.tr('Field to calculate statistics on'),
None, self.INPUT_LAYER, QgsProcessingParameterField.Any))

self.addParameter(QgsProcessingParameterFileOutput(self.OUTPUT_HTML_FILE, self.tr('Statistics'), self.tr('HTML files (*.html)'), None, True))
self.addParameter(QgsProcessingParameterFileDestination(self.OUTPUT_HTML_FILE, self.tr('Statistics'), self.tr('HTML files (*.html)'), None, True))
self.addOutput(QgsProcessingOutputHtml(self.OUTPUT_HTML_FILE, self.tr('Statistics')))

self.addOutput(QgsProcessingOutputNumber(self.COUNT, self.tr('Count')))
@@ -32,7 +32,7 @@
QgsFeatureSink,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterField,
QgsProcessingParameterFolderOutput,
QgsProcessingParameterFolderDestination,
QgsProcessingOutputFolder,
QgsExpression,
QgsFeatureRequest)
@@ -61,8 +61,8 @@ def __init__(self):
self.addParameter(QgsProcessingParameterField(self.FIELD,
self.tr('Unique ID field'), None, self.INPUT))

self.addParameter(QgsProcessingParameterFolderOutput(self.OUTPUT,
self.tr('Output directory')))
self.addParameter(QgsProcessingParameterFolderDestination(self.OUTPUT,
self.tr('Output directory')))

self.addOutput(QgsProcessingOutputFolder(self.OUTPUT, self.tr('Output directory')))

@@ -42,10 +42,10 @@
QgsProcessingOutputVectorLayer,
QgsProcessingAlgRunnerTask,
QgsProcessingOutputHtml,
QgsProcessingParameterVectorOutput,
QgsProcessingParameterVectorDestination,
QgsProcessingOutputLayerDefinition,
QgsProcessingParameterFeatureSink,
QgsProcessingParameterRasterOutput,
QgsProcessingParameterRasterDestination,
QgsProcessingAlgorithm)
from qgis.gui import QgsMessageBar
from qgis.utils import iface
@@ -119,7 +119,7 @@ def getParamValues(self):
else:
dest_project = None
if not param.flags() & QgsProcessingParameterDefinition.FlagHidden and \
isinstance(param, (QgsProcessingParameterRasterOutput, QgsProcessingParameterFeatureSink, QgsProcessingParameterVectorOutput)):
isinstance(param, (QgsProcessingParameterRasterDestination, QgsProcessingParameterFeatureSink, QgsProcessingParameterVectorDestination)):
if self.mainWidget.checkBoxes[param.name()].isChecked():
dest_project = QgsProject.instance()

@@ -34,7 +34,7 @@
from qgis.PyQt.QtCore import Qt

from qgis.core import (QgsProcessingParameterDefinition,
QgsProcessingParameterRasterOutput,
QgsProcessingParameterRasterDestination,
QgsProcessingParameterFeatureSink,
QgsProcessingOutputLayerDefinition,
QgsProcessingOutputHtml,
@@ -104,7 +104,7 @@ def accept(self):
widget = self.mainWidget.tblParameters.cellWidget(row, col)
text = widget.getValue()
if param.checkValueIsAcceptable(text, context):
if isinstance(out, (QgsProcessingParameterRasterOutput,
if isinstance(out, (QgsProcessingParameterRasterDestination,
QgsProcessingParameterFeatureSink)):
# load rasters and sinks on completion
parameters[out.name()] = QgsProcessingOutputLayerDefinition(text, context.project())
@@ -33,7 +33,7 @@

from qgis.core import (QgsMapLayer,
QgsSettings,
QgsProcessingParameterFolderOutput,
QgsProcessingParameterFolderDestination,
QgsProcessingParameterRasterLayer,
QgsProcessingParameterFeatureSource,
QgsProcessingParameterVectorLayer,
@@ -73,7 +73,7 @@ def __init__(self, output, alg, row, col, panel):
self.setLayout(self.horizontalLayout)

def showSelectionDialog(self):
if isinstance(self.output, QgsProcessingParameterFolderOutput):
if isinstance(self.output, QgsProcessingParameterFolderDestination):
self.selectDirectory()
return

@@ -41,7 +41,7 @@
QgsProcessingParameterFeatureSink,
QgsProcessingOutputLayerDefinition,
QgsProcessingParameterDefinition,
QgsProcessingParameterFolderOutput)
QgsProcessingParameterFolderDestination)
from processing.core.ProcessingConfig import ProcessingConfig
from processing.tools.dataobjects import createContext
from processing.gui.PostgisTableSelector import PostgisTableSelector
@@ -79,7 +79,7 @@ def __init__(self, parameter, alg):
and alg.provider().supportsNonFileBasedOutput():
# use memory layers for temporary files if supported
self.leText.setPlaceholderText(self.SAVE_TO_TEMP_LAYER)
elif not isinstance(self.parameter, QgsProcessingParameterFolderOutput):
elif not isinstance(self.parameter, QgsProcessingParameterFolderDestination):
self.leText.setPlaceholderText(self.SAVE_TO_TEMP_FILE)

self.btnSelect.clicked.connect(self.selectOutput)
@@ -94,7 +94,7 @@ def skipOutput(self):
self.use_temporary = False

def selectOutput(self):
if isinstance(self.parameter, QgsProcessingParameterFolderOutput):
if isinstance(self.parameter, QgsProcessingParameterFolderDestination):
self.selectDirectory()
else:
popupMenu = QMenu()
@@ -275,7 +275,7 @@ def getValue(self):
if not key and self.parameter.flags() & QgsProcessingParameterDefinition.FlagOptional:
return None

if isinstance(self.parameter, QgsProcessingParameterFolderOutput):
if isinstance(self.parameter, QgsProcessingParameterFolderDestination):
return self.leText.text()

value = QgsProcessingOutputLayerDefinition(key)

0 comments on commit 9d04f87

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