QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgsprocessingparameterfieldmap.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsprocessingparameterfieldmap.h
3  -------------------------
4  begin : June 2020
5  copyright : (C) 2020 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 
16 #ifndef QGSPROCESSINGPARAMETERFIELDMAP_H
17 #define QGSPROCESSINGPARAMETERFIELDMAP_H
18 
21 
32 {
33  public:
35  QgsProcessingParameterFieldMapping( const QString &name, const QString &description = QString(), const QString &parentLayerParameterName = QString(), bool optional = false );
36 
37  QgsProcessingParameterDefinition *clone() const override;
38  QString type() const override;
39  bool checkValueIsAcceptable( const QVariant &input, QgsProcessingContext *context = nullptr ) const override;
40  QString valueAsPythonString( const QVariant &value, QgsProcessingContext &context ) const override;
42  QVariantMap toVariantMap() const override;
43  bool fromVariantMap( const QVariantMap &map ) override;
44  QStringList dependsOnOtherParameters() const override;
45 
47  static QString typeName() { return QStringLiteral( "fields_mapping" ); }
48 
53  QString parentLayerParameterName() const;
54 
59  void setParentLayerParameterName( const QString &name );
60 
61  private:
62  QString mParentLayerParameterName;
63 
64 };
65 
67 
75 class CORE_EXPORT QgsProcessingParameterTypeFieldMapping : public QgsProcessingParameterType
76 {
77  public:
78  QgsProcessingParameterDefinition *create( const QString &name ) const override SIP_FACTORY
79  {
80  return new QgsProcessingParameterFieldMapping( name );
81  }
82 
83  QString description() const override
84  {
85  return QCoreApplication::translate( "Processing", "A mapping of field names to field type definitions and expressions. Used for the refactor fields algorithm." );
86  }
87 
88  QString name() const override
89  {
90  return QCoreApplication::translate( "Processing", "Fields Mapper" );
91  }
92 
93  QString id() const override
94  {
96  }
97 
98  QString pythonImportString() const override
99  {
100  return QStringLiteral( "from qgis.core import QgsProcessingParameterFieldMapping" );
101  }
102 
103  QString className() const override
104  {
105  return QStringLiteral( "QgsProcessingParameterFieldMapping" );
106  }
107 
108  QStringList acceptedPythonTypes() const override
109  {
110  return QStringList() << QObject::tr( "list[dict]: list of field definitions as dictionaries" );
111  }
112 };
113 
115 
116 #endif // QGSPROCESSINGPARAMETERFIELDMAP_H
QgsProcessingParameterType::create
virtual QgsProcessingParameterDefinition * create(const QString &name) const =0
Creates a new parameter of this type.
qgsprocessingparametertype.h
QgsProcessingParameterDefinition::toVariantMap
virtual QVariantMap toVariantMap() const
Saves this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:2176
QgsProcessingParameterDefinition::valueAsPythonString
virtual QString valueAsPythonString(const QVariant &value, QgsProcessingContext &context) const
Returns a string version of the parameter input value, which is suitable for use as an input paramete...
Definition: qgsprocessingparameters.cpp:2131
QgsProcessingParameterType::description
virtual QString description() const =0
A human readable and translatable description for this parameter type.
QgsProcessingParameterType::name
virtual QString name() const =0
A human readable and translatable short name for this parameter type.
QgsProcessingParameterDefinition
Definition: qgsprocessingparameters.h:330
QgsProcessingParameterType
Makes metadata of processing parameters available.
Definition: qgsprocessingparametertype.h:33
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsProcessing::PythonQgsProcessingAlgorithmSubclass
@ PythonQgsProcessingAlgorithmSubclass
Full Python QgsProcessingAlgorithm subclass.
Definition: qgsprocessing.h:60
QgsProcessingParameterDefinition::fromVariantMap
virtual bool fromVariantMap(const QVariantMap &map)
Restores this parameter to a QVariantMap.
Definition: qgsprocessingparameters.cpp:2188
QgsProcessingContext
Definition: qgsprocessingcontext.h:43
QgsProcessingParameterType::id
virtual QString id() const =0
A static id for this type which will be used for storing this parameter type.
typeName
const QString & typeName
Definition: qgswfsgetfeature.cpp:109
QgsProcessingParameterFieldMapping
Definition: qgsprocessingparameterfieldmap.h:31
qgsprocessingparameters.h
QgsProcessingParameterType::className
virtual QString className() const
Returns the corresponding class name for the parameter type.
Definition: qgsprocessingparametertype.h:103
QgsProcessingParameterFieldMapping::typeName
static QString typeName()
Returns the type name for the parameter class.
Definition: qgsprocessingparameterfieldmap.h:60
QgsProcessingParameterType::pythonImportString
virtual QString pythonImportString() const
Returns a valid Python import string for importing the corresponding parameter type,...
Definition: qgsprocessingparametertype.h:93
QgsProcessingParameterDefinition::asPythonString
virtual QString asPythonString(QgsProcessing::PythonOutputType outputType=QgsProcessing::PythonQgsProcessingAlgorithmSubclass) const
Returns the parameter definition as a Python command which can be used within a Python Processing scr...
Definition: qgsprocessingparameters.cpp:2152
QgsProcessingParameterDefinition::clone
virtual QgsProcessingParameterDefinition * clone() const =0
Creates a clone of the parameter definition.
QgsProcessingParameterDefinition::type
virtual QString type() const =0
Unique parameter type name.
QgsProcessing::PythonOutputType
PythonOutputType
Available Python output types.
Definition: qgsprocessing.h:58
QgsProcessingParameterType::acceptedPythonTypes
virtual QStringList acceptedPythonTypes() const
Returns a list of the Python data types accepted as values for the parameter.
Definition: qgsprocessingparametertype.cpp:30
QgsProcessingParameterDefinition::dependsOnOtherParameters
virtual QStringList dependsOnOtherParameters() const
Returns a list of other parameter names on which this parameter is dependent (e.g.
Definition: qgsprocessingparameters.h:576
QgsProcessingParameterDefinition::checkValueIsAcceptable
virtual bool checkValueIsAcceptable(const QVariant &input, QgsProcessingContext *context=nullptr) const
Checks whether the specified input value is acceptable for the parameter.
Definition: qgsprocessingparameters.cpp:2119