Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing] Default to supporting non-file based outputs for providers
And make this support opt-out, since the vast majority of providers
are based on QGIS API and don't have external dependencies which would
restrict use of memory layers/etc.

Plus, I'd rather see non-compliant providers expose this support when
they can't use non-file-based-outputs (and make this the bug which
needs fixing) then have to rely on plugin providers to discover and
explicitly expose this support.
  • Loading branch information
nyalldawson committed Jan 29, 2018
1 parent cc9f7af commit 0f963df
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
4 changes: 4 additions & 0 deletions python/core/processing/qgsprocessingprovider.sip.in
Expand Up @@ -148,6 +148,10 @@ indicates that none of the outputs from any of the provider's algorithms have
support for non-file based outputs. Returning true indicates that the algorithm's
parameters will each individually declare their non-file based support.

The default behavior for providers is to support non-file based outputs, and most
providers which rely solely on QGIS API (and which do not depend on third-party scripts
or external dependencies) will automatically support this.

.. seealso:: :py:func:`supportedOutputVectorLayerExtensions`
%End

Expand Down
6 changes: 6 additions & 0 deletions python/plugins/processing/algs/gdal/GdalAlgorithmProvider.py
Expand Up @@ -199,6 +199,12 @@ def loadAlgorithms(self):
def supportedOutputRasterLayerExtensions(self):
return GdalUtils.getSupportedRasterExtensions()

def supportsNonFileBasedOutput(self):
"""
GDAL Provider doesn't support non file based outputs
"""
return False

def tr(self, string, context=''):
if context == '':
context = 'GdalAlgorithmProvider'
Expand Down
6 changes: 6 additions & 0 deletions python/plugins/processing/algs/saga/SagaAlgorithmProvider.py
Expand Up @@ -127,6 +127,12 @@ def defaultRasterFileExtension(self):
def supportedOutputTableExtensions(self):
return ['dbf']

def supportsNonFileBasedOutput(self):
"""
SAGA Provider doesn't support non file based outputs
"""
return False

def icon(self):
return QIcon(os.path.join(pluginPath, 'images', 'saga.png'))

Expand Down
5 changes: 5 additions & 0 deletions src/core/processing/qgsprocessingprovider.cpp
Expand Up @@ -140,3 +140,8 @@ QString QgsProcessingProvider::defaultRasterFileExtension() const
return defaultExtension;
}
}

bool QgsProcessingProvider::supportsNonFileBasedOutput() const
{
return true;
}
7 changes: 6 additions & 1 deletion src/core/processing/qgsprocessingprovider.h
Expand Up @@ -150,9 +150,14 @@ class CORE_EXPORT QgsProcessingProvider : public QObject
* indicates that none of the outputs from any of the provider's algorithms have
* support for non-file based outputs. Returning true indicates that the algorithm's
* parameters will each individually declare their non-file based support.
*
* The default behavior for providers is to support non-file based outputs, and most
* providers which rely solely on QGIS API (and which do not depend on third-party scripts
* or external dependencies) will automatically support this.
*
* \see supportedOutputVectorLayerExtensions()
*/
virtual bool supportsNonFileBasedOutput() const { return false; }
virtual bool supportsNonFileBasedOutput() const;

/**
* Loads the provider. This will be called when the plugin is being loaded, and any general
Expand Down

0 comments on commit 0f963df

Please sign in to comment.