mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-01 15:24:13 +02:00
Merge pull request #1010 from Kellermorph/full-contact-comb
Full contact comb
This commit is contained in:
@@ -589,6 +589,29 @@ void ElementPropertiesEditorWidget::populateSlaveGroupsTable()
|
||||
contact_ct->setValue(group.contactCount);
|
||||
ui->m_slave_groups_table->setCellWidget(i, 2, contact_ct);
|
||||
|
||||
// When the contact count changes, keep the terminal count in step
|
||||
// with it, otherwise the two drift apart (both are edited
|
||||
// independently): the stored terminals-per-contact ratio is kept,
|
||||
// or the contact type default (2, 3 for a switch) is used when the
|
||||
// stored values don't divide evenly (inconsistent legacy data).
|
||||
const int old_contacts = group.contactCount;
|
||||
const int old_terminals = group.terminalCount;
|
||||
connect(contact_ct, QOverload<int>::of(&QSpinBox::valueChanged),
|
||||
this, [this, i, old_contacts, old_terminals](int val) {
|
||||
if (i < m_data.m_slave_contact_groups.size()) {
|
||||
readSlaveGroupsFromTable();
|
||||
auto &group = m_data.m_slave_contact_groups[i];
|
||||
int per_pole = old_terminals / qMax(1, old_contacts);
|
||||
if (per_pole < 1 || old_terminals % qMax(1, old_contacts) != 0)
|
||||
per_pole = group.type == ElementData::SW ? 3 : 2;
|
||||
else if (group.type == ElementData::SW && per_pole < 3)
|
||||
per_pole = 3; //a switch needs common, NC and NO
|
||||
group.contactCount = val;
|
||||
group.terminalCount = val * per_pole;
|
||||
populateSlaveGroupsTable();
|
||||
}
|
||||
});
|
||||
|
||||
// Terminal count
|
||||
auto *terminal_ct = new QSpinBox(ui->m_slave_groups_table);
|
||||
terminal_ct->setMinimum(1);
|
||||
|
||||
Reference in New Issue
Block a user