Fix the wire properties panel changing properties nobody edited

With "Show the properties of a selected conductor in the Selection
properties panel" switched on, editing a wire there could change things
the user never touched:

- Enter in a field (Function, Section...) is not used by the line edit,
  so it reaches the checkable "Multifilaire" group box around it, which
  takes it as a click. The wire was switched to single-line, gaining
  ground, neutral and phase symbols. The modal dialog never shows this
  because its OK button takes Enter first.
- Every edit wrote back the whole set of properties as the widget holds
  them, so a value the widget cannot show exactly was rewritten: a dash
  size of 1 became 2.

The panel now swallows Enter at its checkable group boxes, and writes
only the fields that differ from what it showed, through the new
ConductorProperties::applyChanges(). "Apply to all conductors of this
potential" uses the same rule, so the rest of the potential keeps its
own values too.

tst_conductorapplychanges checks each field on its own: change that one
field, and a wire whose every field differs takes it and keeps the rest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
ispyisail
2026-10-01 23:10:15 +13:00
parent 7fdc314e41
commit a8699f6f62
6 changed files with 307 additions and 35 deletions
+52
View File
@@ -757,6 +757,58 @@ void ConductorProperties::applyForEqualAttributes(QList<ConductorProperties> lis
equal = true;
}
/**
@brief ConductorProperties::applyChanges
Copy into this every attribute that differs between before and after,
and leave every other attribute as it is. The Selection properties
panel applies an edit this way, so a conductor keeps everything the
user did not change: its own text, function, cable... and any value
the panel cannot show exactly.
@param before : the properties as they were shown to the user
@param after : the properties after the user's edit
*/
void ConductorProperties::applyChanges(const ConductorProperties &before,
const ConductorProperties &after)
{
const auto take = [](auto &mine, const auto &was, const auto &now) {
if (was != now)
mine = now;
};
take(type, before.type, after.type);
take(color, before.color, after.color);
take(m_bicolor, before.m_bicolor, after.m_bicolor);
take(m_color_2, before.m_color_2, after.m_color_2);
take(m_dash_size, before.m_dash_size, after.m_dash_size);
take(style, before.style, after.style);
take(text, before.text, after.text);
take(text_color, before.text_color, after.text_color);
take(m_formula, before.m_formula, after.m_formula);
take(m_cable, before.m_cable, after.m_cable);
take(m_bus, before.m_bus, after.m_bus);
take(m_function, before.m_function, after.m_function);
take(m_tension_protocol, before.m_tension_protocol, after.m_tension_protocol);
take(m_wire_color, before.m_wire_color, after.m_wire_color);
take(m_wire_section, before.m_wire_section, after.m_wire_section);
take(m_show_text, before.m_show_text, after.m_show_text);
take(text_size, before.text_size, after.text_size);
take(cond_size, before.cond_size, after.cond_size);
take(verti_rotate_text, before.verti_rotate_text, after.verti_rotate_text);
take(horiz_rotate_text, before.horiz_rotate_text, after.horiz_rotate_text);
take(m_one_text_per_folio, before.m_one_text_per_folio, after.m_one_text_per_folio);
take(m_horizontal_alignment, before.m_horizontal_alignment, after.m_horizontal_alignment);
take(m_vertical_alignment, before.m_vertical_alignment, after.m_vertical_alignment);
//Single-line symbols, one by one
SingleLineProperties slp_before = before.singleLineProperties;
SingleLineProperties slp_after = after.singleLineProperties;
take(singleLineProperties.hasGround, slp_before.hasGround, slp_after.hasGround);
take(singleLineProperties.hasNeutral, slp_before.hasNeutral, slp_after.hasNeutral);
take(singleLineProperties.is_pen, slp_before.is_pen, slp_after.is_pen);
if (slp_before.phasesCount() != slp_after.phasesCount())
singleLineProperties.setPhasesCount(slp_after.phasesCount());
}
/**
@brief ConductorProperties::defaultProperties
@return the default properties stored in the setting file