mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-10 22:24:13 +02:00
Write the cable XML only where it has something to carry
Two pieces of cable XML went into every file the program saved, whether the project had cables or not (non-blocking review comment by ispyisail). Resaving one of the example projects added both of them. - <cable_autonums> is now written only when it holds something: a named rule, an axis other than the default, the numbering question answered with no, or a rule of its own. When it is missing, the reader falls back to exactly the defaults a project which never touched cable numbering has, so nothing changes for those files. That is deliberately not "only when the project has cables", which would cost data: a rule configured before the first cable is drawn and an axis chosen before it are answers only this element can carry, and the question answered with no has to survive even if the cable which prompted it was cancelled again. - the font attribute of <xref> is now written only when there is one. Only the cable cross-reference has a font of its own; writing it unconditionally put font="" on every cross-reference type of every project, and an absent attribute reads back as no font, which is what all the others are. Verified by resaving examples/741.qet, examples/Projet_vierge.qet and examples/affuteuse_250h.qet: before, cable_autonums=1 and font="" on each; after, none of them. A cable project of the reviewer's own keeps <cable_autonums axis_priority="y" current_autonum="Cable"> with its rule and its real fonts, and only loses the four empty font attributes. ctest 92/93, the one failure being the pre-existing headless tst_menubarkeyboard.
This commit is contained in:
@@ -172,7 +172,14 @@ QDomElement XRefProperties::toXml(QDomDocument &xml_document) const
|
||||
xml_element.setAttribute("master_label", master_label);
|
||||
QString slave_label = m_slave_label;
|
||||
xml_element.setAttribute("slave_label", slave_label);
|
||||
xml_element.setAttribute("font", m_font);
|
||||
//Only the cable cross-reference has a font of its own, and only
|
||||
//it ever sets one. Writing the attribute unconditionally put
|
||||
//font="" on every cross-reference type of every project the
|
||||
//program saved; a file which does not hold the attribute reads
|
||||
//back as no font, which is what all of them are.
|
||||
if (!m_font.isEmpty()) {
|
||||
xml_element.setAttribute("font", m_font);
|
||||
}
|
||||
foreach (QString key, m_prefix.keys()) {
|
||||
xml_element.setAttribute(key % "prefix", m_prefix.value(key));
|
||||
}
|
||||
|
||||
+23
-1
@@ -2891,6 +2891,17 @@ void QETProject::writeDefaultPropertiesXml(QDomElement &xml_element)
|
||||
|
||||
//Export Cable Autonum -- one rule, but stored exactly like the others
|
||||
//so it travels with the project and survives a re-save untouched.
|
||||
//
|
||||
//Only when it holds something, though. An element which is not there
|
||||
//reads back as exactly the defaults a project which never touched
|
||||
//cable numbering already has, so writing it every time put
|
||||
//<cable_autonums> into every file the program saved -- into the
|
||||
//example projects and into projects without a single cable in them.
|
||||
//
|
||||
//That is not the same as writing it only for projects with cables,
|
||||
//which would cost data: a rule named before the first cable is
|
||||
//drawn, an axis chosen before it, and the numbering question
|
||||
//answered with no are answers only this element can carry.
|
||||
QDomElement cable_autonums = xml_document.createElement("cable_autonums");
|
||||
cable_autonums.setAttribute("current_autonum", m_current_cable_autonum);
|
||||
cable_autonums.setAttribute("axis_priority",
|
||||
@@ -2901,6 +2912,7 @@ void QETProject::writeDefaultPropertiesXml(QDomElement &xml_element)
|
||||
if (!m_cable_ask_numbering) {
|
||||
cable_autonums.setAttribute("ask_numbering_rule", "false");
|
||||
}
|
||||
int written_cable_rules = 0;
|
||||
QStringList cable_autonum_keys = cableAutoNum().keys();
|
||||
cable_autonum_keys.sort();
|
||||
for (const QString &key : std::as_const(cable_autonum_keys)) {
|
||||
@@ -2909,9 +2921,19 @@ void QETProject::writeDefaultPropertiesXml(QDomElement &xml_element)
|
||||
cable_autonum.setAttribute("title", key);
|
||||
cable_autonum.setAttribute("formula", cableAutoNumFormula(key));
|
||||
cable_autonums.appendChild(cable_autonum);
|
||||
++written_cable_rules;
|
||||
}
|
||||
}
|
||||
xml_element.appendChild(cable_autonums);
|
||||
//Nothing to keep when the project never named a rule, never
|
||||
//chose an axis other than the default and has not answered the
|
||||
//numbering question with no -- then this element would say
|
||||
//nothing the reader does not assume anyway.
|
||||
if (!m_current_cable_autonum.isEmpty()
|
||||
|| !m_cable_ask_numbering
|
||||
|| !m_cable_axis_x_first
|
||||
|| written_cable_rules > 0) {
|
||||
xml_element.appendChild(cable_autonums);
|
||||
}
|
||||
|
||||
// Export default guides
|
||||
QDomElement guides_elmt = xml_document.createElement("guides");
|
||||
|
||||
Reference in New Issue
Block a user