19 #include "ui_potentialselectordialog.h" 22 #include <QRadioButton> 71 Conductor *conductor_in_potential =
nullptr;
75 conductor_in_potential = terminal->
conductors().first();
88 conductor_in_potential = t->
conductors().first();
95 if (other_report->
terminals().isEmpty())
return;
98 conductor_in_potential= t->
conductors().first();
102 if (!conductor_in_potential)
108 c_list.append(conductor_in_potential);
171 if (list.isEmpty()) {
173 }
else if (list.size() == 1) {
177 QDialog dialog(widget);
178 QVBoxLayout layout(widget);
179 dialog.setLayout(&layout);
180 QLabel label(
tr(
"Veuillez choisir un potentiel électrique de la liste \n" 181 "à utiliser pour le nouveau potentiel"));
182 layout.addWidget(&label);
184 QHash <QRadioButton *, ConductorProperties> H;
188 if(!cp.text.isEmpty())
189 text.append(
tr(
"\nNuméro : %1").arg(cp.text));
190 if(!cp.m_function.isEmpty())
191 text.append(
tr(
"\nFonction : %1").arg(cp.m_function));
192 if(!cp.m_tension_protocol.isEmpty())
193 text.append(
tr(
"\nTension/protocole : %1").arg(cp.m_tension_protocol));
195 QRadioButton *b =
new QRadioButton(text, &dialog);
199 QDialogButtonBox *button_box =
new QDialogButtonBox(QDialogButtonBox::Ok, &dialog);
200 layout.addWidget(button_box);
201 connect(button_box, &QDialogButtonBox::accepted, &dialog, &QDialog::accept);
204 for (QRadioButton *b : H.keys()) {
223 m_conductor(conductor),
225 m_parent_undo(parent_undo)
242 m_conductor(nullptr),
244 m_parent_undo(parent_undo)
269 if(!cp1.
text.isEmpty())
270 text1.append(
tr(
"\nNuméro : %1").arg(cp1.
text));
272 text1.append(
tr(
"\nFonction : %1").arg(cp1.
m_function));
281 if(!cp2.
text.isEmpty())
282 text2.append(
tr(
"\nNuméro : %1").arg(cp2.
text));
284 text2.append(
tr(
"\nFonction : %1").arg(cp2.
m_function));
288 QRadioButton *rb1 =
new QRadioButton(text1,
this);
289 QRadioButton *rb2 =
new QRadioButton(text2,
this);
291 connect(rb1, &QRadioButton::toggled, [
this](
bool t)
300 connect(rb2, &QRadioButton::toggled, [
this](
bool t)
314 ui->verticalLayout->insertWidget(1, rb1);
315 ui->verticalLayout->insertWidget(2, rb2);
316 rb1->setChecked(
true);
320 ui->verticalLayout->insertWidget(1, rb2);
321 ui->verticalLayout->insertWidget(2, rb1);
322 rb2->setChecked(
true);
335 QUndoCommand *undo =
nullptr;
339 undo =
new QUndoCommand(
tr(
"Modifier les propriétés de plusieurs conducteurs",
"undo caption"));
350 QVariant old_value, new_value;
351 QVariant old_seq, new_seq;
360 new_value.setValue(new_properties);
367 QRegularExpression rx (
"%sequf_|%seqtf_|%seqhf_|%id|%F|%M|%LM");
372 QStringList forbidden_str;
373 forbidden_str <<
"%sequf_" <<
"%seqtf_" <<
"%seqhf_" <<
"%id" <<
"%F" <<
"%M" <<
"%LM";
375 QString text(
tr(
"La formule du nouveau potentiel contient des variables incompatibles avec les reports de folio.\n" 376 "Veuillez saisir une formule compatible pour ce potentiel.\n" 377 "Les variables suivantes sont incompatibles :\n" 378 "%sequf_ %seqtf_ %seqhf_ %id %F %M %LM"));
385 QString new_formula = fag.
formula();
386 QSet <Conductor *> c_list =
m_report->
conductors().first()->relatedPotentialConductors();
393 new_value.setValue(new_properties);
411 QVariant old_value, new_value;
413 new_value.setValue(new_properties);
415 QVariant old_seq, new_seq;
428 new_value.setValue(new_properties);
The QPropertyUndoCommand class This undo command manage QProperty of a QObject. This undo command can...
QList< ConductorProperties > m_properties_list_1
virtual void linkToElement(Element *)
QList< Conductor * > conductors() const
ConductorProperties properties
Conductor::properties.
virtual kind linkType() const
QList< Element * > linkedElements()
Element::linkedElements.
bool isValid() const override
bool addConductor(Conductor *conductor)
Terminal::addConductor Add a conductor to this terminal.
autonum::sequentialNumbers m_seq_num_2
~NewConductorPotentialSelector() override
void on_buttonBox_accepted()
PotentialSelectorDialog::on_buttonBox_accepted Action when user click on OK button.
QSet< Conductor * > relatedPotentialConductors(const bool all_diagram=true, QList< Terminal *> *t_list=nullptr)
Conductor::relatedPotentialConductors Return all conductors at the same potential of this conductor...
autonum::sequentialNumbers m_sequential_num
Diagram * diagram() const
QetGraphicsItem::diagram return the diagram of this item.
AbstractPotentialSelector * m_potential_selector
autonum::sequentialNumbers sequenceNum
The NewConductorPotentialSelector class Use for get the conductor propertie when two potentials is li...
QList< Conductor * > m_conductors_list_2
~PotentialSelectorDialog() override
QList< Conductor * > conductors() const
Element::conductors.
Element * parentElement() const
LinkReportPotentialSelector(Element *report)
QList< Terminal * > terminals() const
Element::terminals.
Diagram * diagram() const
PotentialSelectorDialog(Conductor *conductor, QUndoCommand *parent_undo=nullptr, QWidget *parent=nullptr)
PotentialSelectorDialog::PotentialSelectorDialog Constructor when we link two potentiels together...
QList< ConductorProperties > m_properties_list
virtual void unlinkAllElements()
NewConductorPotentialSelector(Conductor *conductor)
autonum::sequentialNumbers m_seq_num_1
The LinkReportPotentialSelector class Use for get the conductor propertie when two potentials is link...
void getPotential(Terminal *terminal, autonum::sequentialNumbers &seq_num, int &number, QList< ConductorProperties > &properties_list, QList< Conductor *> &c_list)
getPotential Get the conductor propertie of the potential at terminal, and the number of wire in this...
Ui::PotentialSelectorDialog * ui
QUndoCommand * m_parent_undo
QList< Conductor * > m_conductors_to_change
The PotentialSelectorDialog class This dialog is used when user try to connect two existing potential...
QList< ConductorProperties > m_properties_list_2
QString m_tension_protocol
~LinkReportPotentialSelector() override
void removeConductor(Conductor *conductor)
Terminal::removeConductor Remove a conductor from this terminal.
static ConductorProperties chosenProperties(QList< ConductorProperties > list, QWidget *parent=nullptr)
virtual bool isValid() const =0
void applyForEqualAttributes(QList< ConductorProperties > list)
ConductorProperties::applyForEqualAttributes Test each attribute of properties in the list separatly...
void buildWidget()
PotentialSelectorDialog::buildWidget Build the dialog.
bool isValid() const override
QList< Conductor * > m_conductors_list_1