|
16 | 16 | ***************************************************************************/ |
17 | 17 |
|
18 | 18 | #include "qgsprocessingparameters.h" |
| 19 | +#include "qgsprocessingprovider.h" |
19 | 20 | #include "qgsprocessingcontext.h" |
20 | 21 | #include "qgsprocessingutils.h" |
| 22 | +#include "qgsprocessingalgorithm.h" |
21 | 23 | #include "qgsvectorlayerfeatureiterator.h" |
22 | 24 | #include "qgsprocessingoutputs.h" |
23 | 25 | #include "qgssettings.h" |
@@ -1237,6 +1239,16 @@ bool QgsProcessingParameterDefinition::fromVariantMap( const QVariantMap &map ) |
1237 | 1239 | return true; |
1238 | 1240 | } |
1239 | 1241 |
|
| 1242 | +QgsProcessingAlgorithm *QgsProcessingParameterDefinition::algorithm() const |
| 1243 | +{ |
| 1244 | + return mAlgorithm; |
| 1245 | +} |
| 1246 | + |
| 1247 | +QgsProcessingProvider *QgsProcessingParameterDefinition::provider() const |
| 1248 | +{ |
| 1249 | + return mAlgorithm ? mAlgorithm->provider() : nullptr; |
| 1250 | +} |
| 1251 | + |
1240 | 1252 | QgsProcessingParameterBoolean::QgsProcessingParameterBoolean( const QString &name, const QString &description, const QVariant &defaultValue, bool optional ) |
1241 | 1253 | : QgsProcessingParameterDefinition( name, description, defaultValue, optional ) |
1242 | 1254 | {} |
@@ -3087,14 +3099,21 @@ QgsProcessingOutputDefinition *QgsProcessingParameterFeatureSink::toOutputDefini |
3087 | 3099 |
|
3088 | 3100 | QString QgsProcessingParameterFeatureSink::defaultFileExtension() const |
3089 | 3101 | { |
3090 | | - QgsSettings settings; |
3091 | | - if ( hasGeometry() ) |
| 3102 | + if ( QgsProcessingProvider *p = provider() ) |
3092 | 3103 | { |
3093 | | - return settings.value( QStringLiteral( "Processing/DefaultOutputVectorLayerExt" ), QStringLiteral( "shp" ), QgsSettings::Core ).toString(); |
| 3104 | + return p->defaultVectorFileExtension( hasGeometry() ); |
3094 | 3105 | } |
3095 | 3106 | else |
3096 | 3107 | { |
3097 | | - return QStringLiteral( "dbf" ); |
| 3108 | + QgsSettings settings; |
| 3109 | + if ( hasGeometry() ) |
| 3110 | + { |
| 3111 | + return settings.value( QStringLiteral( "Processing/DefaultOutputVectorLayerExt" ), QStringLiteral( "shp" ), QgsSettings::Core ).toString(); |
| 3112 | + } |
| 3113 | + else |
| 3114 | + { |
| 3115 | + return QStringLiteral( "dbf" ); |
| 3116 | + } |
3098 | 3117 | } |
3099 | 3118 | } |
3100 | 3119 |
|
@@ -3240,8 +3259,15 @@ QgsProcessingOutputDefinition *QgsProcessingParameterRasterDestination::toOutput |
3240 | 3259 |
|
3241 | 3260 | QString QgsProcessingParameterRasterDestination::defaultFileExtension() const |
3242 | 3261 | { |
3243 | | - QgsSettings settings; |
3244 | | - return settings.value( QStringLiteral( "Processing/DefaultOutputRasterLayerExt" ), QStringLiteral( "tif" ), QgsSettings::Core ).toString(); |
| 3262 | + if ( QgsProcessingProvider *p = provider() ) |
| 3263 | + { |
| 3264 | + return p->defaultRasterFileExtension(); |
| 3265 | + } |
| 3266 | + else |
| 3267 | + { |
| 3268 | + QgsSettings settings; |
| 3269 | + return settings.value( QStringLiteral( "Processing/DefaultOutputRasterLayerExt" ), QStringLiteral( "tif" ), QgsSettings::Core ).toString(); |
| 3270 | + } |
3245 | 3271 | } |
3246 | 3272 |
|
3247 | 3273 | QgsProcessingParameterRasterDestination *QgsProcessingParameterRasterDestination::fromScriptCode( const QString &name, const QString &description, bool isOptional, const QString &definition ) |
@@ -3536,14 +3562,21 @@ QgsProcessingOutputDefinition *QgsProcessingParameterVectorDestination::toOutput |
3536 | 3562 |
|
3537 | 3563 | QString QgsProcessingParameterVectorDestination::defaultFileExtension() const |
3538 | 3564 | { |
3539 | | - QgsSettings settings; |
3540 | | - if ( hasGeometry() ) |
| 3565 | + if ( QgsProcessingProvider *p = provider() ) |
3541 | 3566 | { |
3542 | | - return settings.value( QStringLiteral( "Processing/DefaultOutputVectorLayerExt" ), QStringLiteral( "shp" ), QgsSettings::Core ).toString(); |
| 3567 | + return p->defaultVectorFileExtension( hasGeometry() ); |
3543 | 3568 | } |
3544 | 3569 | else |
3545 | 3570 | { |
3546 | | - return QStringLiteral( "dbf" ); |
| 3571 | + QgsSettings settings; |
| 3572 | + if ( hasGeometry() ) |
| 3573 | + { |
| 3574 | + return settings.value( QStringLiteral( "Processing/DefaultOutputVectorLayerExt" ), QStringLiteral( "shp" ), QgsSettings::Core ).toString(); |
| 3575 | + } |
| 3576 | + else |
| 3577 | + { |
| 3578 | + return QStringLiteral( "dbf" ); |
| 3579 | + } |
3547 | 3580 | } |
3548 | 3581 | } |
3549 | 3582 |
|
|
0 commit comments