diff --git a/sources/autoNum/assignvariables.cpp b/sources/autoNum/assignvariables.cpp index 6161fb4fd..6eed17367 100644 --- a/sources/autoNum/assignvariables.cpp +++ b/sources/autoNum/assignvariables.cpp @@ -414,9 +414,6 @@ namespace autonum QString::number(m_context.folio_total)); m_assigned_label.replace("%M", m_context.plant); m_assigned_label.replace("%LM", m_context.locmach); - //%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); QSettings settings; if (m_context.has_element) @@ -441,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() diff --git a/tests/qttest/tst_reportfoliotitle.cpp b/tests/qttest/tst_reportfoliotitle.cpp index 1e0945e2f..24bd9f4f9 100644 --- a/tests/qttest/tst_reportfoliotitle.cpp +++ b/tests/qttest/tst_reportfoliotitle.cpp @@ -24,7 +24,8 @@ %T in a folio report or cross reference formula is the title of the folio the reference points to, so a reference can read like the ones EPLAN prints: "+UV1/1 Versorgung UG/EG.0". %total and the title block - and project variables (lower case only) keep their own values. + and project variables (lower case only) keep their own values, and the + title itself is free text: variables in it stay as typed. */ class tst_reportfoliotitle : public QObject { @@ -62,6 +63,15 @@ private slots: QCOMPARE(result, QStringLiteral("Versorgung UG/EG / 23 / SH363N / SH363N")); } + void titleKeepsTheVariablesItContains() + { + autonum::FormulaContext c = context(); + c.folio_title = QStringLiteral("Schema %c %F %total %{typ}"); + c.title_block_fields.addValue(QStringLiteral("typ"), QStringLiteral("SH363N")); + const QString result = label(QStringLiteral("%F %T"), c); + QCOMPARE(result, QStringLiteral("1 Schema %c %F %total %{typ}")); + } + void emptyTitleLeavesNothing() { autonum::FormulaContext c = context();