mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Add folder output type
This commit is contained in:
parent
6be4875a82
commit
76a9844949
@ -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 @@ from qgis.core import (QgsProcessingParameterDefinition,
|
||||
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 qgis.PyQt.QtGui import QIcon
|
||||
|
||||
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 @@ class ParametersPanel(BASE, WIDGET):
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user