From: QElectroTech Date: Fri, 23 May 2026 Subject: crossrefitem: fix power contact terminal pairing in Contacts mode Remove alphanumeric sort of terminal names for power contacts in drawContact(). The sort was breaking consecutive-pair grouping: e.g. [L1,L2,L3,T1,T2,T3] was sorted then paired as L1/L2, L3/T1, T2/T3 instead of the correct L1/T1, L2/T2, L3/T3. Terminal names are now used in declaration order from the element editor. Users must declare pairs consecutively: 1,2,3,4,5,6 -> pole 0=1/2, pole 1=3/4, pole 2=5/6 L1,T1,L2,T2,L3,T3 -> pole 0=L1/T1, pole 1=L2/T2, pole 2=L3/T3 --- sources/ui/crossrefitem.cpp | 16 +------- 1 file changed, 2 insertions(+), 14 deletions(-) --- a/sources/ui/crossrefitem.cpp +++ b/sources/ui/crossrefitem.cpp @@ -750,24 +750,10 @@ QRectF CrossRefItem::drawContact(QPainter &painter, int flags, Element *elmt, in } if (is_power_ctc) { - // Sort terminals alphanumerically so names like "R1","R2"... or "1","2"... - // are ordered correctly. Extract trailing digits for numeric comparison; - // fall back to full string comparison when no digits are found. - std::sort(terminal_names.begin(), terminal_names.end(), - [](const QString &a, const QString &b){ - // Extract trailing numeric part - int i_a = a.size(); - while (i_a > 0 && a[i_a-1].isDigit()) --i_a; - int i_b = b.size(); - while (i_b > 0 && b[i_b-1].isDigit()) --i_b; - bool a_ok = false, b_ok = false; - int ai = a.mid(i_a).toInt(&a_ok); - int bi = b.mid(i_b).toInt(&b_ok); - if (a_ok && b_ok && a.left(i_a) == b.left(i_b)) - return ai < bi; - return a < b; - }); - // Pick the pair for this pole: pole 0 -> [0,1], pole 1 -> [2,3], etc. + // No sorting: terminals are used in declaration order from the element editor. + // Users must declare terminals as consecutive pairs: [in1, out1, in2, out2, ...] + // e.g. 1,2,3,4,5,6 -> pole 0=1/2, pole 1=3/4, pole 2=5/6 + // e.g. L1,T1,L2,T2,L3,T3 -> pole 0=L1/T1, pole 1=L2/T2, pole 2=L3/T3 int idx = pole_index * 2; if (idx + 1 < terminal_names.size()) terminal_names = QStringList() << terminal_names[idx] << terminal_names[idx+1];