Navigation Menu

Skip to content

Commit

Permalink
Add folder output type
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Jun 22, 2017
1 parent 6be4875 commit 76a9844
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 5 deletions.
21 changes: 21 additions & 0 deletions python/core/processing/qgsprocessingoutputs.sip
Expand Up @@ -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:

Expand Down Expand Up @@ -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;
};



Expand Down
8 changes: 4 additions & 4 deletions python/plugins/processing/gui/ParametersPanel.py
Expand Up @@ -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,
Expand All @@ -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(
Expand Down Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions src/core/processing/qgsprocessingoutputs.cpp
Expand Up @@ -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 )
{
}
19 changes: 19 additions & 0 deletions src/core/processing/qgsprocessingoutputs.h
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/core/processing/qgsprocessingparameters.cpp
Expand Up @@ -2313,7 +2313,7 @@ bool QgsProcessingParameterFolderOutput::checkValueIsAcceptable( const QVariant

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

QString QgsProcessingParameterFolderOutput::defaultFileExtension() const
Expand Down

0 comments on commit 76a9844

Please sign in to comment.