Clarify split-first duration handling and test per-entry operations

This commit is contained in:
Dandaedre 2026-11-04 16:47:51 +01:00
parent 2f1aa8dd45
commit bcb0cce6be
3 changed files with 64 additions and 11 deletions

View File

@ -102,6 +102,15 @@ fn duration_handling_controls(ui: &mut egui::Ui, profile: &mut Profile, id: egui
}
ui.indent(id.with("indent"), |ui| {
ui.horizontal_wrapped(|ui| {
ui.checkbox(&mut profile.duration_split, "Split into multiple entries");
if profile.duration_split {
let separator = profile
.duration_separator
.get_or_insert_with(|| "\\n".into());
ui.label("Separator");
ui.add(egui::TextEdit::singleline(separator).desired_width(70.0))
.on_hover_text("Use \\n for a newline, \\n\\n for a blank line, \\t for a tab, or enter a literal separator.");
}
ui.weak("Duration handling");
let mut mode = profile
.duration_mode
@ -120,19 +129,11 @@ fn duration_handling_controls(ui: &mut egui::Ui, profile: &mut Profile, id: egui
}
})
.response
.on_hover_text("Choose how duration values are extracted when one cell contains several values.");
.on_hover_text("Split first, then apply this operation independently to each separated line or group. Values from different entries are never combined.");
profile.duration_mode = (mode != "strict").then_some(mode.clone());
ui.checkbox(&mut profile.duration_add_margin, "Add margin")
.on_hover_text("Keep the difference between the sum of source durations and the selected duration as a gap after the event. With splitting, apply this to each entry. Sum leaves no remainder.");
ui.checkbox(&mut profile.duration_split, "Split into multiple entries");
if profile.duration_split {
let separator = profile
.duration_separator
.get_or_insert_with(|| "\\n".into());
ui.label("Separator");
ui.add(egui::TextEdit::singleline(separator).desired_width(70.0))
.on_hover_text("Use \\n for a newline, \\n\\n for a blank line, \\t for a tab, or enter a literal separator.");
}
});
});
}

View File

@ -1564,3 +1564,52 @@ fn margin_toggle_combines_with_minimum_maximum_sum_and_split() {
}
}
}
#[test]
fn splitting_precedes_every_operation_and_export_keeps_independent_results() {
for (separator, text) in [
("\\n", "20 min + 5 min\n10 min + 2 min\n3 min"),
("|", "20 min + 5 min|10 min + 2 min|3 min"),
(
"\\n\\n",
"09:00-09:25\n20 min + 5 min\n\n09:25-09:37\n10 min + 2 min\n\n3 min",
),
] {
let t = table(&[&["Start", "Duration", "Title"], &["09:00", text, "Talks"]]);
for (mode, minutes) in [
("sum", [25, 12, 3]),
("minimum", [5, 2, 3]),
("maximum", [20, 10, 3]),
] {
for margin in [false, true] {
let p = Profile {
duration_mode: Some(mode.into()),
duration_split: true,
duration_separator: Some(separator.into()),
duration_add_margin: margin,
..Default::default()
};
let a = analyze(&t, &p);
assert!(
a.diagnostics.is_empty(),
"{mode}/{separator}: {:?}",
a.diagnostics
);
let r = a.rundown.unwrap();
assert_eq!(r.entries.len(), 3);
let json = export::ontime(&r).unwrap();
for (entry, minutes) in r.entries.iter().zip(minutes) {
assert_eq!(entry.duration_ms, minutes * 60_000);
assert_eq!(
json["rundowns"]["default"]["entries"][&entry.id]["duration"],
minutes * 60_000
);
}
if margin {
assert_eq!(r.entries[1].start_ms, 9 * 3_600_000 + 25 * 60_000);
assert_eq!(r.entries[2].start_ms, 9 * 3_600_000 + 37 * 60_000);
}
}
}
}
}

View File

@ -127,7 +127,10 @@ visually distinct from labels and ordinary actions; the active tab uses the stro
choice instead of extra column roles: whole cell, minimum, maximum or sum.
Separate **Add margin** and **Split into multiple entries** toggles can be
combined with that choice. Add margin keeps the unused duration as a gap;
splitting applies the selected handling and margin to each separated group. Selecting one duration column explicitly resolves
splitting applies the selected handling and margin to each separated group.
The order is **Split → Duration handling → Add margin**. For example,
`20 min + 5 min` and `10 min + 2 min` on separate lines produce 25-minute
and 12-minute entries with Split + Sum. Selecting one duration column explicitly resolves
duplicate TIMER headers.
**Secondary title** selects another title source with a nested handling menu:
**Either** uses the main title when present and the secondary when it is empty;