Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new string concatenation algorithm in processing
- Loading branch information
1 parent
89a31e5
commit 386eef2
Showing
5 changed files
with
132 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
src/analysis/processing/qgsalgorithmstringconcatenation.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/*************************************************************************** | ||
qgsalgorithmstringconcatenation.cpp | ||
--------------------- | ||
begin : October 2017 | ||
copyright : (C) 2017 by Etienne Trimaille | ||
email : etienne at kartoza dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#include "qgsalgorithmstringconcatenation.h" | ||
|
||
///@cond PRIVATE | ||
|
||
QString QgsStringConcatenationAlgorithm::name() const | ||
{ | ||
return QStringLiteral( "stringconcatenation" ); | ||
} | ||
|
||
QgsProcessingAlgorithm::Flags QgsStringConcatenationAlgorithm::flags() const | ||
{ | ||
return FlagHideFromToolbox; | ||
} | ||
|
||
QString QgsStringConcatenationAlgorithm::displayName() const | ||
{ | ||
return QObject::tr( "String concatenation" ); | ||
} | ||
|
||
QStringList QgsStringConcatenationAlgorithm::tags() const | ||
{ | ||
return QObject::tr( "string,concatenation,merge" ).split( ',' ); | ||
} | ||
|
||
QString QgsStringConcatenationAlgorithm::group() const | ||
{ | ||
return QObject::tr( "Modeler tool" ); | ||
} | ||
|
||
QString QgsStringConcatenationAlgorithm::shortHelpString() const | ||
{ | ||
return QObject::tr( "This algorithm concatenates two strings together." ); | ||
} | ||
|
||
QgsStringConcatenationAlgorithm *QgsStringConcatenationAlgorithm::createInstance() const | ||
{ | ||
return new QgsStringConcatenationAlgorithm(); | ||
} | ||
|
||
void QgsStringConcatenationAlgorithm::initAlgorithm( const QVariantMap & ) | ||
{ | ||
addParameter( new QgsProcessingParameterString( QStringLiteral( "INPUT_1" ), QObject::tr( "Input 1" ), QVariant(), false, false ) ); | ||
addParameter( new QgsProcessingParameterString( QStringLiteral( "INPUT_2" ), QObject::tr( "Input 2" ), QVariant(), false, false ) ); | ||
addOutput( new QgsProcessingOutputString( QStringLiteral( "CONCATENATION" ), QObject::tr( "Concatenation" ) ) ); | ||
} | ||
|
||
QVariantMap QgsStringConcatenationAlgorithm::processAlgorithm( const QVariantMap ¶meters, QgsProcessingContext &context, QgsProcessingFeedback * ) | ||
{ | ||
QString input_1 = parameterAsString( parameters, QStringLiteral( "INPUT_1" ), context ); | ||
QString input_2 = parameterAsString( parameters, QStringLiteral( "INPUT_2" ), context ); | ||
|
||
QVariantMap outputs; | ||
outputs.insert( QStringLiteral( "CONCATENATION" ), input_1 + input_2 ); | ||
return outputs; | ||
} | ||
|
||
///@endcond |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/*************************************************************************** | ||
qgsalgorithmstringconcatenation.h | ||
--------------------- | ||
begin : October 2017 | ||
copyright : (C) 2017 by Etienne Trimaille | ||
email : etienne at kartoza dot com | ||
***************************************************************************/ | ||
|
||
/*************************************************************************** | ||
* * | ||
* This program is free software; you can redistribute it and/or modify * | ||
* it under the terms of the GNU General Public License as published by * | ||
* the Free Software Foundation; either version 2 of the License, or * | ||
* (at your option) any later version. * | ||
* * | ||
***************************************************************************/ | ||
|
||
#ifndef QGSALGORITHMSTRINGCONCATENATION_H | ||
#define QGSALGORITHMSTRINGCONCATENATION_H | ||
|
||
#define SIP_NO_FILE | ||
|
||
#include "qgis.h" | ||
#include "qgsprocessingalgorithm.h" | ||
|
||
///@cond PRIVATE | ||
|
||
/** | ||
* Native string concatenation algorithm. | ||
*/ | ||
class QgsStringConcatenationAlgorithm : public QgsProcessingAlgorithm | ||
{ | ||
public: | ||
QgsStringConcatenationAlgorithm() = default; | ||
void initAlgorithm( const QVariantMap &configuration = QVariantMap() ) override; | ||
Flags flags() const override; | ||
QString name() const override; | ||
QString displayName() const override; | ||
virtual QStringList tags() const override; | ||
QString group() const override; | ||
QString shortHelpString() const override; | ||
QgsStringConcatenationAlgorithm *createInstance() const override SIP_FACTORY; | ||
|
||
protected: | ||
|
||
virtual QVariantMap processAlgorithm( const QVariantMap ¶meters, | ||
QgsProcessingContext &context, QgsProcessingFeedback * ) override; | ||
|
||
}; | ||
|
||
///@endcond PRIVATE | ||
|
||
#endif // QGSALGORITHMSTRINGCONCATENATION_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters