mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-03 17:34:12 +02:00
Multi-wire panel: stable first wire, mixed fields, locked text, one reload
Review of #1205: - The scene gives no order for its selection, so the "first" wire whose values the panel shows could change between two selections of the same wires. The wires are now sorted top to bottom, then left to right. - A text field the selected wires do not agree on (function, section, cable...) is shown blank with the hint "Plusieurs valeurs". Typing any value there, including the first wire's own, now differs from what was shown, so it reaches every wire: 1.5 mm² on a 1.5 and a 2.5 wire works. - The conductor text is locked while several wires are selected: the same number on all of them would make duplicates. "Apply to all conductors of this potential" with one wire selected still sets the number on the whole potential. - One edit of N wires emitted N signals, each reloading the panel. They are now gathered into one reload, which matters since a reload reads every selected wire to find the mixed fields. Selections and targets are de-duplicated with sets, and a wire reached through an earlier wire's potential is not walked again. An edit that changes nothing returns before any potential is walked. The rules move to sources/conductormultiedit.h, templates over the wire type, so tst_conductormultiedit can check them against a fake wire: order, targets with and without potentials, one undo step and its redo for three wires, and the mixed fields. tst_conductorapplychanges now gives the other wire the opposite value in every boolean field, so copying one by mistake fails the test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -191,6 +191,48 @@ void ConductorPropertiesWidget::setHiddenOneTextPerFolio(const bool &hide) {
|
||||
ui -> m_one_text_per_folio_cb -> setHidden(hide);
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ConductorPropertiesWidget::setMixedTextFields
|
||||
Mark the text fields whose value differs between several edited
|
||||
conductors: they are shown blank, with a hint saying why.
|
||||
@param mixed
|
||||
*/
|
||||
void ConductorPropertiesWidget::setMixedTextFields(
|
||||
const QList<ConductorMultiEdit::TextField> &mixed)
|
||||
{
|
||||
using namespace ConductorMultiEdit;
|
||||
const QList<QPair<TextField, QLineEdit *>> edits {
|
||||
{Text, ui->m_text_le},
|
||||
{Formula, ui->m_formula_le},
|
||||
{Function, ui->m_function_le},
|
||||
{TensionProtocol, ui->m_tension_protocol_le},
|
||||
{WireColor, ui->m_wire_color_le},
|
||||
{WireSection, ui->m_wire_section_le},
|
||||
{Cable, ui->m_cable_le},
|
||||
{Bus, ui->m_bus_le}};
|
||||
|
||||
for (const auto &edit : edits)
|
||||
edit.second->setPlaceholderText(mixed.contains(edit.first)
|
||||
? tr("Plusieurs valeurs", "several conductors, different values")
|
||||
: QString());
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ConductorPropertiesWidget::setTextLocked
|
||||
Lock the conductor text while several conductors are edited at once:
|
||||
the same number on all of them would make duplicates.
|
||||
@param locked
|
||||
*/
|
||||
void ConductorPropertiesWidget::setTextLocked(bool locked)
|
||||
{
|
||||
m_text_locked = locked;
|
||||
ui->m_text_le->setEnabled(!locked && ui->m_formula_le->text().isEmpty());
|
||||
ui->m_text_le->setToolTip(locked
|
||||
? tr("Plusieurs conducteurs sélectionnés : le texte se modifie "
|
||||
"sur un seul conducteur à la fois.")
|
||||
: tr("Texte"));
|
||||
}
|
||||
|
||||
/**
|
||||
@brief ConductorPropertiesWidget::setDisabledShowText
|
||||
@param disable
|
||||
@@ -239,7 +281,7 @@ void ConductorPropertiesWidget::initWidget()
|
||||
|
||||
connect(ui->m_multiwires_gb, &QGroupBox::toggled, [this](bool toggle) {this->ui->m_singlewire_gb->setChecked(!toggle);});
|
||||
connect(ui->m_singlewire_gb, &QGroupBox::toggled, [this](bool toggle) {this->ui->m_multiwires_gb->setChecked(!toggle);});
|
||||
connect(ui->m_formula_le, &QLineEdit::textChanged, [this](QString text) {this->ui->m_text_le->setEnabled(text.isEmpty());});
|
||||
connect(ui->m_formula_le, &QLineEdit::textChanged, [this](QString text) {this->ui->m_text_le->setEnabled(!m_text_locked && text.isEmpty());});
|
||||
ui->m_multiwires_gb->setChecked(true);
|
||||
ui->m_singlewire_gb->setChecked(true);
|
||||
#if TODO_LIST
|
||||
|
||||
Reference in New Issue
Block a user