QGIS API Documentation  3.4.15-Madeira (e83d02e274)
qgsalgorithmstringconcatenation.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsalgorithmstringconcatenation.cpp
3  ---------------------
4  begin : October 2017
5  copyright : (C) 2017 by Etienne Trimaille
6  email : etienne at kartoza dot com
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
19 
21 
22 QString QgsStringConcatenationAlgorithm::name() const
23 {
24  return QStringLiteral( "stringconcatenation" );
25 }
26 
27 QgsProcessingAlgorithm::Flags QgsStringConcatenationAlgorithm::flags() const
28 {
29  return FlagHideFromToolbox;
30 }
31 
32 QString QgsStringConcatenationAlgorithm::displayName() const
33 {
34  return QObject::tr( "String concatenation" );
35 }
36 
37 QStringList QgsStringConcatenationAlgorithm::tags() const
38 {
39  return QObject::tr( "string,concatenation,merge" ).split( ',' );
40 }
41 
42 QString QgsStringConcatenationAlgorithm::group() const
43 {
44  return QObject::tr( "Modeler tools" );
45 }
46 
47 QString QgsStringConcatenationAlgorithm::groupId() const
48 {
49  return QStringLiteral( "modelertools" );
50 }
51 
52 QString QgsStringConcatenationAlgorithm::shortHelpString() const
53 {
54  return QObject::tr( "This algorithm concatenates two strings together." );
55 }
56 
57 QgsStringConcatenationAlgorithm *QgsStringConcatenationAlgorithm::createInstance() const
58 {
59  return new QgsStringConcatenationAlgorithm();
60 }
61 
62 void QgsStringConcatenationAlgorithm::initAlgorithm( const QVariantMap & )
63 {
64  addParameter( new QgsProcessingParameterString( QStringLiteral( "INPUT_1" ), QObject::tr( "Input 1" ), QVariant(), false, false ) );
65  addParameter( new QgsProcessingParameterString( QStringLiteral( "INPUT_2" ), QObject::tr( "Input 2" ), QVariant(), false, false ) );
66  addOutput( new QgsProcessingOutputString( QStringLiteral( "CONCATENATION" ), QObject::tr( "Concatenation" ) ) );
67 }
68 
69 QVariantMap QgsStringConcatenationAlgorithm::processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback * )
70 {
71  QString input_1 = parameterAsString( parameters, QStringLiteral( "INPUT_1" ), context );
72  QString input_2 = parameterAsString( parameters, QStringLiteral( "INPUT_2" ), context );
73 
74  QVariantMap outputs;
75  outputs.insert( QStringLiteral( "CONCATENATION" ), input_1 + input_2 );
76  return outputs;
77 }
78 
Base class for providing feedback from a processing algorithm.
A string output for processing algorithms.
Contains information about the context in which a processing algorithm is executed.
A string parameter for processing algorithms.