diff --git a/sources/diagram.cpp b/sources/diagram.cpp index 9940ced53..a03150e6d 100644 --- a/sources/diagram.cpp +++ b/sources/diagram.cpp @@ -2431,6 +2431,8 @@ void Diagram::folioSequentialsFromXml(const QDomElement &root, - linking the elements waiting to be linked - Refresh the connection of the dynamic element text item (use for text with source of text label) + - Fill the texts of a report (or a wire label) that show the + properties of the wire they are on. */ void Diagram::refreshContents() { @@ -2440,6 +2442,25 @@ void Diagram::refreshContents() elmt->initLink(project()); for (auto &deti : elmt->dynamicTextItems()) deti->refreshLabelConnection(); + /* + * A report's texts showing a wire's properties are filled when + * the wires are added, which is after the symbols are read + * (Diagram::buildContents()), and once more 100 ms later by + * DynamicElementTextItem::conductorWasAdded(). Both run after + * the project left the parsing state, so the alignment is live + * and the fill would take the rect of the still empty text for + * anchor -- a right aligned one then shifts by the whole width + * of its text, on every open. + * + * A linked report gets that fill here already, through + * initLink() -> linkedElementChanged() -> reportChanged(), while + * the project is still parsing; buildFolios() relies on it. An + * unlinked one, and one whose partner is on a folio not built + * yet, got nothing: fill them here too, in that same state. The + * later fill then finds the text already set and changes + * nothing. + */ + elmt->updateConductorTexts(); } for (auto &conductor : dc_.conductors()) { diff --git a/sources/qetgraphicsitem/element.cpp b/sources/qetgraphicsitem/element.cpp index e9eacba5f..d52eb2159 100644 --- a/sources/qetgraphicsitem/element.cpp +++ b/sources/qetgraphicsitem/element.cpp @@ -2715,22 +2715,32 @@ bool Element::definitionGeometryMatches(const QDomElement &definition) const /** * @brief Element::updateConductorTexts - *Slot that is triggered when a cable is * - *connected to or disconnected from a terminal on this component. - */ -/** - * @brief Element::updateConductorTexts + * Refresh the texts of this symbol that show the properties of the wire + * it is on: a wire label's own, and a folio report's (its function, + * section...). Slot triggered when a wire is connected to or + * disconnected from a terminal of this symbol. */ void Element::updateConductorTexts() { - if (m_link_type != Element::ConductorDefinition) { - return; + if (m_link_type == Element::ConductorDefinition) + { + for (DynamicElementTextItem *deti : m_dynamic_text_list) { + if (deti) { + deti->setPotentialConductor(); + deti->updateLabel(); + } + } } - - for (DynamicElementTextItem *deti : m_dynamic_text_list) { - if (deti) { - deti->setPotentialConductor(); - deti->updateLabel(); + else if (m_link_type & Element::AllReport) + { + //setPotentialConductor() ends on conductorPropertiesChanged(), + //which fills those texts. No updateLabel() here: a report's + //"label" text is not its own information but the linked + //folio's, refreshed by updateReportText(). + for (DynamicElementTextItem *deti : m_dynamic_text_list) { + if (deti) { + deti->setPotentialConductor(); + } } } }