QGIS API Documentation 4.3.0-Master (729d6602d19)
Loading...
Searching...
No Matches
qgsprocessingparameterinterpolationsource.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsprocessingparameterinterpolationsource.cpp
3 ---------------------
4 Date : August 2026
5 Copyright : (C) 2026 by Nyall Dawson
6 Email : nyall dot dawson at gmail dot com
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
17
19
20#include <QString>
21
22using namespace Qt::StringLiterals;
23
24
28
33
35{
36 return typeName();
37}
38
40{
41 switch ( outputType )
42 {
44 {
45 QString code = u"QgsProcessingParameterInterpolationSource('%1', %2)"_s.arg( name(), QgsProcessingUtils::stringToPythonLiteral( description() ) );
46 return code;
47 }
48 }
49 return QString();
50}
51
53{
54 if ( !input.isValid() && !mDefault.isValid() )
56
57 const QString stringValue = input.toString();
58 if ( stringValue.isEmpty() || ( !input.isValid() && mDefault.userType() == QMetaType::Type::QString && mDefault.toString().isEmpty() ) )
60
61 const QStringList layerRows = stringValue.split( "::|::"_L1 );
62 for ( const QString &row : layerRows )
63 {
64 if ( row.trimmed().isEmpty() )
65 return false;
66
67 const QStringList tokens = row.split( "::~::"_L1 );
68 if ( tokens.count() < 4 )
69 {
70 return false;
71 }
72 }
73
74 return true;
75}
@ Optional
Parameter is optional.
Definition qgis.h:3984
Contains information about the context in which a processing algorithm is executed.
Qgis::ProcessingParameterFlags mFlags
Parameter flags.
QString description() const
Returns the description for the parameter.
QgsProcessingParameterDefinition(const QString &name, const QString &description=QString(), const QVariant &defaultValue=QVariant(), bool optional=false, const QString &help=QString())
Constructor for QgsProcessingParameterDefinition.
QString name() const
Returns the name of the parameter.
QVariant mDefault
Default value for parameter.
static QString typeName()
Returns the type name for the parameter class.
bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const override
Checks whether the specified input value is acceptable for the parameter.
QgsProcessingParameterInterpolationSource(const QString &name, const QString &description=QString())
Constructor for QgsProcessingParameterInterpolationSource.
QString type() const override
Unique parameter type name.
QgsProcessingParameterInterpolationSource * clone() const override
Creates a clone of the parameter definition.
QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonOutputType::PythonQgsProcessingAlgorithmSubclass) const override
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
static QString stringToPythonLiteral(const QString &string)
Converts a string to a Python string literal.
PythonOutputType
Available Python output types.
@ PythonQgsProcessingAlgorithmSubclass
Full Python QgsProcessingAlgorithm subclass.