From 29fe3f30228c5b3d9b5e40daccc9089352798423 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Sat, 3 Oct 2026 10:08:00 +0200 Subject: [PATCH] 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. --- .../UserInterface/RiuWorkflowGraphView.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ApplicationLibCode/UserInterface/RiuWorkflowGraphView.cpp b/ApplicationLibCode/UserInterface/RiuWorkflowGraphView.cpp index c826f1ffd7..8650a06167 100644 --- a/ApplicationLibCode/UserInterface/RiuWorkflowGraphView.cpp +++ b/ApplicationLibCode/UserInterface/RiuWorkflowGraphView.cpp @@ -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() );