Compare commits

...

12 Commits

Author SHA1 Message Date
plc-user 56464629bf FIX compile-warnings 2026-08-22 13:34:29 +02:00
plc-user c536dcf30f Merge pull request #746 from ispyisail/fix/issue413-paste-conductor-underscore-label
Fix pasted conductors getting an unwanted "_" label
2026-08-22 10:53:10 +02:00
plc-user 5db77fe40c Merge pull request #747 from ispyisail/fix/parttext-real-font-size-desync
Fix real_font_size_ desyncing from the actual font in PartText
2026-08-22 10:27:14 +02:00
Laurent Trinques bf816cbc44 Merge pull request #761 from ChuckNr11/master
Change element editor coordinates display
2026-08-22 10:11:40 +02:00
Laurent Trinques 315889baf4 Merge pull request #766 from Kellermorph/plc-fix
PLC terminal names: fix transfer to slaves and display in properties widgets
2026-08-22 10:00:34 +02:00
Kellermorph 2f6fb7808a fix 2026-08-22 09:52:01 +02:00
Laurent Trinques f951c20586 Update snapcraft.yaml 2026-08-22 09:20:31 +02:00
Kellermorph dbe2bcb599 PLC terminal names: fix transfer to slaves and display in properties widgets 2026-08-21 12:10:50 +02:00
ChuckNr11 9d81a9788f move position of element editor coord display to center of statusbar
for better visibility only
2026-08-19 12:00:43 +02:00
ChuckNr11 2803dcf8b8 Change live cursor-coordinate readout on running ESEvent
During an ESEvent, the mouse position was used without format with
`snapToGrid` to display the coordinates. However, since the `helpCross`
is positioned using `snapToGrid` during these events, the displayed
coordinates did not match the `helpCross` position.
The command for sending the coordinates has been moved to the
`ESEventInterface` to function 'updateHelpCross' and now transmits the
position of the intersection point of the helpCross lines.
2026-08-18 14:19:33 +02:00
ispyisail 3077527601 Fix real_font_size_ desyncing from the actual font in PartText
Follow-up to #158 / PR #501. While investigating that position bug,
found a second, separate one in the same area: PartText::setFont()
never updated real_font_size_, so it stayed frozen at whatever size the
item was constructed with.

That field isn't cosmetic - it's live data two other operations depend
on:

- startUserTransformation()/handleUserTransformation() use it as the
  base size when scaling the font as the user drags a resize handle.
  With it stale, dragging a handle after changing the size via the
  toolbar (or loading a file with a non-default size) scales from the
  wrong starting point - the resulting size has nothing to do with
  what's visibly on screen.
- flip() reads it directly to compute the repositioning offset, so a
  stale value also mis-positions the item on flip.

Fix: update real_font_size_ inside setFont(), the same place PR #501
already re-runs adjustItemPosition() for the same reason (font changed,
keep everything that depends on it in sync). fromXml() already routes
both its "size" and "font" attribute branches through setFont(), so
loaded elements pick this up for free.

Verified with a temporary instrumented build: typed a size into the
element editor's font-size field three times (9 -> 4 -> 48). Each
setFont() call's "before" value exactly matched the previous call's
"after" value, confirming real_font_size_ now tracks every change
instead of freezing at its construction-time value (9). Instrumentation
removed before committing.
2026-08-14 20:21:16 +12:00
ispyisail 4c7d4e7c53 Fix pasted conductors getting an unwanted "_" label
https://github.com/qelectrotech/qelectrotech-source-mirror/issues/413

## Bug

Copy-pasting an element pair joined by a conductor with no label
results in the pasted conductor having a literal "_" label, even
though the source conductor's label was empty. Repeating copy+paste on
the result keeps stacking the same "_" back on, since the pasted
conductor now legitimately has that text.

## Root cause

PasteDiagramCommand::redo() (sources/diagramcommands.cpp), when the
"erase label on copy" option is enabled (the default), resets each
pasted element's formula/label/comment/location to "" - a real erase.
Right next to it, the equivalent reset for conductors doesn't erase:

    cp.text = c->diagram() ? c->diagram()->defaultConductorProperties.text : "_";

It unconditionally overwrites the conductor's text with the *project's
configured default text for newly drawn conductors* - a setting that
happens to default to a literal "_" character (visible in the project/
new-folio "Conductors" tab), and is otherwise unrelated to whether this
particular copy's label should be kept or cleared. The `: "_"` fallback
for the "no diagram" case doesn't help either, since these conductors
are already added to the scene before this code runs.

## Fix

Reset conductor text to "" too, matching every other field reset in
the same block. "Erase on copy" should erase, not "replace with
whatever the project's unrelated new-conductor default happens to be."

## Verification

Built clean. I was not able to get a reliable live GUI reproduction
under Xvfb + xdotool for this one - drawing conductors between
terminals via simulated drag kept mis-firing as element placement
instead in this environment, the same class of automation friction
noted on PR #743. Confidence rests on tracing the exact code path
(confirmed defaultConductorProperties.text is a project-level setting
for freshly-drawn conductors, unrelated to paste; confirmed the
sibling element-info reset four lines above uses "" specifically) plus
the fact this is a one-line change to match an already-correct pattern
right next to it, not new logic.
2026-08-14 19:08:21 +12:00
14 changed files with 175 additions and 123 deletions
+3 -7
View File
@@ -15,13 +15,9 @@ platforms:
amd64:
arm64:
layout:
/usr/local/share/qelectrotech:
symlink: $SNAP/usr/local/share/qelectrotech
apps:
qelectrotech:
command: usr/local/bin/qelectrotech
command: usr/bin/qelectrotech
common-id: qelectrotech.desktop
extensions:
- kde-neon-6
@@ -109,8 +105,8 @@ parts:
override-stage: |
craftctl default
# patch desktop file with correct icon path
SED_CMD="sed -i -E s|^Icon=(.*)|Icon=\${SNAP}/usr/local/share/icons/hicolor/128x128/apps/\1.png|g"
$SED_CMD usr/local/share/applications/org.qelectrotech.qelectrotech.desktop
SED_CMD="sed -i -E s|^Icon=(.*)|Icon=\${SNAP}/usr/share/icons/hicolor/128x128/apps/\1.png|g"
$SED_CMD usr/share/applications/org.qelectrotech.qelectrotech.desktop
cleanup:
after: [qelectrotech, qet-tb-generator]
+8 -2
View File
@@ -106,12 +106,18 @@ void PasteDiagramCommand::redo()
dc.addValue("location", "");
e->setElementInformations(dc);
//Reset the text of conductors
//Reset the text of conductors, the same way the label/comment/
//location above are reset to "" rather than to some other
//value - "erase on copy" means erase, not "replace with the
//project's default new-conductor text" (which happens to
//default to a literal "_" character, unrelated to whether the
//user wanted this copy's old label kept or cleared; see
//issue #413).
const QList <Conductor *> conductors_list = content.m_conductors_to_move;
for (Conductor *c : conductors_list)
{
ConductorProperties cp = c -> properties();
cp.text = c->diagram() ? c -> diagram() -> defaultConductorProperties.text : "_";
cp.text = "";
c -> setProperties(cp);
}
}
+1 -1
View File
@@ -121,7 +121,7 @@ void ElementScene::mouseMoveEvent(QGraphicsSceneMouseEvent *e)
{
if (m_event_interface) {
if (m_event_interface -> mouseMoveEvent(e)) {
emit mouseMoved(e -> scenePos());
emit mouseMoved(snapToGrid(e->scenePos()));
if (m_event_interface->isFinish()) {
delete m_event_interface;
m_event_interface = nullptr;
+8
View File
@@ -440,6 +440,14 @@ void PartText::setFont(const QFont &font) {
// at a different spot after save/reopen (the position recomputes from
// the saved font on load). See #158.
adjustItemPosition();
// Keep real_font_size_ in sync with the actual font. It's the base
// size startUserTransformation()/handleUserTransformation() scale
// from when the user drags a resize handle, and flip() also reads it
// to reposition the item. Left stale here, either one computes from
// whatever size the item had when it was first created, ignoring any
// size set since (toolbar, property editor, or loaded from XML) -
// found investigating #158.
real_font_size_ = font.pointSize();
emit fontChanged(font);
}
}
+13 -1
View File
@@ -55,6 +55,7 @@
#include <QActionGroup>
#include <QFileDialog>
#include <QSvgGenerator>
#include <QHBoxLayout>
/**
* @brief QETElementEditor::QETElementEditor
@@ -1200,7 +1201,18 @@ void QETElementEditor::initGui()
//Live cursor position readout, in the same scene coordinates as the parts' X/Y properties
m_position_label = new QLabel(this);
m_position_label->setMinimumWidth(120);
statusBar()->addPermanentWidget(m_position_label);
// Layout
QHBoxLayout *coordDisplayLayout = new QHBoxLayout();
coordDisplayLayout->setContentsMargins(0, 0, 0, 0);
coordDisplayLayout->addWidget(m_position_label);
coordDisplayLayout->addStretch();
// Widget
QWidget *coordDisplay = new QWidget;
coordDisplay->setLayout(coordDisplayLayout);
statusBar()->addPermanentWidget(coordDisplay);
connect(m_elmt_scene, &ElementScene::mouseMoved, this, [this](const QPointF &pos) {
m_position_label->setText(tr("X: %1 Y: %2")
.arg(pos.x(), 0, 'f', 1)
+4 -1
View File
@@ -436,7 +436,10 @@ void ProjectPrintWindow::printDiagram(Diagram *diagram, bool fit_page, QPainter
// Build info text
QStringList lines;
for (const QString &key : {"label", "manufacturer", "designation", "description"}) {
for (const auto &key : {QStringLiteral("label"),
QStringLiteral("manufacturer"),
QStringLiteral("designation"),
QStringLiteral("description")}) {
if (info.contains(key) && !info.value(key).toString().isEmpty())
lines << QETInformation::translatedInfoKey(key) + ": " + info.value(key).toString();
}
+13
View File
@@ -99,6 +99,19 @@ class ElementData : public PropertiesInterface
int terminalCount = 1; ///< Number of terminals for this IO (1-4)
QStringList terminals; ///< Terminal values T1, T2, ... (size = terminalCount)
/**
* @brief Return terminal labels, generating defaults (T1, T2...) if empty
*/
QStringList effectiveTerminals() const {
if (!terminals.isEmpty())
return terminals;
int count = qMax(terminalCount, 1);
QStringList defaults;
for (int i = 0; i < count && i < 4; ++i)
defaults << QStringLiteral("T%1").arg(i + 1);
return defaults;
}
bool operator==(const PlcIO &other) const {
return type == other.type
&& address == other.address
+10 -7
View File
@@ -38,6 +38,15 @@
#include "dynamicelementtextitem.h"
#include "elementtextitemgroup.h"
#include "iostream"
#include <QCollator>
static const QString plcTerminalKeys[] = {
QETInformation::ELMT_PLC_T1,
QETInformation::ELMT_PLC_T2,
QETInformation::ELMT_PLC_T3,
QETInformation::ELMT_PLC_T4
};
#include "../qetxml.h"
#include "../qetversion.h"
#include "qgraphicsitemutility.h"
@@ -1511,13 +1520,7 @@ void Element::setElementData(ElementData data)
{
QString val = (t < io.terminals.size())
? io.terminals.at(t) : QString();
ctx.addValue(
QStringList({
QETInformation::ELMT_PLC_T1,
QETInformation::ELMT_PLC_T2,
QETInformation::ELMT_PLC_T3,
QETInformation::ELMT_PLC_T4
}).at(t), val);
ctx.addValue(plcTerminalKeys[t], val);
}
slave->setElementInformations(ctx);
+1 -3
View File
@@ -877,17 +877,15 @@ QUuid Terminal::stableUuid() const
QString Terminal::name() const
{
if (d->m_use_master_label && parent_element_) {
// Find the master element in the slave's linked elements
for (Element *elmt : parent_element_->linkedElements()) {
if (elmt->linkType() == Element::Master) {
int group_idx = elmt->groupIndexForElement(parent_element_);
if (group_idx >= 0) {
// For PLC masters, use io.terminals as labels
if (elmt->elementData().m_master_type == ElementData::PLC) {
const auto &plc_data = elmt->elementData().plcMasterData();
if (group_idx < plc_data.ios.size()) {
int label_idx = d->m_master_label_index;
const QStringList &labels = plc_data.ios.at(group_idx).terminals;
const QStringList labels = plc_data.ios.at(group_idx).effectiveTerminals();
if (label_idx >= 0 && label_idx < labels.size()) {
return labels.at(label_idx);
}
-2
View File
@@ -101,8 +101,6 @@ namespace qdesigner_internal {
QXmlStreamAttributes *atts,
bool *paragraphAlignmentFound)
{
typedef QXmlStreamAttributes::iterator AttributeIt;
if (atts->isEmpty())
return;
@@ -212,7 +212,7 @@ void ShortcutsConfigPage::applyFilter()
const int quick_filter = m_quick_filter->currentIndex();
int visible_actions = 0;
for (const Row &row : qAsConst(m_rows)) {
for (const Row &row : std::as_const(m_rows)) {
// Text is matched by substring, but the key sequence is matched exactly:
// a substring match would let "Ctrl+S" also hit "Ctrl+Shift+F" (the "S"
// of "Shift"), which is precisely the kind of false positive that hides
+19 -41
View File
@@ -525,10 +525,10 @@ void MasterPropertiesWidget::updateUi()
// Table
m_plc_table = new QTableWidget(m_plc_widget);
m_plc_table->setColumnCount(5);
m_plc_table->setColumnCount(6);
m_plc_table->setHorizontalHeaderLabels({
tr("Type"), tr("Adresse"), tr("Fonction"),
tr("Commentaire"), tr("Réf. croisée")
tr("Commentaire"), tr("Réf. croisée"), tr("Bornes")
});
m_plc_table->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
m_plc_table->setSelectionBehavior(QAbstractItemView::SelectItems);
@@ -592,6 +592,11 @@ void MasterPropertiesWidget::updateUi()
auto *crossref_item = new QTableWidgetItem(io.crossRef);
crossref_item->setFlags(crossref_item->flags() & ~Qt::ItemIsEditable);
m_plc_table->setItem(row, 4, crossref_item);
// Anschlüsse (read-only)
auto *terminals_item = new QTableWidgetItem(io.terminals.join(QStringLiteral(", ")));
terminals_item->setFlags(terminals_item->flags() & ~Qt::ItemIsEditable);
m_plc_table->setItem(row, 5, terminals_item);
}
m_plc_table->blockSignals(false);
@@ -806,23 +811,7 @@ void MasterPropertiesWidget::setCellFromValue(int row, int col, const QString &v
}
}
else if (col == 5) {
// Terminal count spinbox
auto *tc_sb = qobject_cast<QSpinBox*>(m_plc_table->cellWidget(row, col));
if (!tc_sb) {
tc_sb = new QSpinBox(m_plc_table);
tc_sb->setMinimum(1);
tc_sb->setMaximum(4);
m_plc_table->setCellWidget(row, col, tc_sb);
connect(tc_sb, QOverload<int>::of(&QSpinBox::valueChanged),
this, [this, row](int) { plcIOCellChanged(row, 5); });
}
bool ok;
int v = val.toInt(&ok);
if (ok && v >= 1 && v <= 4)
tc_sb->setValue(v);
}
else if (col == 6) {
// CrossRef - read-only
// Anschlüsse (read-only)
auto *item = new QTableWidgetItem(val);
item->setFlags(item->flags() & ~Qt::ItemIsEditable);
m_plc_table->setItem(row, col, item);
@@ -860,17 +849,10 @@ void MasterPropertiesWidget::plcAddRow()
m_plc_table->setItem(row, 3, new QTableWidgetItem());
m_plc_table->setItem(row, 4, new QTableWidgetItem());
auto *tc_sb = new QSpinBox(m_plc_table);
tc_sb->setMinimum(1);
tc_sb->setMaximum(4);
tc_sb->setValue(1);
m_plc_table->setCellWidget(row, 5, tc_sb);
connect(tc_sb, QOverload<int>::of(&QSpinBox::valueChanged),
this, [this, row](int) { plcIOCellChanged(row, 5); });
auto *crossref_item = new QTableWidgetItem();
crossref_item->setFlags(crossref_item->flags() & ~Qt::ItemIsEditable);
m_plc_table->setItem(row, 6, crossref_item);
// Anschlüsse (read-only)
auto *terminals_item = new QTableWidgetItem();
terminals_item->setFlags(terminals_item->flags() & ~Qt::ItemIsEditable);
m_plc_table->setItem(row, 5, terminals_item);
}
/**
@@ -997,14 +979,7 @@ void MasterPropertiesWidget::plcUpdateDisplaySettings()
ElementData::PlcMasterData plc_data = ed.plcMasterData();
plc_data.ios.clear();
// Build address -> original IO lookup to correctly reattach terminal data
// after row reorder (move up/down) or row removal
QHash<QString, int> addr_to_orig_idx;
for (int i = 0; i < ed.plcMasterData().ios.size(); ++i) {
addr_to_orig_idx[ed.plcMasterData().ios.at(i).address] = i;
}
// Read IOs from table, preserving terminal data from original IOs
// Read IOs from table, preserving terminal data from original IOs by row index
for (int row = 0; row < m_plc_table->rowCount(); ++row) {
ElementData::PlcIO io;
@@ -1028,9 +1003,12 @@ void MasterPropertiesWidget::plcUpdateDisplaySettings()
if (crossref_item)
io.crossRef = crossref_item->text();
// Preserve terminal data by looking up original IO via address
if (addr_to_orig_idx.contains(io.address)) {
const auto orig_io = ed.plcMasterData().ios.at(addr_to_orig_idx.value(io.address));
// Preserve terminal data by matching row index directly.
// This avoids address-based lookup which fails when all addresses
// are empty (common in PLC masters) — a hash collision would cause
// only the last IO's terminals to be used for all rows.
if (row < ed.plcMasterData().ios.size()) {
const auto &orig_io = ed.plcMasterData().ios.at(row);
io.terminalCount = orig_io.terminalCount;
io.terminals = orig_io.terminals;
}
+3 -3
View File
@@ -65,7 +65,7 @@ PlcLinkWidget::PlcLinkWidget(Element *elmt, QWidget *parent)
m_tree_widget = new QTreeWidget(this);
m_tree_widget->setHeaderLabels({
tr("Label"), tr("Type"), tr("Adresse"),
tr("Fonction"), tr("Commentaire"), tr("Anschlüsse")
tr("Fonction"), tr("Commentaire"), tr("Bornes")
});
m_tree_widget->setRootIsDecorated(true);
m_tree_widget->setIndentation(20);
@@ -225,8 +225,8 @@ void PlcLinkWidget::buildPlcTree()
child_item->setText(3, io.functionText);
child_item->setText(4, io.comment);
// Terminal count
child_item->setText(5, QString::number(io.terminalCount));
// Terminal names
child_item->setText(5, io.terminals.join(QStringLiteral(", ")));
PlcIoEntry entry;
entry.master = elmt;
+91 -54
View File
@@ -31,6 +31,16 @@
#include "../autoNum/assignvariables.h"
#include "../autoNum/numerotationcontextcommands.h"
#include <algorithm>
#include <QCollator>
static const QString plcTerminalKeys[] = {
QETInformation::ELMT_PLC_T1,
QETInformation::ELMT_PLC_T2,
QETInformation::ELMT_PLC_T3,
QETInformation::ELMT_PLC_T4
};
/**
@brief Get the cross-ref text for a slave element using XRefProperties formula
@param master the PLC master element
@@ -408,15 +418,16 @@ void LinkElementCommand::makeLink(const QList<Element *> &element_list)
// Set master labels on slave terminals
if (elmt->elementData().m_master_type == ElementData::PLC)
{
// For PLC masters, use io.terminals as labels
const auto &plc_data = elmt->elementData().plcMasterData();
if (group_idx < plc_data.ios.size())
{
const QStringList &labels = plc_data.ios.at(group_idx).terminals;
const QStringList labels = plc_data.ios.at(group_idx).effectiveTerminals();
QList<Terminal *> slave_terms = m_element->terminals();
QCollator collator;
collator.setNumericMode(true);
std::sort(slave_terms.begin(), slave_terms.end(),
[](Terminal *a, Terminal *b) {
return a->baseName() < b->baseName();
[&collator](Terminal *a, Terminal *b) {
return collator.compare(a->baseName(), b->baseName()) < 0;
});
for (int i = 0; i < slave_terms.size(); ++i)
{
@@ -426,6 +437,29 @@ void LinkElementCommand::makeLink(const QList<Element *> &element_list)
slave_terms.at(i)->setMasterLabelIndex(i);
}
}
// Populate PLC variables on the slave
const auto &io = plc_data.ios.at(group_idx);
DiagramContext ctx = m_element->elementInformations();
ctx.addValue(QETInformation::ELMT_PLC_TYPE,
ElementData::translatedPlcIOType(io.type));
ctx.addValue(QETInformation::ELMT_PLC_ADDRESS, io.address);
ctx.addValue(QETInformation::ELMT_PLC_FUNCTION, io.functionText);
ctx.addValue(QETInformation::ELMT_PLC_COMMENT, io.comment);
ctx.addValue(QETInformation::ELMT_PLC_CROSSREF,
plcCrossRefText(elmt, m_element));
ctx.addValue(QETInformation::ELMT_LABEL,
elmt->actualLabel());
ctx.addValue(QETInformation::ELMT_PLC_TC,
QString::number(io.terminalCount));
const QStringList eff_terms = io.effectiveTerminals();
for (int t = 0; t < io.terminalCount && t < 4; ++t)
{
QString val = (t < eff_terms.size())
? eff_terms.at(t) : QString();
ctx.addValue(plcTerminalKeys[t], val);
}
m_element->setElementInformations(ctx);
}
}
else
@@ -435,9 +469,11 @@ void LinkElementCommand::makeLink(const QList<Element *> &element_list)
{
const QStringList &labels = groups.at(group_idx).labels;
QList<Terminal *> slave_terms = m_element->terminals();
QCollator collator;
collator.setNumericMode(true);
std::sort(slave_terms.begin(), slave_terms.end(),
[](Terminal *a, Terminal *b) {
return a->baseName() < b->baseName();
[&collator](Terminal *a, Terminal *b) {
return collator.compare(a->baseName(), b->baseName()) < 0;
});
for (int i = 0; i < slave_terms.size(); ++i)
{
@@ -450,41 +486,6 @@ void LinkElementCommand::makeLink(const QList<Element *> &element_list)
}
}
// Populate PLC variables on the slave if master is PLC type
if (elmt->elementData().m_master_type == ElementData::PLC)
{
const auto &plc_data = elmt->elementData().plcMasterData();
if (group_idx < plc_data.ios.size())
{
const auto &io = plc_data.ios.at(group_idx);
DiagramContext ctx = m_element->elementInformations();
ctx.addValue(QETInformation::ELMT_PLC_TYPE,
ElementData::translatedPlcIOType(io.type));
ctx.addValue(QETInformation::ELMT_PLC_ADDRESS, io.address);
ctx.addValue(QETInformation::ELMT_PLC_FUNCTION, io.functionText);
ctx.addValue(QETInformation::ELMT_PLC_COMMENT, io.comment);
ctx.addValue(QETInformation::ELMT_PLC_CROSSREF,
plcCrossRefText(elmt, m_element));
ctx.addValue(QETInformation::ELMT_LABEL,
elmt->actualLabel());
ctx.addValue(QETInformation::ELMT_PLC_TC,
QString::number(io.terminalCount));
for (int t = 0; t < io.terminalCount && t < 4; ++t)
{
QString val = (t < io.terminals.size())
? io.terminals.at(t) : QString();
ctx.addValue(
QStringList({
QETInformation::ELMT_PLC_T1,
QETInformation::ELMT_PLC_T2,
QETInformation::ELMT_PLC_T3,
QETInformation::ELMT_PLC_T4
}).at(t), val);
}
m_element->setElementInformations(ctx);
}
}
break;
}
}
@@ -502,22 +503,49 @@ void LinkElementCommand::makeLink(const QList<Element *> &element_list)
m_element->setGroupIndexForElement(slave, group_idx);
// Set master labels on slave terminals
const auto &groups = m_element->elementData().m_slave_contact_groups;
if (group_idx < groups.size())
if (m_element->elementData().m_master_type == ElementData::PLC)
{
const QStringList &labels = groups.at(group_idx).labels;
QList<Terminal *> slave_terms = slave->terminals();
// Sort terminals by name (T1, T2, T3...) to match label order
std::sort(slave_terms.begin(), slave_terms.end(),
[](Terminal *a, Terminal *b) {
return a->name() < b->name();
});
for (int i = 0; i < slave_terms.size(); ++i)
const auto &plc_data = m_element->elementData().plcMasterData();
if (group_idx < plc_data.ios.size())
{
if (i < labels.size())
const QStringList labels = plc_data.ios.at(group_idx).effectiveTerminals();
QList<Terminal *> slave_terms = slave->terminals();
QCollator collator;
collator.setNumericMode(true);
std::sort(slave_terms.begin(), slave_terms.end(),
[&collator](Terminal *a, Terminal *b) {
return collator.compare(a->baseName(), b->baseName()) < 0;
});
for (int i = 0; i < slave_terms.size(); ++i)
{
slave_terms.at(i)->setUseMasterLabel(true);
slave_terms.at(i)->setMasterLabelIndex(i);
if (i < labels.size())
{
slave_terms.at(i)->setUseMasterLabel(true);
slave_terms.at(i)->setMasterLabelIndex(i);
}
}
}
}
else
{
const auto &groups = m_element->elementData().m_slave_contact_groups;
if (group_idx < groups.size())
{
const QStringList &labels = groups.at(group_idx).labels;
QList<Terminal *> slave_terms = slave->terminals();
QCollator collator;
collator.setNumericMode(true);
std::sort(slave_terms.begin(), slave_terms.end(),
[&collator](Terminal *a, Terminal *b) {
return collator.compare(a->baseName(), b->baseName()) < 0;
});
for (int i = 0; i < slave_terms.size(); ++i)
{
if (i < labels.size())
{
slave_terms.at(i)->setUseMasterLabel(true);
slave_terms.at(i)->setMasterLabelIndex(i);
}
}
}
}
@@ -539,6 +567,15 @@ void LinkElementCommand::makeLink(const QList<Element *> &element_list)
plcCrossRefText(m_element, slave));
ctx.addValue(QETInformation::ELMT_LABEL,
m_element->actualLabel());
ctx.addValue(QETInformation::ELMT_PLC_TC,
QString::number(io.terminalCount));
const QStringList eff_terms = io.effectiveTerminals();
for (int t = 0; t < io.terminalCount && t < 4; ++t)
{
QString val = (t < eff_terms.size())
? eff_terms.at(t) : QString();
ctx.addValue(plcTerminalKeys[t], val);
}
slave->setElementInformations(ctx);
}
}