Let a Cyclique (modulo) part actually be displayed: %seqw_N

Reported by @scorpio810 on #632 with a screenshot: a "Chiffre 1" followed by
a "Cyclique (modulo) 8" numbers elements 0..7 and then jumps straight to 9,
never showing 8, and never producing the 0-7 / 10-17 / 20-27 pattern the
feature exists for.

The cause is that the wrap-and-carry feature shipped without its rendering
half. Commit 68c2603 added the arithmetic and the editor UI across seven
files, none of them assignvariables.*, so there is no %seqw_ variable, no
wrap list in sequentialNumbers, no branch in setSequential(), and no branch
in numerotationContextToFormula(). A cyclic part therefore contributes
nothing to the generated formula and cannot be referenced from one -- it is
invisible.

Invisible but not inert: it still advances and still carries. So the digit
in front of it receives +1 from the carry on top of its own increment, and
the only digit the label does show jumps by two. That is the missing 8.

Add the missing half:
  - sequentialNumbers gains a wrap list, handled in the copy constructor,
    assignment, comparison, clear(), toXml() and fromXml();
  - setSequential() collects wrap parts when the label uses %seqw_;
  - assignSequence() substitutes %seqw_N and counts wrap in its bound, so a
    context whose only counter is cyclic still resolves;
  - numerotationContextToFormula() emits %seqw_N, so adding a Cyclique part
    in the editor now puts a token in the formula instead of nothing.

Old projects are unaffected: <wrap> is simply absent from files written
before this, which fromXml() reads as an empty list, and such files have no
cyclic parts to reference in the first place. An older QET reading a newer
file ignores the unknown child.

Measured on the exact configuration from the report, unit + wrap(mod 8):

  formula generated   %sequ_1%seqw_1   (was %sequ_1 -- wrap contributed none)

  carry digit increment 1   00 11 22 33 44 55 66 77 90 101 112 ...
  carry digit increment 0   00 01 02 03 04 05 06 07 10 11 ... 17 20 21

The second line is the requested pattern. The first shows what is left once
the rendering is fixed but the carry digit still increments itself as well
as receiving the carry -- worth a UI decision, noted on the PR.
This commit is contained in:
ispyisail
2026-08-02 18:46:28 +12:00
parent 66eaf13022
commit 6f7e537db3
2 changed files with 30 additions and 1 deletions
+28 -1
View File
@@ -39,6 +39,7 @@ namespace autonum
sequentialNumbers::sequentialNumbers(const sequentialNumbers &other)
{
unit = other.unit;
wrap = other.wrap;
unit_folio = other.unit_folio;
ten = other.ten;
ten_folio = other.ten_folio;
@@ -57,6 +58,7 @@ namespace autonum
return (*this);
unit = other.unit;
wrap = other.wrap;
unit_folio = other.unit_folio;
ten = other.ten;
ten_folio = other.ten_folio;
@@ -70,6 +72,7 @@ namespace autonum
bool sequentialNumbers::operator==(const sequentialNumbers &other) const
{
if (unit == other.unit && \
wrap == other.wrap && \
unit_folio == other.unit_folio && \
ten == other.ten && \
ten_folio == other.ten_folio && \
@@ -107,6 +110,11 @@ namespace autonum
document,
"unit",
unit.join(";")));
if (!wrap.isEmpty())
element.appendChild(QETXML::textToDomElement(
document,
"wrap",
wrap.join(";")));
if (!unit_folio.isEmpty())
element.appendChild(QETXML::textToDomElement(
document,
@@ -156,6 +164,11 @@ namespace autonum
from = element.firstChildElement("unit");
unit = from.text().split(";");
//Absent from files written before cyclic parts could be
//rendered; an empty list is the correct reading of that.
from = element.firstChildElement("wrap");
wrap = from.text().split(";");
from = element.firstChildElement("unitFolio");
unit_folio = from.text().split(";");
@@ -179,6 +192,7 @@ namespace autonum
void sequentialNumbers::clear()
{
unit.clear();
wrap.clear();
unit_folio.clear();
ten.clear();
ten_folio.clear();
@@ -434,7 +448,8 @@ namespace autonum
qMax(
qMax(m_seq_struct.hundred.size(),
m_seq_struct.ten.size()),
m_seq_struct.alpha.size())
qMax(m_seq_struct.alpha.size(),
m_seq_struct.wrap.size()))
);
for (int i=1; i<=max ; i++)
@@ -442,6 +457,9 @@ namespace autonum
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));
}
if (m_assigned_label.contains("%seqw_" + QString::number(i)) && m_seq_struct.wrap.size() >= i) {
m_assigned_label.replace("%seqw_" + QString::number(i),m_seq_struct.wrap.at(i-1));
}
if (m_assigned_label.contains("%seqt_" + QString::number(i)) && m_seq_struct.ten.size() >= i) {
m_assigned_label.replace("%seqt_" + QString::number(i),m_seq_struct.ten.at(i-1));
}
@@ -553,6 +571,10 @@ namespace autonum
{
autonum::setSequentialToList(seqStruct.unit, context,"unit");
}
if (label.contains("%seqw_"))
{
autonum::setSequentialToList(seqStruct.wrap, context,"wrap");
}
if (label.contains("%sequf_"))
{
autonum::setSequentialToList(seqStruct.unit_folio, context,"unitfolio");
@@ -594,6 +616,7 @@ namespace autonum
QString value;
QString formula;
int count_unit = 0;
int count_wrap = 0;
int count_unitf = 0;
int count_ten = 0;
int count_tenf = 0;
@@ -636,6 +659,10 @@ namespace autonum
count_unit++;
formula.append("%sequ_" + QString::number(count_unit));
}
else if (type == "wrap") {
count_wrap++;
formula.append("%seqw_" + QString::number(count_wrap));
}
else if (type == "unitfolio") {
count_unitf++;
formula.append("%sequf_" + QString::number(count_unitf));
+2
View File
@@ -47,6 +47,8 @@ namespace autonum
void clear();
QStringList unit;
/// Values of the cyclic (modulo) parts, referenced by %seqw_N.
QStringList wrap;
QStringList unit_folio;
QStringList ten;
QStringList ten_folio;