Merge pull request #1525 from DaTweety/feature/report-folio-title

Reports: %T for the target folio's title, element info in composite texts
This commit is contained in:
ispyisail
2026-10-19 14:46:10 +13:00
committed by GitHub
7 changed files with 124 additions and 2 deletions
+9
View File
@@ -17,6 +17,8 @@
*/
#include "assignvariables.h"
#include <QRegularExpression>
#include "../diagram.h"
#include "../diagramposition.h"
#include "../qetapp.h"
@@ -229,6 +231,7 @@ namespace autonum
FormulaContext context;
const BorderTitleBlock &border = diagram->border_and_titleblock;
context.folio = border.folio();
context.folio_title = border.title();
context.folio_index = diagram->folioIndex();
context.folio_total = border.folioTotal();
context.plant = border.plant();
@@ -435,6 +438,12 @@ namespace autonum
assignTitleBlockVar();
assignProjectVar();
assignSequence();
//The folio title last: it is free text, and a title such as
//"Schema %c" must stay as typed, not have the variables in it
//replaced. %T on its own only, not the start of a longer word.
static const QRegularExpression folio_title(QStringLiteral("%T(?![A-Za-z0-9_])"));
m_assigned_label.replace(folio_title, m_context.folio_title);
}
void AssignVariables::assignTitleBlockVar()
+2
View File
@@ -69,6 +69,8 @@ namespace autonum
{
/// border_and_titleblock.folio(), folioIndex(), folioTotal()...
QString folio;
/// the folio's title, %T
QString folio_title;
int folio_index = 0;
int folio_total = 0;
QString plant;
@@ -1143,7 +1143,12 @@ void DynamicElementTextItem::elementInfoChanged()
if (m_composite_text.contains("%{label}"))
setupFormulaConnection();
final_text = autonum::AssignVariables::replaceVariable(m_composite_text, dc);
//A report's %{label} is where its partner is, not its own
//label: the same text updateReportText() builds
if (m_parent_element && (m_parent_element.data()->linkType() & Element::AllReport))
final_text = reportReplacedCompositeText();
else
final_text = autonum::AssignVariables::replaceVariable(m_composite_text, dc);
}
else if (m_text_from == UserText)
final_text = m_text;
@@ -1261,6 +1266,8 @@ void DynamicElementTextItem::setConnectionForReportFormula(const QString &formul
connect(other_diagram->project(), &QETProject::projectDiagramsOrderChanged, this, &DynamicElementTextItem::updateReportText);
connect(other_diagram->project(), &QETProject::diagramRemoved, this, &DynamicElementTextItem::updateReportText);
}
if (other_diagram && string.contains("%T"))
connect(&other_diagram->border_and_titleblock, &BorderTitleBlock::informationChanged, this, &DynamicElementTextItem::updateReportText);
if (string.contains("%l"))
connect(other_elmt, &Element::yChanged, this, &DynamicElementTextItem::updateReportText);
if (string.contains("%c"))
@@ -1286,6 +1293,8 @@ void DynamicElementTextItem::removeConnectionForReportFormula(const QString &for
if (other_diagram && (string.contains("%f") || string.contains("%id")))
disconnect(other_diagram->project(), &QETProject::projectDiagramsOrderChanged, this, &DynamicElementTextItem::updateReportText);
if (other_diagram && string.contains("%T"))
disconnect(&other_diagram->border_and_titleblock, &BorderTitleBlock::informationChanged, this, &DynamicElementTextItem::updateReportText);
if (string.contains("%l"))
disconnect(other_element, &Element::yChanged, this, &DynamicElementTextItem::updateReportText);
if (string.contains("%c"))
@@ -1580,6 +1589,13 @@ QString DynamicElementTextItem::reportReplacedCompositeText() const
if(string.contains("%{conductor_section}"))
string.replace("%{conductor_section}", "");
}
//What is left is the report's own information, as in the
//composite text of any other element: a report can then say
//which device and terminal it leads to (%{comment}), the way
//EPLAN prints "-XS27:N 2 UG Raum - 1.1"
string = autonum::AssignVariables::replaceVariable(
string, m_parent_element.data()->elementInformations());
}
return string;
+1
View File
@@ -38,6 +38,7 @@ Create your own text using the following variables:
%F: the sheet number
%M: the installation
%LM: the location
%T: the sheet title
%l: the row number
%c: the column number</string>
</property>
+2 -1
View File
@@ -285,7 +285,8 @@
%l: the row number
%c: the column number
%M: the installation
%LM: the location</string>
%LM: the location
%T: the sheet title</string>
</property>
</widget>
</item>