File tree 2 files changed +15
-0
lines changed
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -95,6 +95,15 @@ const QgsProcessingAlgorithm *QgsProcessingRegistry::algorithmById( const QStrin
95
95
if ( alg->id () == id )
96
96
return alg;
97
97
}
98
+
99
+ // try mapping 'qgis' algs to 'native' algs - this allows us to freely move algorithms
100
+ // from the python 'qgis' provider to the c++ 'native' provider without breaking API
101
+ // or existing models
102
+ if ( id.startsWith ( QStringLiteral ( " qgis:" ) ) )
103
+ {
104
+ QString newId = QStringLiteral ( " native:" ) + id.mid ( 5 );
105
+ return algorithmById ( newId );
106
+ }
98
107
return nullptr ;
99
108
}
100
109
Original file line number Diff line number Diff line change @@ -848,6 +848,12 @@ void TestQgsProcessing::algorithm()
848
848
QVERIFY ( !r.algorithmById ( " p1:alg3" ) );
849
849
QVERIFY ( !r.algorithmById ( " px:alg1" ) );
850
850
851
+ // test that algorithmById can transparently map 'qgis' algorithms across to matching 'native' algorithms
852
+ // this allows us the freedom to convert qgis python algs to c++ without breaking api or existing models
853
+ QCOMPARE ( QgsApplication::processingRegistry ()->algorithmById ( QStringLiteral ( " qgis:dissolve" ) )->id (), QStringLiteral ( " native:dissolve" ) );
854
+ QCOMPARE ( QgsApplication::processingRegistry ()->algorithmById ( QStringLiteral ( " qgis:clip" ) )->id (), QStringLiteral ( " native:clip" ) );
855
+ QVERIFY ( !QgsApplication::processingRegistry ()->algorithmById ( QStringLiteral ( " qgis:notanalg" ) ) );
856
+
851
857
// createAlgorithmById
852
858
QVERIFY ( !r.createAlgorithmById ( " p1:alg3" ) );
853
859
std::unique_ptr< QgsProcessingAlgorithm > creation ( r.createAlgorithmById ( " p1:alg1" ) );
You can’t perform that action at this time.
0 commit comments