Fix #1113: custom title-block variables in Find/Replace and unset placeholders

Two problems with a custom variable newly added to a title-block template:

1. Find/Replace > Folio > Custom showed an empty table, so the user had to
   know and type each variable name. It now lists every custom variable the
   folios already carry plus those their templates use, with empty values.
   An empty value now means "leave unchanged", like every field of the main
   tab; only the variables actually filled in are written to the folios.

2. The title block showed the variable's own name ("%doc-type") until the
   folio's properties were opened, because interpreteVariables() only
   replaces names present in the context. Placeholders in the template text
   that no key resolves now render blank, as auto-added unset ones already
   did since #973. Only the template's own text is considered, so a value
   that contains "%something" is never touched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ispyisail
2026-09-29 09:59:21 +13:00
parent 56e69d5956
commit 08bce54a2f
6 changed files with 89 additions and 9 deletions
@@ -76,7 +76,20 @@ void SearchAndReplaceWorker::replaceDiagram(QList<Diagram *> diagram_list)
}
}
new_properties.context.add(m_titleblock_properties.context);
// The replace dialog lists every custom variable of the folios
// (#1113), so an empty value means "leave unchanged", exactly like
// the fields of the main tab.
const DiagramContext &change = m_titleblock_properties.context;
for (const QString &key : change.keys()) {
const QString value = change.value(key).toString();
if (value.isEmpty()) {
continue;
}
new_properties.context.addValue(
key,
applyChange(new_properties.context.value(key).toString(),
value));
}
if (old_propertie != new_properties) {
project->undoStack()->push(new ChangeTitleBlockCommand(d, old_propertie, new_properties));