@@ -4180,13 +4180,15 @@ void TestQgsProcessing::modelerAlgorithm()
4180
4180
child.setDependencies ( QStringList () << " a" << " b" );
4181
4181
QCOMPARE ( child.dependencies (), QStringList () << " a" << " b" );
4182
4182
4183
- QMap< QString, QgsProcessingModelAlgorithm::ChildParameterSource > sources;
4184
- sources.insert ( QStringLiteral ( " a" ), QgsProcessingModelAlgorithm::ChildParameterSource::fromStaticValue ( 5 ) );
4183
+ QMap< QString, QgsProcessingModelAlgorithm::ChildParameterSources > sources;
4184
+ sources.insert ( QStringLiteral ( " a" ), QgsProcessingModelAlgorithm::ChildParameterSources () << QgsProcessingModelAlgorithm:: ChildParameterSource::fromStaticValue ( 5 ) );
4185
4185
child.setParameterSources ( sources );
4186
- QCOMPARE ( child.parameterSources ().value ( QStringLiteral ( " a" ) ).staticValue ().toInt (), 5 );
4187
- child.addParameterSource ( QStringLiteral ( " b" ), QgsProcessingModelAlgorithm::ChildParameterSource::fromStaticValue ( 7 ) );
4188
- QCOMPARE ( child.parameterSources ().value ( QStringLiteral ( " a" ) ).staticValue ().toInt (), 5 );
4189
- QCOMPARE ( child.parameterSources ().value ( QStringLiteral ( " b" ) ).staticValue ().toInt (), 7 );
4186
+ QCOMPARE ( child.parameterSources ().value ( QStringLiteral ( " a" ) ).at ( 0 ).staticValue ().toInt (), 5 );
4187
+ child.addParameterSources ( QStringLiteral ( " b" ), QgsProcessingModelAlgorithm::ChildParameterSources () << QgsProcessingModelAlgorithm::ChildParameterSource::fromStaticValue ( 7 ) << QgsProcessingModelAlgorithm::ChildParameterSource::fromStaticValue ( 9 ) );
4188
+ QCOMPARE ( child.parameterSources ().value ( QStringLiteral ( " a" ) ).at ( 0 ).staticValue ().toInt (), 5 );
4189
+ QCOMPARE ( child.parameterSources ().value ( QStringLiteral ( " b" ) ).count (), 2 );
4190
+ QCOMPARE ( child.parameterSources ().value ( QStringLiteral ( " b" ) ).at ( 0 ).staticValue ().toInt (), 7 );
4191
+ QCOMPARE ( child.parameterSources ().value ( QStringLiteral ( " b" ) ).at ( 1 ).staticValue ().toInt (), 9 );
4190
4192
4191
4193
QgsProcessingModelAlgorithm::ModelOutput testModelOut;
4192
4194
testModelOut.setChildId ( QStringLiteral ( " my_id" ) );
@@ -4358,7 +4360,7 @@ void TestQgsProcessing::modelerAlgorithm()
4358
4360
// dependency via parameter source
4359
4361
QgsProcessingModelAlgorithm::ChildAlgorithm c9;
4360
4362
c9.setChildId ( " c9" );
4361
- c9.addParameterSource ( " x" , QgsProcessingModelAlgorithm::ChildParameterSource::fromChildOutput ( " c8" , " x" ) );
4363
+ c9.addParameterSources ( " x" , QgsProcessingModelAlgorithm::ChildParameterSources () << QgsProcessingModelAlgorithm::ChildParameterSource::fromChildOutput ( " c8" , " x" ) );
4362
4364
alg3.addChildAlgorithm ( c9 );
4363
4365
QVERIFY ( alg3.dependentChildAlgorithms ( " c9" ).isEmpty () );
4364
4366
QCOMPARE ( alg3.dependentChildAlgorithms ( " c8" ).count (), 1 );
@@ -4441,10 +4443,10 @@ void TestQgsProcessing::modelerAlgorithm()
4441
4443
QgsProcessingModelAlgorithm::ModelParameter bool2;
4442
4444
alg4.addModelParameter ( new QgsProcessingParameterBoolean ( " p1" , " desc" ), bool2 );
4443
4445
QVERIFY ( !alg4.childAlgorithmsDependOnParameter ( " p1" ) );
4444
- c10.addParameterSource ( " x" , QgsProcessingModelAlgorithm::ChildParameterSource::fromModelParameter ( " p2" ) );
4446
+ c10.addParameterSources ( " x" , QgsProcessingModelAlgorithm::ChildParameterSources () << QgsProcessingModelAlgorithm::ChildParameterSource::fromModelParameter ( " p2" ) );
4445
4447
alg4.setChildAlgorithm ( c10 );
4446
4448
QVERIFY ( !alg4.childAlgorithmsDependOnParameter ( " p1" ) );
4447
- c10.addParameterSource ( " y" , QgsProcessingModelAlgorithm::ChildParameterSource::fromModelParameter ( " p1" ) );
4449
+ c10.addParameterSources ( " y" , QgsProcessingModelAlgorithm::ChildParameterSources () << QgsProcessingModelAlgorithm::ChildParameterSource::fromModelParameter ( " p1" ) );
4448
4450
alg4.setChildAlgorithm ( c10 );
4449
4451
QVERIFY ( alg4.childAlgorithmsDependOnParameter ( " p1" ) );
4450
4452
@@ -4457,9 +4459,12 @@ void TestQgsProcessing::modelerAlgorithm()
4457
4459
QgsProcessingModelAlgorithm::ChildAlgorithm alg5c1;
4458
4460
alg5c1.setChildId ( " cx1" );
4459
4461
alg5c1.setAlgorithmId ( " buffer" );
4460
- alg5c1.addParameterSource ( " x" , QgsProcessingModelAlgorithm::ChildParameterSource::fromModelParameter ( " p1" ) );
4461
- alg5c1.addParameterSource ( " y" , QgsProcessingModelAlgorithm::ChildParameterSource::fromChildOutput ( " cx2" , " out3" ) );
4462
- alg5c1.addParameterSource ( " z" , QgsProcessingModelAlgorithm::ChildParameterSource::fromStaticValue ( 5 ) );
4462
+ alg5c1.addParameterSources ( " x" , QgsProcessingModelAlgorithm::ChildParameterSources () << QgsProcessingModelAlgorithm::ChildParameterSource::fromModelParameter ( " p1" ) );
4463
+ alg5c1.addParameterSources ( " y" , QgsProcessingModelAlgorithm::ChildParameterSources () << QgsProcessingModelAlgorithm::ChildParameterSource::fromChildOutput ( " cx2" , " out3" ) );
4464
+ alg5c1.addParameterSources ( " z" , QgsProcessingModelAlgorithm::ChildParameterSources () << QgsProcessingModelAlgorithm::ChildParameterSource::fromStaticValue ( 5 ) );
4465
+ alg5c1.addParameterSources ( " zm" , QgsProcessingModelAlgorithm::ChildParameterSources () << QgsProcessingModelAlgorithm::ChildParameterSource::fromStaticValue ( 6 )
4466
+ << QgsProcessingModelAlgorithm::ChildParameterSource::fromModelParameter ( " p2" )
4467
+ << QgsProcessingModelAlgorithm::ChildParameterSource::fromChildOutput ( " cx2" , " out4" ) );
4463
4468
alg5c1.setActive ( true );
4464
4469
alg5c1.setOutputsCollapsed ( true );
4465
4470
alg5c1.setParametersCollapsed ( true );
@@ -4504,14 +4509,22 @@ void TestQgsProcessing::modelerAlgorithm()
4504
4509
QCOMPARE ( alg6c1.description (), QStringLiteral ( " child 1" ) );
4505
4510
QCOMPARE ( alg6c1.position ().x (), 1.0 );
4506
4511
QCOMPARE ( alg6c1.position ().y (), 2.0 );
4507
- QCOMPARE ( alg6c1.parameterSources ().count (), 3 );
4508
- QCOMPARE ( alg6c1.parameterSources ().value ( " x" ).source (), QgsProcessingModelAlgorithm::ChildParameterSource::ModelParameter );
4509
- QCOMPARE ( alg6c1.parameterSources ().value ( " x" ).parameterName (), QStringLiteral ( " p1" ) );
4510
- QCOMPARE ( alg6c1.parameterSources ().value ( " y" ).source (), QgsProcessingModelAlgorithm::ChildParameterSource::ChildOutput );
4511
- QCOMPARE ( alg6c1.parameterSources ().value ( " y" ).outputChildId (), QStringLiteral ( " cx2" ) );
4512
- QCOMPARE ( alg6c1.parameterSources ().value ( " y" ).outputName (), QStringLiteral ( " out3" ) );
4513
- QCOMPARE ( alg6c1.parameterSources ().value ( " z" ).source (), QgsProcessingModelAlgorithm::ChildParameterSource::StaticValue );
4514
- QCOMPARE ( alg6c1.parameterSources ().value ( " z" ).staticValue ().toInt (), 5 );
4512
+ QCOMPARE ( alg6c1.parameterSources ().count (), 4 );
4513
+ QCOMPARE ( alg6c1.parameterSources ().value ( " x" ).at ( 0 ).source (), QgsProcessingModelAlgorithm::ChildParameterSource::ModelParameter );
4514
+ QCOMPARE ( alg6c1.parameterSources ().value ( " x" ).at ( 0 ).parameterName (), QStringLiteral ( " p1" ) );
4515
+ QCOMPARE ( alg6c1.parameterSources ().value ( " y" ).at ( 0 ).source (), QgsProcessingModelAlgorithm::ChildParameterSource::ChildOutput );
4516
+ QCOMPARE ( alg6c1.parameterSources ().value ( " y" ).at ( 0 ).outputChildId (), QStringLiteral ( " cx2" ) );
4517
+ QCOMPARE ( alg6c1.parameterSources ().value ( " y" ).at ( 0 ).outputName (), QStringLiteral ( " out3" ) );
4518
+ QCOMPARE ( alg6c1.parameterSources ().value ( " z" ).at ( 0 ).source (), QgsProcessingModelAlgorithm::ChildParameterSource::StaticValue );
4519
+ QCOMPARE ( alg6c1.parameterSources ().value ( " z" ).at ( 0 ).staticValue ().toInt (), 5 );
4520
+ QCOMPARE ( alg6c1.parameterSources ().value ( " zm" ).at ( 0 ).source (), QgsProcessingModelAlgorithm::ChildParameterSource::StaticValue );
4521
+ QCOMPARE ( alg6c1.parameterSources ().value ( " zm" ).at ( 0 ).staticValue ().toInt (), 6 );
4522
+ QCOMPARE ( alg6c1.parameterSources ().value ( " zm" ).at ( 1 ).source (), QgsProcessingModelAlgorithm::ChildParameterSource::ModelParameter );
4523
+ QCOMPARE ( alg6c1.parameterSources ().value ( " zm" ).at ( 1 ).parameterName (), QStringLiteral ( " p2" ) );
4524
+ QCOMPARE ( alg6c1.parameterSources ().value ( " zm" ).at ( 2 ).source (), QgsProcessingModelAlgorithm::ChildParameterSource::ChildOutput );
4525
+ QCOMPARE ( alg6c1.parameterSources ().value ( " zm" ).at ( 2 ).outputChildId (), QStringLiteral ( " cx2" ) );
4526
+ QCOMPARE ( alg6c1.parameterSources ().value ( " zm" ).at ( 2 ).outputName (), QStringLiteral ( " out4" ) );
4527
+
4515
4528
QCOMPARE ( alg6c1.modelOutputs ().count (), 1 );
4516
4529
QCOMPARE ( alg6c1.modelOutputs ().value ( QStringLiteral ( " a" ) ).description (), QStringLiteral ( " my output" ) );
4517
4530
QCOMPARE ( alg6c1.modelOutput ( " a" ).description (), QStringLiteral ( " my output" ) );
@@ -4602,12 +4615,12 @@ void TestQgsProcessing::modelExecution()
4602
4615
QgsProcessingModelAlgorithm::ChildAlgorithm algc2;
4603
4616
algc2.setChildId ( " cx2" );
4604
4617
algc2.setAlgorithmId ( " native:centroids" );
4605
- algc2.addParameterSource ( " x" , QgsProcessingModelAlgorithm::ChildParameterSource::fromChildOutput ( " cx1" , " p1" ) );
4618
+ algc2.addParameterSources ( " x" , QgsProcessingModelAlgorithm::ChildParameterSources () << QgsProcessingModelAlgorithm::ChildParameterSource::fromChildOutput ( " cx1" , " p1" ) );
4606
4619
model1.addChildAlgorithm ( algc2 );
4607
4620
QgsProcessingModelAlgorithm::ChildAlgorithm algc3;
4608
4621
algc3.setChildId ( " cx3" );
4609
4622
algc3.setAlgorithmId ( " native:centroids" );
4610
- algc3.addParameterSource ( " x" , QgsProcessingModelAlgorithm::ChildParameterSource::fromChildOutput ( " cx1" , " p2" ) );
4623
+ algc3.addParameterSources ( " x" , QgsProcessingModelAlgorithm::ChildParameterSources () << QgsProcessingModelAlgorithm::ChildParameterSource::fromChildOutput ( " cx1" , " p2" ) );
4611
4624
algc3.setActive ( false );
4612
4625
model1.addChildAlgorithm ( algc3 );
4613
4626
@@ -4624,12 +4637,12 @@ void TestQgsProcessing::modelExecution()
4624
4637
QgsProcessingModelAlgorithm::ChildAlgorithm alg2c1;
4625
4638
alg2c1.setChildId ( " cx1" );
4626
4639
alg2c1.setAlgorithmId ( " native:buffer" );
4627
- alg2c1.addParameterSource ( " INPUT" , QgsProcessingModelAlgorithm::ChildParameterSource::fromModelParameter ( " SOURCE_LAYER" ) );
4628
- alg2c1.addParameterSource ( " DISTANCE" , QgsProcessingModelAlgorithm::ChildParameterSource::fromModelParameter ( " DIST" ) );
4629
- alg2c1.addParameterSource ( " SEGMENTS" , QgsProcessingModelAlgorithm::ChildParameterSource::fromStaticValue ( 16 ) );
4630
- alg2c1.addParameterSource ( " END_CAP_STYLE" , QgsProcessingModelAlgorithm::ChildParameterSource::fromStaticValue ( 1 ) );
4631
- alg2c1.addParameterSource ( " JOIN_STYLE" , QgsProcessingModelAlgorithm::ChildParameterSource::fromStaticValue ( 2 ) );
4632
- alg2c1.addParameterSource ( " DISSOLVE" , QgsProcessingModelAlgorithm::ChildParameterSource::fromStaticValue ( false ) );
4640
+ alg2c1.addParameterSources ( " INPUT" , QgsProcessingModelAlgorithm::ChildParameterSources () << QgsProcessingModelAlgorithm::ChildParameterSource::fromModelParameter ( " SOURCE_LAYER" ) );
4641
+ alg2c1.addParameterSources ( " DISTANCE" , QgsProcessingModelAlgorithm::ChildParameterSources () << QgsProcessingModelAlgorithm::ChildParameterSource::fromModelParameter ( " DIST" ) );
4642
+ alg2c1.addParameterSources ( " SEGMENTS" , QgsProcessingModelAlgorithm::ChildParameterSources () << QgsProcessingModelAlgorithm::ChildParameterSource::fromStaticValue ( 16 ) );
4643
+ alg2c1.addParameterSources ( " END_CAP_STYLE" , QgsProcessingModelAlgorithm::ChildParameterSources () << QgsProcessingModelAlgorithm::ChildParameterSource::fromStaticValue ( 1 ) );
4644
+ alg2c1.addParameterSources ( " JOIN_STYLE" , QgsProcessingModelAlgorithm::ChildParameterSources () << QgsProcessingModelAlgorithm::ChildParameterSource::fromStaticValue ( 2 ) );
4645
+ alg2c1.addParameterSources ( " DISSOLVE" , QgsProcessingModelAlgorithm::ChildParameterSources () << QgsProcessingModelAlgorithm::ChildParameterSource::fromStaticValue ( false ) );
4633
4646
QMap<QString, QgsProcessingModelAlgorithm::ModelOutput> outputs1;
4634
4647
QgsProcessingModelAlgorithm::ModelOutput out1 ( " MODEL_OUT_LAYER" );
4635
4648
out1.setChildOutputName ( " OUTPUT_LAYER" );
@@ -4660,7 +4673,7 @@ void TestQgsProcessing::modelExecution()
4660
4673
QgsProcessingModelAlgorithm::ChildAlgorithm alg2c2;
4661
4674
alg2c2.setChildId ( " cx2" );
4662
4675
alg2c2.setAlgorithmId ( " native:centroids" );
4663
- alg2c2.addParameterSource ( " INPUT" , QgsProcessingModelAlgorithm::ChildParameterSource::fromChildOutput ( " cx1" , " OUTPUT_LAYER" ) );
4676
+ alg2c2.addParameterSources ( " INPUT" , QgsProcessingModelAlgorithm::ChildParameterSources () << QgsProcessingModelAlgorithm::ChildParameterSource::fromChildOutput ( " cx1" , " OUTPUT_LAYER" ) );
4664
4677
model2.addChildAlgorithm ( alg2c2 );
4665
4678
params = model2.parametersForChildAlgorithm ( model2.childAlgorithm ( " cx2" ), modelInputs, childResults );
4666
4679
QCOMPARE ( params.value ( " INPUT" ).toString (), QStringLiteral ( " dest.shp" ) );
@@ -4671,8 +4684,8 @@ void TestQgsProcessing::modelExecution()
4671
4684
QgsProcessingModelAlgorithm::ChildAlgorithm alg2c3;
4672
4685
alg2c3.setChildId ( " cx3" );
4673
4686
alg2c3.setAlgorithmId ( " native:extractbyexpression" );
4674
- alg2c3.addParameterSource ( " INPUT" , QgsProcessingModelAlgorithm::ChildParameterSource::fromChildOutput ( " cx1" , " OUTPUT_LAYER" ) );
4675
- alg2c3.addParameterSource ( " EXPRESSION" , QgsProcessingModelAlgorithm::ChildParameterSource::fromStaticValue ( " true" ) );
4687
+ alg2c3.addParameterSources ( " INPUT" , QgsProcessingModelAlgorithm::ChildParameterSources () << QgsProcessingModelAlgorithm::ChildParameterSource::fromChildOutput ( " cx1" , " OUTPUT_LAYER" ) );
4688
+ alg2c3.addParameterSources ( " EXPRESSION" , QgsProcessingModelAlgorithm::ChildParameterSources () << QgsProcessingModelAlgorithm::ChildParameterSource::fromStaticValue ( " true" ) );
4676
4689
alg2c3.setDependencies ( QStringList () << " cx2" );
4677
4690
model2.addChildAlgorithm ( alg2c3 );
4678
4691
params = model2.parametersForChildAlgorithm ( model2.childAlgorithm ( " cx3" ), modelInputs, childResults );
0 commit comments