mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-06-11 13:43:13 +02:00
7d718bb9a0
The previous sort used QString::toInt() to order terminal names, which returns 0 for any string containing a non-numeric prefix (e.g. "R1", "R2", "L1", "L2"...). This caused undefined sort order and incorrect pole pairing in the Xref contact mirror. Example: a 4-pole NC power contact with terminals R1..R8 was displaying R1/R3, R5/R7, R2/R4, R6/R8 instead of the correct R1/R2, R3/R4, R5/R6, R7/R8. Fix: extract the trailing numeric part of each terminal name and compare prefixes separately. If both names share the same prefix and both have a trailing number, sort numerically on that number; otherwise fall back to full string comparison. This covers all naming conventions: "1"/"2"/"3", "R1"/"R2"/"R3", "L1"/"L2"/"L3", etc. Applied in both drawContact() and setUpCrossBoundingRect().