Replace %sequ_10 before %sequ_1 in label formulas

AssignVariables::assignSequence() replaced the sequential-number
placeholders from 1 upwards with a plain QString::replace(). "%sequ_1"
is also the start of "%sequ_10", so with ten or more sequences a
formula's %sequ_10 became the first value followed by a "0". The same
held for every family (%sequf_, %seqt_, %seqtf_, %seqh_, %seqhf_,
%seqw_, %seqa_).

Run the loop from the highest number down to 1, so the longer
placeholder is gone before the shorter one is looked for.

No file-format change. Labels with fewer than ten sequences come out
exactly as before.

Tests: tst_tensequentialnumbers runs the binary's --export-bom on a
fixture whose element has the formula %sequ_10-%sequ_1 and the unit
values A to J, and expects the label "J-A". On master the label is
"A0-A".

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Signed-off-by: Beat Hangartner <beat@hangartners.ch>
This commit is contained in:
Beat Hangartner
2026-10-07 21:10:23 +02:00
parent ef795a21e5
commit fc39acaf75
4 changed files with 452 additions and 1 deletions
+4 -1
View File
@@ -482,7 +482,10 @@ namespace autonum
m_seq_struct.wrap.size()))
);
for (int i=1; i<=max ; i++)
// Highest number first: "%sequ_1" is also the start of
// "%sequ_10", so replacing 1 before 10 would turn %sequ_10
// into the first value followed by a "0".
for (int i=max; i>=1 ; i--)
{
if (m_assigned_label.contains("%sequ_" + QString::number(i)) && m_seq_struct.unit.size() >= i) {
m_assigned_label.replace("%sequ_" + QString::number(i),m_seq_struct.unit.at(i-1));