mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-03 09:14:12 +02:00
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:
@@ -30,6 +30,7 @@
|
||||
#include "../../qeticons.h"
|
||||
#include "../../qetinformation.h"
|
||||
#include "../../qetproject.h"
|
||||
#include "../../ui/titleblockpropertieswidget.h"
|
||||
#include "replaceadvanceddialog.h"
|
||||
#include "replaceconductordialog.h"
|
||||
#include "replaceelementdialog.h"
|
||||
@@ -1109,7 +1110,26 @@ void SearchAndReplaceWidget::on_m_previous_pb_clicked()
|
||||
void SearchAndReplaceWidget::on_m_folio_pb_clicked()
|
||||
{
|
||||
ReplaceFolioDialog *dialog = new ReplaceFolioDialog(this);
|
||||
dialog->setTitleBlockProperties(m_worker.m_titleblock_properties);
|
||||
|
||||
// List the custom variables the folios already use, so the user only
|
||||
// has to type a value instead of guessing each name (#1113).
|
||||
TitleBlockProperties properties = m_worker.m_titleblock_properties;
|
||||
for (const QPointer<Diagram> &diagram : std::as_const(m_diagram_hash))
|
||||
{
|
||||
if (!diagram) {
|
||||
continue;
|
||||
}
|
||||
for (const QString &key :
|
||||
diagram->border_and_titleblock.exportTitleBlock().context.keys()) {
|
||||
if (!properties.context.contains(key)) {
|
||||
properties.context.addValue(key, QString());
|
||||
}
|
||||
}
|
||||
TitleBlockPropertiesWidget::addTemplateVariables(
|
||||
properties.context,
|
||||
diagram->border_and_titleblock.titleBlockTemplate());
|
||||
}
|
||||
dialog->setTitleBlockProperties(properties);
|
||||
|
||||
int result = dialog->exec();
|
||||
if (result == QDialogButtonBox::AcceptRole)
|
||||
|
||||
Reference in New Issue
Block a user