Merge pull request #1584 from Kellermorph/feature/terminal-label-split
Linux build and tests / Build and test (Qt 6, Debug) (push) Failing after 1m38s

Terminal labelling: option to draw label and number apart, and a Show name box for terminals
This commit is contained in:
Laurent Trinques
2026-10-23 13:41:48 +02:00
committed by GitHub
16 changed files with 1036 additions and 26 deletions
+67
View File
@@ -2316,6 +2316,39 @@ void QETProject::setUprightSymbolTexts(bool upright)
}
}
/**
@brief QETProject::terminalLabelSplit
@return whether the terminals of this project draw their label split,
the label ("X1") and the terminal number ("1") each in their own text
field, instead of the whole label ("X1:1") in one field. Off unless
the project says otherwise, so a project saved without it draws as it
always did. This is a setting of the project, not of the application:
the same file draws the same way on every machine which opens it.
@sa setTerminalLabelSplit
*/
bool QETProject::terminalLabelSplit() const {
return m_terminal_label_split;
}
/**
@brief QETProject::setTerminalLabelSplit
Set whether the terminals of this project draw their label split, and
tell the labels of the drawings already open to draw it again.
@param split
*/
void QETProject::setTerminalLabelSplit(bool split)
{
if (split == m_terminal_label_split) {
return;
}
m_terminal_label_split = split;
for (Diagram *diagram : diagrams()) {
for (Element *element : diagram->elements()) {
element->refreshLabelFields();
}
}
}
/**
@brief QETProject::wiringRules
@return how many wires a terminal of this project may take
@@ -2554,6 +2587,7 @@ QDomDocument QETProject::toXml(QHash<int, QByteArray> *kept_folios, QStringList
writeUsageXml(project_root);
writeWireHopsXml(project_root);
writeSymbolTextsXml(project_root);
writeTerminalLabelSplitXml(project_root);
writeWiringRulesXml(project_root);
// Properties for news diagrams
@@ -3525,6 +3559,7 @@ void QETProject::readProjectXml(QDomDocument &xml_project)
readUsageXml(xml_project);
readWireHopsXml(xml_project);
readSymbolTextsXml(xml_project);
readTerminalLabelSplitXml(xml_project);
readWiringRulesXml(xml_project);
//Load the default properties for the new diagrams
@@ -3889,6 +3924,21 @@ void QETProject::readSymbolTextsXml(QDomDocument &xml_project)
&& texts.attribute(QStringLiteral("upright")) == QLatin1String("true");
}
/**
@brief QETProject::readTerminalLabelSplitXml
Read the <terminal_labelling> element of the project, if any. A
project without it was saved before the setting existed, or with it
off, and draws the whole label of each terminal in one field.
@param xml_project : the xml description of the project
*/
void QETProject::readTerminalLabelSplitXml(QDomDocument &xml_project)
{
const QDomElement labelling = xml_project.documentElement()
.firstChildElement(QStringLiteral("terminal_labelling"));
m_terminal_label_split = !labelling.isNull()
&& labelling.attribute(QStringLiteral("split")) == QLatin1String("true");
}
/**
@brief QETProject::readWiringRulesXml
Read the <wiring_rules> element of the project, if any.
@@ -4213,6 +4263,23 @@ void QETProject::writeSymbolTextsXml(QDomElement &xml_element)
xml_element.appendChild(texts);
}
/**
@brief QETProject::writeTerminalLabelSplitXml
Export whether the terminals draw their label split, as a
<terminal_labelling> child of \a xml_element. Written only when on,
so a project with it off saves exactly as before.
*/
void QETProject::writeTerminalLabelSplitXml(QDomElement &xml_element)
{
if (!m_terminal_label_split) {
return;
}
QDomElement labelling = xml_element.ownerDocument()
.createElement(QStringLiteral("terminal_labelling"));
labelling.setAttribute(QStringLiteral("split"), QStringLiteral("true"));
xml_element.appendChild(labelling);
}
/**
@brief QETProject::writeWiringRulesXml
Export the project's wiring rules as a <wiring_rules> child of