Take the slot count from the contact groups when an element declares them

An element can declare contact groups and a max_slaves that disagree with
each other, and nothing reconciles them.

The element editor keeps the two in step: max_slaves sizes the contact
group table, one row per slot. Nothing does so on load, so a hand
written or generated file can carry five groups and max_slaves=2. That
loads without complaint, isFull() then caps linking at two, and
ContactGroupSelectionDialog still offers all five groups -- so the user
is shown groups that cannot be linked to, with nothing to explain why.

When groups are declared they are the slots: a slave occupies exactly
one, and the selection dialog offers exactly these. So take the limit
from the group count, which is also the number the user can see.
max_slaves stays as the fallback for the elements that declare no
groups, which today is every element in the standard collection.

No element in the collection declares contact groups, so this changes
nothing for existing projects.

Verified with two purpose-built fixtures, since no real element
exercises either path: a coil declaring five groups with max_slaves=2
now takes the limit from the groups, and a coil with max_slaves and no
groups still takes the fallback path unchanged.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
ispyisail
2026-09-09 14:41:11 +12:00
parent c265f0206c
commit c6995a0e7e
+16
View File
@@ -233,6 +233,22 @@ void MasterElement::aboutDeleteXref()
*/
bool MasterElement::isFull() const
{
//When the element declares contact groups, those groups are the
//slots: a slave occupies exactly one, and ContactGroupSelectionDialog
//offers exactly these. So the group count is the limit, and it is the
//one the user can actually see.
//
//max_slaves is the fallback for elements which declare no groups. The
//element editor keeps the two in step -- max_slaves sizes the group
//table -- but nothing reconciles them on load, so a hand written or
//generated file can carry five groups and max_slaves=2. Taking
//max_slaves there capped linking at two while the dialog still
//offered all five, which the user could only read as the dialog
//being broken.
if (!m_data.m_slave_contact_groups.isEmpty()) {
return connected_elements.size() >= m_data.m_slave_contact_groups.size();
}
// Set default value to -1 (unlimited slaves)
int max_slaves = -1;
QVariant max_slaves_variant = kindInformations().value("max_slaves");