Workflows: Order config box fields like the task inputs

Config fields were sorted alphabetically, which made their connections
cross. They now follow the order of the task's input ports.
This commit is contained in:
Kristian Bendiksen committed 2026-10-21 11:20:03 +02:00
1 parent 61c2db898f
commit 29fe3f3022
1 file changed
+11 -1
@@ -1097,7 +1097,6 @@ void RiuWorkflowGraphView::showGraph( const QJsonObject& graph, const QString& e
if ( !fieldName.isEmpty() ) configured.append( "field:" + fieldName );
}
configured.removeDuplicates();
configured.sort();
configFields.insert( name, configured );
}
for ( const QJsonValue& value : edges )
@@ -1144,6 +1143,17 @@ void RiuWorkflowGraphView::showGraph( const QJsonObject& graph, const QString& e
outputs = portInfos( out, true, data.value( "output_types" ).toObject(), data.value( "output_icons" ).toObject() );
}
// Config fields follow the order of the task's inputs, so their connections do not cross
QStringList& configured = configFields[name];
auto inputIndex = [&inputs]( const QString& key )
{
const auto it = std::find_if( inputs.begin(), inputs.end(), [&key]( const PortInfo& port ) { return port.key == key; } );
return std::distance( inputs.begin(), it );
};
std::stable_sort( configured.begin(),
configured.end(),
[&inputIndex]( const QString& a, const QString& b ) { return inputIndex( a ) < inputIndex( b ); } );
const QJsonObject map = data.value( "map" ).toObject();
QString subtitle;
if ( !map.isEmpty() ) subtitle = QString::fromUtf8( "⟳ map over %1" ).arg( map.value( "over" ).toString() );