Skip to content
Permalink
Browse files

Add folder output type

  • Loading branch information
nyalldawson committed Jun 22, 2017
1 parent 6be4875 commit 76a98449494750ff61535b3ea23c07c280a06127
@@ -38,6 +38,8 @@ class QgsProcessingOutputDefinition
sipType = sipType_QgsProcessingOutputNumber;
else if ( sipCpp->type() == "outputString" )
sipType = sipType_QgsProcessingOutputString;
else if ( sipCpp->type() == "outputFolder" )
sipType = sipType_QgsProcessingOutputFolder;
%End
public:

@@ -206,6 +208,25 @@ class QgsProcessingOutputString : QgsProcessingOutputDefinition
virtual QString type() const;
};

class QgsProcessingOutputFolder : QgsProcessingOutputDefinition
{
%Docstring
A folder output for processing algorithms.
.. versionadded:: 3.0
%End

%TypeHeaderCode
#include "qgsprocessingoutputs.h"
%End
public:

QgsProcessingOutputFolder( const QString &name, const QString &description = QString() );
%Docstring
Constructor for QgsProcessingOutputFolder.
%End

virtual QString type() const;
};



@@ -38,7 +38,8 @@
QgsProcessingOutputVectorLayer,
QgsProcessingOutputRasterLayer,
QgsProcessingParameterRasterOutput,
QgsProcessingParameterFeatureSink)
QgsProcessingParameterFeatureSink,
QgsProcessingParameterVectorOutput)
from qgis.PyQt import uic
from qgis.PyQt.QtCore import QCoreApplication
from qgis.PyQt.QtWidgets import (QWidget, QHBoxLayout, QToolButton,
@@ -47,8 +48,7 @@

from processing.gui.DestinationSelectionPanel import DestinationSelectionPanel
from processing.gui.wrappers import WidgetWrapperFactory
from processing.core.parameters import ParameterVector, ParameterExtent, ParameterPoint
from processing.core.outputs import OutputTable


pluginPath = os.path.split(os.path.dirname(__file__))[0]
WIDGET, BASE = uic.loadUiType(
@@ -157,7 +157,7 @@ def initWidgets(self):
widget = DestinationSelectionPanel(output, self.alg)
self.layoutMain.insertWidget(self.layoutMain.count() - 1, label)
self.layoutMain.insertWidget(self.layoutMain.count() - 1, widget)
if isinstance(output, (QgsProcessingParameterRasterOutput, QgsProcessingParameterFeatureSink, OutputTable)):
if isinstance(output, (QgsProcessingParameterRasterOutput, QgsProcessingParameterFeatureSink, QgsProcessingParameterVectorOutput)):
check = QCheckBox()
check.setText(self.tr('Open output file after running algorithm'))
check.setChecked(True)
@@ -54,3 +54,8 @@ QgsProcessingOutputNumber::QgsProcessingOutputNumber( const QString &name, const
QgsProcessingOutputString::QgsProcessingOutputString( const QString &name, const QString &description )
: QgsProcessingOutputDefinition( name, description )
{}

QgsProcessingOutputFolder::QgsProcessingOutputFolder( const QString &name, const QString &description )
: QgsProcessingOutputDefinition( name, description )
{
}
@@ -53,6 +53,8 @@ class CORE_EXPORT QgsProcessingOutputDefinition
sipType = sipType_QgsProcessingOutputNumber;
else if ( sipCpp->type() == "outputString" )
sipType = sipType_QgsProcessingOutputString;
else if ( sipCpp->type() == "outputFolder" )
sipType = sipType_QgsProcessingOutputFolder;
SIP_END
#endif

@@ -217,6 +219,23 @@ class CORE_EXPORT QgsProcessingOutputString : public QgsProcessingOutputDefiniti
QString type() const override { return QStringLiteral( "outputString" ); }
};

/**
* \class QgsProcessingOutputFolder
* \ingroup core
* A folder output for processing algorithms.
* \since QGIS 3.0
*/
class CORE_EXPORT QgsProcessingOutputFolder : public QgsProcessingOutputDefinition
{
public:

/**
* Constructor for QgsProcessingOutputFolder.
*/
QgsProcessingOutputFolder( const QString &name, const QString &description = QString() );

QString type() const override { return QStringLiteral( "outputFolder" ); }
};

#endif // QGSPROCESSINGOUTPUTS_H

@@ -2313,7 +2313,7 @@ bool QgsProcessingParameterFolderOutput::checkValueIsAcceptable( const QVariant

QgsProcessingOutputDefinition *QgsProcessingParameterFolderOutput::toOutputDefinition() const
{
return nullptr;
return new QgsProcessingOutputFolder( name(), description() );
}

QString QgsProcessingParameterFolderOutput::defaultFileExtension() const

0 comments on commit 76a9844

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