This commit is contained in:
Kellermorph
2026-08-01 14:26:39 +02:00
parent 4c1f82f814
commit e91bab14fe
6 changed files with 162 additions and 98 deletions
+11 -3
View File
@@ -1397,16 +1397,20 @@ void Element::setElementInformations(DiagramContext dc)
}
emit elementInfoChange(old_info, m_data.m_informations);
// Propagate label change to linked PLC slaves
// Propagate label change to linked PLC slaves (label is changed via
// setElementInformations through the undo stack, not via setElementData)
if (m_data.m_type == ElementData::Master && m_data.m_master_type == ElementData::PLC)
{
if (!m_group_index_map.isEmpty()) {
if (!m_group_index_map.isEmpty())
{
const QString new_label = actualLabel();
for (auto it = m_group_index_map.constBegin(); it != m_group_index_map.constEnd(); ++it)
{
Element *slave = it.key();
if (!slave)
continue;
if (slave->elementInformations().value(QETInformation::ELMT_LABEL).toString() == new_label)
continue;
DiagramContext ctx = slave->elementInformations();
ctx.addValue(QETInformation::ELMT_LABEL, new_label);
slave->setElementInformations(ctx);
@@ -1480,6 +1484,7 @@ void Element::setElementData(ElementData data)
return autonum::AssignVariables::formulaToLabel(
xrp.slaveLabel(), seq, diagram(), this);
}());
ctx.addValue(QETInformation::ELMT_LABEL, actualLabel());
ctx.addValue(QETInformation::ELMT_PLC_TC,
QString::number(io.terminalCount));
for (int t = 0; t < io.terminalCount && t < 4; ++t)
@@ -1511,7 +1516,7 @@ void Element::setElementData(ElementData data)
}
}
}
else if (label_changed)
if (label_changed)
{
// Only label changed, update the label on the slave
DiagramContext ctx = slave->elementInformations();
@@ -1958,7 +1963,10 @@ void Element::drawPlcTable(QPainter *painter)
}
QRectF text_rect = cr.adjusted(1, 0, -1, 0);
painter->save();
painter->setClipRect(text_rect, Qt::IntersectClip);
painter->drawText(text_rect, Qt::AlignLeft | Qt::AlignVCenter | Qt::TextWordWrap, cell_text);
painter->restore();
cx += col_widths[col];
}