Fix minor bug : conductor text is not updated when folio id is used

See https://qelectrotech.org/forum/viewtopic.php?pid=18157#p18157
This commit is contained in:
joshua
2023-04-17 22:09:18 +02:00
parent 31b648c2a0
commit 247b98da41
2 changed files with 9 additions and 6 deletions

View File

@@ -1765,25 +1765,29 @@ void Conductor::setSequenceNum(const autonum::sequentialNumbers& sn)
*/ */
void Conductor::setUpConnectionForFormula(QString old_formula, QString new_formula) void Conductor::setUpConnectionForFormula(QString old_formula, QString new_formula)
{ {
if (diagram()) Diagram *diagram_ {diagram()};
if (!diagram_) {
diagram_ = terminal1->diagram();
}
if (diagram_)
{ {
//Because the variable %F is a reference to another text which can contain variables, //Because the variable %F is a reference to another text which can contain variables,
//we must replace %F by the real text, to check if the real text contains the variable %id //we must replace %F by the real text, to check if the real text contains the variable %id
if (old_formula.contains("%F")) if (old_formula.contains("%F"))
old_formula.replace("%F", diagram()->border_and_titleblock.folio()); old_formula.replace("%F", diagram_->border_and_titleblock.folio());
if (old_formula.contains("%id")) if (old_formula.contains("%id"))
disconnect(diagram()->project(), &QETProject::projectDiagramsOrderChanged, this, &Conductor::refreshText); disconnect(diagram_->project(), &QETProject::projectDiagramsOrderChanged, this, &Conductor::refreshText);
//Label is frozen, so we don't update it. //Label is frozen, so we don't update it.
if (m_freeze_label == true) if (m_freeze_label == true)
return; return;
if (new_formula.contains("%F")) if (new_formula.contains("%F"))
new_formula.replace("%F", diagram()->border_and_titleblock.folio()); new_formula.replace("%F", diagram_->border_and_titleblock.folio());
if (new_formula.contains("%id")) if (new_formula.contains("%id"))
connect(diagram()->project(), &QETProject::projectDiagramsOrderChanged, this, &Conductor::refreshText); connect(diagram_->project(), &QETProject::projectDiagramsOrderChanged, this, &Conductor::refreshText);
} }
} }

View File

@@ -251,7 +251,6 @@ void ConductorTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *e) {
void ConductorTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *e) void ConductorTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *e)
{ {
Q_UNUSED(e); Q_UNUSED(e);
qDebug() << "Leave mouse over";
m_mouse_hover = false; m_mouse_hover = false;
update(); update();
} }